diff options
author | henry <henry@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-09-11 21:05:16 +0000 |
---|---|---|
committer | henry <henry@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-09-11 21:05:16 +0000 |
commit | d35a921a559f2c1a802bfa0019c6d5db45402161 (patch) | |
tree | e9f96441e1614e6e72f289a253bdb87c94a45be4 /libmpdemux | |
parent | dd02976caa33df39116f64bd1f7ebce7df813163 (diff) | |
download | mpv-d35a921a559f2c1a802bfa0019c6d5db45402161.tar.bz2 mpv-d35a921a559f2c1a802bfa0019c6d5db45402161.tar.xz |
yet another sync fix
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10852 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/tvi_v4l2.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libmpdemux/tvi_v4l2.c b/libmpdemux/tvi_v4l2.c index 4e85a86c64..9ba219f540 100644 --- a/libmpdemux/tvi_v4l2.c +++ b/libmpdemux/tvi_v4l2.c @@ -77,7 +77,7 @@ typedef struct { 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 @@ static void *video_grabber(void *data) /* 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 @@ static void *audio_grabber(void *data) 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); |