comparison src/alsa-ng/alsa-core.c @ 3197:d2e01ca06335

alsa-ng: Work around *broken* drivers, such as snd-au88xx.
author William Pitcock <nenolod@atheme.org>
date Mon, 13 Jul 2009 15:37:47 -0500
parents 0f7180e3b163
children 83b1a4e5f453
comparison
equal deleted inserted replaced
3196:0f7180e3b163 3197:d2e01ca06335
306 alsaplug_open_audio(AFormat fmt, gint rate, gint nch) 306 alsaplug_open_audio(AFormat fmt, gint rate, gint nch)
307 { 307 {
308 gint err, bitwidth, ringbuf_size, buf_size; 308 gint err, bitwidth, ringbuf_size, buf_size;
309 snd_pcm_format_t afmt; 309 snd_pcm_format_t afmt;
310 snd_pcm_hw_params_t *hwparams = NULL; 310 snd_pcm_hw_params_t *hwparams = NULL;
311 guint rate_ = rate;
311 312
312 afmt = alsaplug_format_convert(fmt); 313 afmt = alsaplug_format_convert(fmt);
313 if (afmt == SND_PCM_FORMAT_UNKNOWN) 314 if (afmt == SND_PCM_FORMAT_UNKNOWN)
314 { 315 {
315 _ERROR("unsupported format requested: %d -> %d", fmt, afmt); 316 _ERROR("unsupported format requested: %d -> %d", fmt, afmt);
329 snd_pcm_hw_params_alloca(&hwparams); 330 snd_pcm_hw_params_alloca(&hwparams);
330 snd_pcm_hw_params_any(pcm_handle, hwparams); 331 snd_pcm_hw_params_any(pcm_handle, hwparams);
331 snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED); 332 snd_pcm_hw_params_set_access(pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED);
332 snd_pcm_hw_params_set_format(pcm_handle, hwparams, afmt); 333 snd_pcm_hw_params_set_format(pcm_handle, hwparams, afmt);
333 snd_pcm_hw_params_set_channels(pcm_handle, hwparams, nch); 334 snd_pcm_hw_params_set_channels(pcm_handle, hwparams, nch);
334 snd_pcm_hw_params_set_rate(pcm_handle, hwparams, rate, 0); 335 snd_pcm_hw_params_set_rate_resample(pcm_handle, hwparams, 1);
336
337 snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &rate_, 0);
338 if (rate_ != rate)
339 {
340 _ERROR("sample rate %d is not supported (got %d)", rate, rate_);
341 return -1;
342 }
335 343
336 err = snd_pcm_hw_params(pcm_handle, hwparams); 344 err = snd_pcm_hw_params(pcm_handle, hwparams);
337 if (err < 0) 345 if (err < 0)
338 { 346 {
339 _ERROR("snd_pcm_hw_params failed: %s", snd_strerror(err)); 347 _ERROR("snd_pcm_hw_params failed: %s", snd_strerror(err));