[MPlayer-dev-eng] [PATCH] short, low bitrate audio file playback

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Mon Aug 22 14:00:04 CEST 2005


Hi,
the attached patch helps playing short audio file to the end by not only
waiting for the stream eof but also until the audio buffer is empty.
Is it okay to apply?

Greetings,
Reimar Döffinger

P.S. I'm quite sure there is a bugzilla entry for this, but I just can't
find it. Can anyone help me out?
-------------- next part --------------
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.860
diff -u -r1.860 mplayer.c
--- mplayer.c	15 Aug 2005 08:30:42 -0000	1.860
+++ mplayer.c	22 Aug 2005 11:42:54 -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 {
 


More information about the MPlayer-dev-eng mailing list