# HG changeset patch # User reimar # Date 1376336255 0 # Node ID 95ea180551c08f5db3ac3c676ec12bc68ef54e50 # Parent 335349ca21371daf05f3c6363f83b04b714f5724 Fix possible hang bug with -ao pcm. When video stream reached EOF vo_pts would no longer be updated. This would lead to ao_pcm hanging since it would wait for the vo_pts to catch up with its position. diff -r 335349ca2137 -r 95ea180551c0 mplayer.c --- a/mplayer.c Mon Aug 12 19:37:33 2013 +0000 +++ b/mplayer.c Mon Aug 12 19:37:35 2013 +0000 @@ -2422,6 +2422,13 @@ return 0; } +static void advance_timer(double amount) +{ + mpctx->sh_video->timer += amount; + if (mpctx->sh_audio) + mpctx->delay -= amount; +} + static double update_video(int *blit_frame) { sh_video_t *const sh_video = mpctx->sh_video; @@ -2477,9 +2484,7 @@ return -1; if (full_frame) { - sh_video->timer += frame_time; - if (mpctx->sh_audio) - mpctx->delay -= frame_time; + advance_timer(frame_time); // video_read_frame can change fps (e.g. for ASF video) vo_fps = sh_video->fps; update_subtitles(sh_video, sh_video->pts, mpctx->d_sub, 0); @@ -2521,9 +2526,7 @@ if (!frame_time) frame_time = sh_video->frametime; sh_video->last_pts = sh_video->pts; - sh_video->timer += frame_time; - if (mpctx->sh_audio) - mpctx->delay -= frame_time; + advance_timer(frame_time); *blit_frame = res > 0; } return frame_time; @@ -3798,6 +3801,8 @@ if (frame_time < 0) { // if we have no more video, sleep some arbitrary time frame_time = 1.0 / 20.0; + // Ensure vo_pts is updated so that ao_pcm will not hang. + advance_timer(frame_time); // only stop playing when audio is at end as well if (!mpctx->sh_audio || mpctx->d_audio->eof) mpctx->eof = 1;