[Mplayer-cvslog] CVS: main/libmpdemux tvi_v4l.c,1.31,1.32

Alex Beregszaszi alex at mplayerhq.hu
Wed Oct 2 18:47:44 CEST 2002


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

Modified Files:
	tvi_v4l.c 
Log Message:
some cleanups for video_grabber() which fix a race condition by Jindrich Makovicka <makovick at kmlinux.fjfi.cvut.cz>

Index: tvi_v4l.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_v4l.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- tvi_v4l.c	28 Sep 2002 18:49:47 -0000	1.31
+++ tvi_v4l.c	2 Oct 2002 16:47:41 -0000	1.32
@@ -1184,7 +1184,7 @@
     mp_dbg(MSGT_TV, MSGL_DBG3, "\npicture sync failed\n");
 
     prev_interval = 0.0;
-    prev_skew = priv->audio_skew;
+    prev_skew = 0.0;
 
     for (;!priv->shutdown;)
     {
@@ -1209,29 +1209,33 @@
 		priv->starttime = curtime.tv_sec + curtime.tv_usec*.000001;
 		priv->audio_skew_measure_time = 0;
 		pthread_mutex_unlock(&priv->audio_starter);
+		// first frame must always have timestamp of zero
+		xskew = 0.0;
+		skew = 0.0;
+		interval = 0.0;
 		first = 0;
-	    }
+	    } else {
+		interval = curtime.tv_sec + curtime.tv_usec*.000001 - priv->starttime;
 
-	    interval = curtime.tv_sec + curtime.tv_usec*.000001 - priv->starttime;
+		if (!priv->immediate_mode && (
+			(interval - prev_interval < 1.0/priv->fps*0.85)
+			|| (interval - prev_interval > 1.0/priv->fps*1.15) ) ) {
+		    mp_msg(MSGT_TV, MSGL_V, "\nvideo capture thread: frame delta ~ %.1lf fps\n",
+			   1.0/(interval - prev_interval));
+		}
 
-	    if (!priv->immediate_mode && (
-		    ((interval - prev_interval < 1.0/priv->fps*0.85) && interval > 0.0001)
-		    || (interval - prev_interval > 1.0/priv->fps*1.15) ) ) {
-		mp_msg(MSGT_TV, MSGL_V, "\nvideo capture thread: frame delta ~ %.1lf fps\n",
-		       1.0/(interval - prev_interval));
-	    }
-
-	    // interpolate the skew in time
-	    pthread_mutex_lock(&priv->skew_mutex);
-	    xskew = priv->audio_skew + (interval - priv->audio_skew_measure_time)*priv->audio_skew_factor;
-	    pthread_mutex_unlock(&priv->skew_mutex);
-	    // correct extreme skew changes to avoid (especially) moving backwards in time
-	    if (xskew - prev_skew > (interval - prev_interval)*MAX_SKEW_DELTA) {
-		skew = prev_skew + (interval - prev_interval)*MAX_SKEW_DELTA;
-	    } else if (xskew - prev_skew < -(interval - prev_interval)*MAX_SKEW_DELTA) {
-		skew = prev_skew - (interval - prev_interval)*MAX_SKEW_DELTA;
-	    } else {
-		skew = xskew;
+		// interpolate the skew in time
+		pthread_mutex_lock(&priv->skew_mutex);
+		xskew = priv->audio_skew + (interval - priv->audio_skew_measure_time)*priv->audio_skew_factor;
+		pthread_mutex_unlock(&priv->skew_mutex);
+		// correct extreme skew changes to avoid (especially) moving backwards in time
+		if (xskew - prev_skew > (interval - prev_interval)*MAX_SKEW_DELTA) {
+		    skew = prev_skew + (interval - prev_interval)*MAX_SKEW_DELTA;
+		} else if (xskew - prev_skew < -(interval - prev_interval)*MAX_SKEW_DELTA) {
+		    skew = prev_skew - (interval - prev_interval)*MAX_SKEW_DELTA;
+		} else {
+		    skew = xskew;
+		}
 	    }
 
 	    mp_msg(MSGT_TV, MSGL_DBG3, "\nfps = %lf, v_interval = %lf, a_skew = %f, corr_skew = %f\n",




More information about the MPlayer-cvslog mailing list