Mercurial > mplayer.hg
changeset 7585:cfd6a99021ac
some cleanups for video_grabber() which fix a race condition by Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
author | alex |
---|---|
date | Wed, 02 Oct 2002 16:47:41 +0000 |
parents | 838ee1b00853 |
children | d12421dd1265 |
files | libmpdemux/tvi_v4l.c |
diffstat | 1 files changed, 26 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/tvi_v4l.c Wed Oct 02 16:46:55 2002 +0000 +++ b/libmpdemux/tvi_v4l.c Wed Oct 02 16:47:41 2002 +0000 @@ -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; - } - - interval = curtime.tv_sec + curtime.tv_usec*.000001 - priv->starttime; - - 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)); - } + } else { + interval = curtime.tv_sec + curtime.tv_usec*.000001 - priv->starttime; - // 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; + 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)); + } + + // 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",