[MPlayer-cvslog] r36420 - trunk/mplayer.c

reimar subversion at mplayerhq.hu
Mon Aug 12 21:37:35 CEST 2013


Author: reimar
Date: Mon Aug 12 21:37:35 2013
New Revision: 36420

Log:
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.

Modified:
   trunk/mplayer.c

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	Mon Aug 12 21:37:33 2013	(r36419)
+++ trunk/mplayer.c	Mon Aug 12 21:37:35 2013	(r36420)
@@ -2422,6 +2422,13 @@ err_out:
     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 @@ static double update_video(int *blit_fra
                 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 @@ static double update_video(int *blit_fra
         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 @@ goto_enable_cache:
                     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;


More information about the MPlayer-cvslog mailing list