Web lists-archives.com

[MPlayer-dev-eng] [PATCH] mplayer: fix buffer handling during channel change.




Without this change, when changing from, for example, stereo
to 5.1, there may be a little stereo data left in the output
buffer when the audio output is reinitialized with the new
format. If that little stereo data is not a multiple of 6 samples
it causes a shift in the mapping of the 5.1 channels.

With this patch, ensure that the output buffer is flushed before
performing the format change. It may cause a small A-V sync glitch
at the time, but it is better than completely wrong surround
arrangement.
---
 mplayer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mplayer.c b/mplayer.c
index 0068b84..34b7430 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -2187,7 +2187,7 @@ static int fill_audio_out_buffers(void)
         t  = GetTimer() - t;
         tt = t * 0.000001f;
         audio_time_usage += tt;
-        if (playsize > sh_audio->a_out_buffer_len) {
+        if (playsize >= sh_audio->a_out_buffer_len) {
             playsize = sh_audio->a_out_buffer_len;
             if (audio_eof || format_change)
                 playflags |= AOPLAY_FINAL_CHUNK;
@@ -2215,6 +2215,8 @@ static int fill_audio_out_buffers(void)
             mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_AudioOutputTruncated);
             sh_audio->a_out_buffer_len = 0;
         }
+        if (audio_eof || format_change)
+            bytes_to_write = sh_audio->a_out_buffer_len;
     }
     if (format_change) {
         uninit_player(INITIALIZED_AO);
-- 
2.1.4

_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng