At Sat, 24 Jan 2009 11:53:14 +0100, Cristian Morales Vega wrote:
2008/6/2 Christian Morales Vega cmorve69@yahoo.es:
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) { exit(1); }
if(snd_pcm_set_params(handle, SND_PCM_FORMAT_S16_LE, SND_PCM_ACCESS_RW_INTERLEAVED, 2, 24000, 1, 100000) < 0) { exit(2); } }
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-1.0.16.20080602 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 snd_pcm_set_params().
The problem persists with alsa-1.0.19.git20090122-1.1 and alsa-driver-kmp-default-1.0.19.20090124_2.6.27.7_9.1-1.1 from openSUSE 11.1 multimedia:audio(:kmp) Build Service repository.
Note that the problem only happens with snd_pcm_set_params(). Using snd_pcm_hw_params_set_* functions works fine (and I really get 24KHz): http://board.zsnes.com/phpBB2/viewtopic.php?p=170478#170478
Hm, snd_pcm_set_params() is basically nothing but the command sequences of snd_pcm_hw_params_*(). So, some call of them is broken...
Takashi