changeset 16290:8a2585bc494f

ensure that audio-only files are decoded till the end by not only waiting for eof but also checking that the a_in_buffer is empty.
author reimar
date Tue, 23 Aug 2005 07:56:29 +0000
parents cafa391ff89c
children f443f849531b
files mplayer.c
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mplayer.c	Mon Aug 22 20:04:42 2005 +0000
+++ b/mplayer.c	Tue Aug 23 07:56:29 2005 +0000
@@ -2286,10 +2286,15 @@
   // Fill buffer if needed:
   current_module="decode_audio";   // Enter AUDIO decoder module
   t=GetTimer();
-  while(sh_audio->a_out_buffer_len<playsize && !d_audio->eof){
+  while(sh_audio->a_out_buffer_len<playsize &&
+        (!d_audio->eof || sh_audio->a_in_buffer_len > 0)){
     int ret=decode_audio(sh_audio,&sh_audio->a_out_buffer[sh_audio->a_out_buffer_len],
         playsize-sh_audio->a_out_buffer_len,sh_audio->a_out_buffer_size-sh_audio->a_out_buffer_len);
-    if(ret<=0) break; // EOF?
+    if(ret<=0) { // EOF?
+      if (d_audio->eof)
+        sh_audio->a_in_buffer_len = 0; // make sure we don't hang if something's broken
+      break;
+    }
     sh_audio->a_out_buffer_len+=ret;
   }
   t=GetTimer()-t;
@@ -2316,7 +2321,7 @@
     float a_pos = sh_audio->delay - audio_out->get_delay() * playback_speed;
     print_status(a_pos, 0, 0);
   }
-  if(d_audio->eof) eof = PT_NEXT_ENTRY;
+  if(d_audio->eof && sh_audio->a_in_buffer_len <= 0) eof = PT_NEXT_ENTRY;
 
 } else {