[Mplayer-cvslog] CVS: main/libmpdemux tvi_v4l2.c,1.7,1.8

Jindrich Makovicka CVS henry at mplayerhq.hu
Thu Sep 11 23:05:46 CEST 2003


Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv18298

Modified Files:
	tvi_v4l2.c 
Log Message:
yet another sync fix

Index: tvi_v4l2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_v4l2.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- tvi_v4l2.c	5 Sep 2003 10:35:00 -0000	1.7
+++ tvi_v4l2.c	11 Sep 2003 21:05:16 -0000	1.8
@@ -77,7 +77,7 @@
     struct map			*map;
     int				mapcount;
     int				frames;
-    long long                   first_frame;
+    volatile long long          first_frame;
     long long                   curr_frame;
     /* audio video interleaving ;-) */
     volatile int		streamon;
@@ -1395,7 +1395,9 @@
 
 	/* store the timestamp of the very first frame as reference */
 	if (!priv->frames++) {
+	    pthread_mutex_lock(&priv->skew_mutex);
 	    priv->first_frame = (long long)1e6*buf.timestamp.tv_sec + buf.timestamp.tv_usec;
+	    pthread_mutex_unlock(&priv->skew_mutex);
 	}
 	priv->curr_frame = (long long)buf.timestamp.tv_sec*1e6+buf.timestamp.tv_usec;
 //	fprintf(stderr, "idx = %d, ts = %lf\n", buf.index, (double)(priv->curr_frame) / 1e6);
@@ -1610,6 +1612,12 @@
 	priv->audio_skew_measure_time = current_time;
 	prev_skew = priv->audio_skew;
 	priv->audio_skew -= priv->audio_start_time - priv->first_frame;
+
+	// re-adjust the skew to zero after first few audio frames
+	if (priv->audio_recv_blocks_total == priv->aud_skew_cnt) {
+	    priv->audio_start_time += priv->audio_skew;
+	}
+
 	pthread_mutex_unlock(&priv->skew_mutex);
 
 //	fprintf(stderr, "audio_skew = %lf, delta = %lf\n", (double)priv->audio_skew/1e6, (double)priv->audio_skew_delta_total/1e6);



More information about the MPlayer-cvslog mailing list