[MPlayer-dev-eng] [PATCH] alsa: use buffer_time_min instead of buffer_time_near

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Sep 29 10:24:26 CEST 2009


Hello,
using buffer_time_near allows ALSA to (in theory) create ridiculously
small buffers which MPlayer can not handle at all, which _might_ be the
cause for some of the recent ALSA issues.
For my drivers I am lucky, the issue only starts appearing when setting
alsa_buffer_time to something silly like 10000, but this patch still
"fixes" it then.
However I think that r29549 added another bug:
snd_pcm_hw_params_set_buffer_time_near can modify the alsa_buffer_time,
so when playing multiple files, the second one will try to set the
buffer time to near the return value of the last call instead of the
intended default value, possibly causing it to converge towards 0.
Take this as another real-world proof why it is really stupid to mix
cosmetic with functional changes.

Index: libao2/ao_alsa.c
===================================================================
--- libao2/ao_alsa.c    (revision 29731)
+++ libao2/ao_alsa.c    (working copy)
@@ -571,7 +571,7 @@
       bytes_per_sample *= ao_data.channels;
       ao_data.bps = ao_data.samplerate * bytes_per_sample;
 
-       if ((err = snd_pcm_hw_params_set_buffer_time_near(alsa_handler, alsa_hwparams,
+       if ((err = snd_pcm_hw_params_set_buffer_time_min(alsa_handler, alsa_hwparams,
                                                          &alsa_buffer_time, NULL)) < 0)
          {
            mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetBufferTimeNear,




More information about the MPlayer-dev-eng mailing list