aboutsummaryrefslogtreecommitdiffstats
path: root/ffplay.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2010-02-01 10:55:51 +0000
committerMichael Niedermayer <michaelni@gmx.at>2010-02-01 10:55:51 +0000
commit68aefbe81cb3b9dd002108782bb8d798e1c12806 (patch)
tree73bda3da9ae9fbaf38f2f4f140fe047cf8f23000 /ffplay.c
parentf5668147cb39a67f8c3f97df5993aaf7653c0f62 (diff)
downloadffmpeg-68aefbe81cb3b9dd002108782bb8d798e1c12806.tar.gz
Fix race condition with reading between video_current_pts and video_current_pts_time.
Originally committed as revision 21585 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffplay.c')
-rw-r--r--ffplay.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/ffplay.c b/ffplay.c
index 9fc8f383fe..496e7a4bf9 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -168,7 +168,7 @@ typedef struct VideoState {
AVStream *video_st;
PacketQueue videoq;
double video_current_pts; ///<current displayed pts (different from video_clock if frame fifos are used)
- int64_t video_current_pts_time; ///<time (av_gettime) at which we updated video_current_pts - used to have running video pts
+ double video_current_pts_drift; ///<video_current_pts - time (av_gettime) at which we updated video_current_pts - used to have running video pts
VideoPicture pictq[VIDEO_PICTURE_QUEUE_SIZE];
int pictq_size, pictq_rindex, pictq_windex;
SDL_mutex *pictq_mutex;
@@ -942,7 +942,7 @@ static double get_video_clock(VideoState *is)
if (is->paused) {
return is->video_current_pts;
} else {
- return is->video_current_pts + (av_gettime() - is->video_current_pts_time) / 1000000.0;
+ return is->video_current_pts_drift + av_gettime() / 1000000.0;
}
}
@@ -990,15 +990,14 @@ static void stream_seek(VideoState *is, int64_t pos, int64_t rel, int seek_by_by
/* pause or resume the video */
static void stream_pause(VideoState *is)
{
- is->paused = !is->paused;
- if (!is->paused) {
+ if (is->paused) {
+ is->frame_timer += av_gettime() / 1000000.0 + is->video_current_pts_drift - is->video_current_pts;
if(is->read_pause_return != AVERROR(ENOSYS)){
- is->video_current_pts = get_video_clock(is);
+ is->video_current_pts = is->video_current_pts_drift + av_gettime() / 1000000.0;
}
-
- is->frame_timer += (av_gettime() - is->video_current_pts_time) / 1000000.0;
- is->video_current_pts_time= av_gettime();
+ is->video_current_pts_drift = is->video_current_pts - av_gettime() / 1000000.0;
}
+ is->paused = !is->paused;
}
static double compute_frame_delay(double frame_current_pts, VideoState *is)
@@ -1070,7 +1069,7 @@ static void video_refresh_timer(void *opaque)
/* update current video pts */
is->video_current_pts = vp->pts;
- is->video_current_pts_time = av_gettime();
+ is->video_current_pts_drift = is->video_current_pts - av_gettime() / 1000000.0;
/* launch timer for next picture */
schedule_refresh(is, (int)(compute_frame_delay(vp->pts, is) * 1000 + 0.5));
@@ -1795,7 +1794,7 @@ static int stream_component_open(VideoState *is, int stream_index)
is->frame_last_delay = 40e-3;
is->frame_timer = (double)av_gettime() / 1000000.0;
- is->video_current_pts_time = av_gettime();
+// is->video_current_pts_time = av_gettime();
packet_queue_init(&is->videoq);
is->video_tid = SDL_CreateThread(video_thread, is);