[alsa-devel] ALSA default buffer sizes (recent now being subscribed with correct address... hopefully)
Hi there,
I'm somewhat upset because audacious does not work with my AU8830. The problem is that audacious never calls any function that would give any clue about the desired buffer size. So my AU8830 ends up with 32 periods, 1 byte each. Great ! I'm not going to blame the author of that driver :P ... but:
The question is, who is the entity deciding those default values ? Other soundcards seem to get reasonable defaults, but the AU8830 does not. So I would like to fix that, but I want to do that at the right place.
Best Regards, and many thanks for any hint.
Manuel Jander wrote:
I'm somewhat upset because audacious does not work with my AU8830. The problem is that audacious never calls any function that would give any clue about the desired buffer size. So my AU8830 ends up with 32 periods, 1 byte each.
The question is, who is the entity deciding those default values ?
snd_pcm_hw_params_choose() in alsa-lib/src/pcm/pcm_params.c: /* Choose one configuration from configuration space defined by PARAMS The configuration chosen is that obtained fixing in this order: first access first format first subformat min channels min rate min period time max buffer size min tick time */
au88x0_pcm.c has period_bytes_min = 0x1 and periods_max = 32.
Is that periods_max an actual hardware limit?
Best regards, Clemens
Hi Clemens,
The question is, who is the entity deciding those default values ?
snd_pcm_hw_params_choose() in alsa-lib/src/pcm/pcm_params.c: /* Choose one configuration from configuration space defined by PARAMS The configuration chosen is that obtained fixing in this order: first access first format first subformat min channels min rate min period time max buffer size min tick time */
Thanks, that information is really helpful. But why would it be a good idea to pick to lowest period time ? Maybe a given soundcard is able to do 4 byte periods and all those low delay freaks will just start drooling because of that fact, but obviously with a high interrupt trigger rate, thus consuming more CPU. But OK, if you want low delay, you gotta pay for that. The fact that a soundcard is capable of doing that extreme low delay setting, does not necessarily mean that I want to favor that. Keep it mind that not every machine is a x86 with 3GHz.
Can anyone tell me why choosing the smallest period size by default is a good idea ? Maybe it would be good to know inside the driver that the user program does not actually care about the period time?
The problem is, as far as I understand right now, I would have to increase the minimum period time of the au88x0 driver, to get a reasonable setting for audacious, but that would limit the low delay capabilities for other applications that might do somewhat smarter buffer settings.
As a work around, maybe I could set the minimum period bytes to 0, and if I encounter that value at snd_pcm_xxx_hw_params(), override that value with something useable and reasonable ? For an mp3 player, period sizes below 576 audio samples would not make any sense either, so I would prefer 1024 frames rather than 1.
au88x0_pcm.c has period_bytes_min = 0x1 and periods_max = 32.
Is that periods_max an actual hardware limit?
No. I considered that anything beyond 32 is just plain stupid :) The case for period_bytes_min = 0x1 is only valid for 8 bits mono audio of course. I think that needs to be changed.
Best Regards, Manuel
At Mon, 24 Aug 2009 20:38:15 +0200, Manuel Jander wrote:
Hi Clemens,
The question is, who is the entity deciding those default values ?
snd_pcm_hw_params_choose() in alsa-lib/src/pcm/pcm_params.c: /* Choose one configuration from configuration space defined by PARAMS The configuration chosen is that obtained fixing in this order: first access first format first subformat min channels min rate min period time max buffer size min tick time */
Thanks, that information is really helpful. But why would it be a good idea to pick to lowest period time ?
Traditionally, the best way to avoid buffer underrun is to use the smallest period size and the largest buffer size. That is, wake up as much as possible while allowing to sleep as much as possible.
Maybe a given soundcard is able to do 4 byte periods and all those low delay freaks will just start drooling because of that fact, but obviously with a high interrupt trigger rate, thus consuming more CPU. But OK, if you want low delay, you gotta pay for that.
But 4 byte periods are still unrealistic. No Linux machine could work in practice use.
Takashi
Manuel Jander wrote:
Can anyone tell me why choosing the smallest period size by default is a good idea ?
Because there a sound cards where there is no more precise information about the current position than the period interrupt, so using smaller periods gives better position information.
Using larger periods is useful only if you really want to save power.
Most PCI drivers have a minimum period size of 32 bytes (related to the PCI burst size) and do not limit the number of periods, so this algorithm tends to work just fine.
Maybe it would be good to know inside the driver that the user program does not actually care about the period time?
When the program actually does not care, then it does not matter what value gets used, so the minimum period time is correct by definition.
The problem is, as far as I understand right now, I would have to increase the minimum period time of the au88x0 driver,
Just increase the maximum number of periods.
Increasing period_bytes_min to 32 or so wouldn't hurt either.
As a work around, maybe I could set the minimum period bytes to 0, and if I encounter that value at snd_pcm_xxx_hw_params(), override that value with something useable and reasonable ?
You cannot use values that the ALSA framework does not know about.
au88x0_pcm.c has period_bytes_min = 0x1 and periods_max = 32.
Is that periods_max an actual hardware limit?
No. I considered that anything beyond 32 is just plain stupid :)
Those fields are intended to enforce hardware limits.
Besides, using the sound card period interrupt as a 48 kHz timer is a perfectly valid application. (Well, as a stress test. :-)
Best regards, Clemens
participants (3)
-
Clemens Ladisch
-
Manuel Jander
-
Takashi Iwai