changeset 15556:7575f4b17b48

patch by oded to fix edl hang when end of audio is reached
author rfelker
date Tue, 24 May 2005 02:41:48 +0000
parents 806cd20f1c8f
children 40d5e0ccce93
files mencoder.c
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mencoder.c	Mon May 23 21:24:47 2005 +0000
+++ b/mencoder.c	Tue May 24 02:41:48 2005 +0000
@@ -1612,15 +1612,16 @@
         if (sh_audio) {
             a_pts = d_audio->pts + (ds_tell_pts(d_audio) - sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
             while (sh_video->pts > a_pts) {
+                int len;
                 if (mux_a->h.dwSampleSize) {
-                    int len;
                     len = mux_a->wf->nAvgBytesPerSec * (sh_video->pts - a_pts);
                     len/= mux_a->h.dwSampleSize; if(len<1) len=1;
                     len*= mux_a->h.dwSampleSize;
-                    demux_read_data(sh_audio->ds,mux_a->buffer,len);
+                    len = demux_read_data(sh_audio->ds,mux_a->buffer,len);
                 } else {
-                    ds_get_packet(sh_audio->ds,(unsigned char**) &mux_a->buffer);
+                    len = ds_get_packet(sh_audio->ds,(unsigned char**) &mux_a->buffer);
                 }
+                if (len <= 0) break; // EOF of audio.
                 a_pts = d_audio->pts + (ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
             }
         }