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
168168 AVStream *video_st;
169169 PacketQueue videoq;
170170 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 pts
171+ double video_current_pts_drift; ///<video_current_pts - time (av_gettime) at which we updated video_current_pts - used to have running video pts
172172 VideoPicture pictq[VIDEO_PICTURE_QUEUE_SIZE];
173173 int pictq_size, pictq_rindex, pictq_windex;
174174 SDL_mutex *pictq_mutex;
@@ -942,7 +942,7 @@ static double get_video_clock(VideoState *is) · 767 unmodified lines
942942 if (is->paused) {
943943 return is->video_current_pts;
944944 } 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;
946946 }
947947 }
948948
@@ -990,15 +990,14 @@ static void stream_seek(VideoState *is, int64_t pos, int64_t rel, int seek_by_by · 41 unmodified lines
990990 /* pause or resume the video */
991991 static void stream_pause(VideoState *is)
992992 {
993− is->paused = !is->paused;
994− if (!is->paused) {
993+ if (is->paused) {
994+ is->frame_timer += av_gettime() / 1000000.0 + is->video_current_pts_drift - is->video_current_pts;
995995 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;
997997 }
998−
999− is->frame_timer += (av_gettime() - is->video_current_pts_time) / 1000000.0;
1000− is->video_current_pts_time= av_gettime();
998+ is->video_current_pts_drift = is->video_current_pts - av_gettime() / 1000000.0;
1001999 }
1000+ is->paused = !is->paused;
10021001 }
10031002
10041003 static double compute_frame_delay(double frame_current_pts, VideoState *is)
@@ -1070,7 +1069,7 @@ static void video_refresh_timer(void *opaque) · 65 unmodified lines
10701069
10711070 /* update current video pts */
10721071 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;
10741073
10751074 /* launch timer for next picture */
10761075 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
17951794
17961795 is->frame_last_delay = 40e-3;
17971796 is->frame_timer = (double)av_gettime() / 1000000.0;
1798− is->video_current_pts_time = av_gettime();
1797+// is->video_current_pts_time = av_gettime();
17991798
18001799 packet_queue_init(&is->videoq);
18011800 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