[alsa-devel] snd_pcm_set_params() bug?

Christian Morales Vega cmorve69 at yahoo.es
Mon Jun 2 18:30:54 CEST 2008

This code:

#include <alsa/asoundlib.h>

int main(){
    snd_pcm_t *handle;
    if(snd_pcm_open(&handle, "default:1", SND_PCM_STREAM_PLAYBACK, 0) < 0) {

    if(snd_pcm_set_params(handle, SND_PCM_FORMAT_S16_LE,
       2, 24000, 1, 100000) < 0) {

fails with error "ALSA lib pcm.c:7193:(snd_pcm_set_params) Unable to
get period size for PLAYBACK: Invalid argument"
Disable resampling and you get "ALSA lib
pcm.c:7142:(snd_pcm_set_params) Rate doesn't match (requested 24000Hz,
get 0Hz)" (normal, I suppose). With other samplerates works fine.

I'm using alsa-driver-kmp-default- and
alsa-1.0.16.hg20080510 RPM packages from multimedia:audio openSUSE
Build Service repository (from Takashi Iwai) and an AD1988 (hda-intel)
codec. A XUbuntu user also has the same problem with an hda-intel
codec (that I suppose uses stable 1.0.16).
With a SB Live! in the same computer there are no problems.

This was discovered with bsnes ( http://byuu.cinnamonpirate.com/bsnes/
- http://board.zsnes.com/phpBB2/viewtopic.php?t=11584 ) that can use
openal, libao or alsa directly. The problem just happens when using
24KHz with alsa. So I suppose the problem is in the
snd_pcm_set_params() itself, since openal and libao have not the
problem but they set parameters "manually", not with

More information about the Alsa-devel mailing list