History

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

Michael Niedermayer committed 16 years ago

Commit 68aefbe1 parent f5668141 file · +9 −10Browse files

Unified · Split

ffplay.c+9−10
@@ -168,7 +168,7 @@ typedef struct VideoState { · 167 unmodified lines
168 AVStream *video_st;168 AVStream *video_st;
169 PacketQueue videoq;169 PacketQueue videoq;
170 double video_current_pts; ///<current displayed pts (different from video_clock if frame fifos are used)170 double video_current_pts; ///<current displayed pts (different from video_clock if frame fifos are used)
171 int64_t video_current_pts_time; ///<time (av_gettime) at which we updated video_current_pts - used to have running video pts171 double video_current_pts_drift; ///<video_current_pts - time (av_gettime) at which we updated video_current_pts - used to have running video pts
172 VideoPicture pictq[VIDEO_PICTURE_QUEUE_SIZE];172 VideoPicture pictq[VIDEO_PICTURE_QUEUE_SIZE];
173 int pictq_size, pictq_rindex, pictq_windex;173 int pictq_size, pictq_rindex, pictq_windex;
174 SDL_mutex *pictq_mutex;174 SDL_mutex *pictq_mutex;
@@ -942,7 +942,7 @@ static double get_video_clock(VideoState *is) · 767 unmodified lines
942 if (is->paused) {942 if (is->paused) {
943 return is->video_current_pts;943 return is->video_current_pts;
944 } else {944 } else {
945 return is->video_current_pts + (av_gettime() - is->video_current_pts_time) / 1000000.0;945 return is->video_current_pts_drift + av_gettime() / 1000000.0;
946 }946 }
947}947}
948 948
@@ -990,15 +990,14 @@ static void stream_seek(VideoState *is, int64_t pos, int64_t rel, int seek_by_by · 41 unmodified lines
990/* pause or resume the video */990/* pause or resume the video */
991static void stream_pause(VideoState *is)991static void stream_pause(VideoState *is)
992{992{
993 is->paused = !is->paused;993 if (is->paused) {
994 if (!is->paused) {994 is->frame_timer += av_gettime() / 1000000.0 + is->video_current_pts_drift - is->video_current_pts;
995 if(is->read_pause_return != AVERROR(ENOSYS)){995 if(is->read_pause_return != AVERROR(ENOSYS)){
996 is->video_current_pts = get_video_clock(is);996 is->video_current_pts = is->video_current_pts_drift + av_gettime() / 1000000.0;
997 }997 }
998 998 is->video_current_pts_drift = is->video_current_pts - av_gettime() / 1000000.0;
999 is->frame_timer += (av_gettime() - is->video_current_pts_time) / 1000000.0;
1000 is->video_current_pts_time= av_gettime();
1001 }999 }
1000 is->paused = !is->paused;
1002}1001}
1003 1002
1004static double compute_frame_delay(double frame_current_pts, VideoState *is)1003static double compute_frame_delay(double frame_current_pts, VideoState *is)
@@ -1070,7 +1069,7 @@ static void video_refresh_timer(void *opaque) · 65 unmodified lines
1070 1069
1071 /* update current video pts */1070 /* update current video pts */
1072 is->video_current_pts = vp->pts;1071 is->video_current_pts = vp->pts;
1073 is->video_current_pts_time = av_gettime();1072 is->video_current_pts_drift = is->video_current_pts - av_gettime() / 1000000.0;
1074 1073
1075 /* launch timer for next picture */1074 /* launch timer for next picture */
1076 schedule_refresh(is, (int)(compute_frame_delay(vp->pts, is) * 1000 + 0.5));1075 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) · 718 unmodified lines
1795 1794
1796 is->frame_last_delay = 40e-3;1795 is->frame_last_delay = 40e-3;
1797 is->frame_timer = (double)av_gettime() / 1000000.0;1796 is->frame_timer = (double)av_gettime() / 1000000.0;
1798 is->video_current_pts_time = av_gettime();1797// is->video_current_pts_time = av_gettime();
1799 1798
1800 packet_queue_init(&is->videoq);1799 packet_queue_init(&is->videoq);
1801 is->video_tid = SDL_CreateThread(video_thread, is);1800 is->video_tid = SDL_CreateThread(video_thread, is);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t