alsa: fall back to 16 bit output
If the sample format isn't supported by the device (i.e. 24 bit on low-end sound chips), fall back to 16 bit output. There is code in pcm_utils.c which converts PCM data to 16 bit.
This commit is contained in:
parent
9b0693d8ef
commit
ffed2fdca7
@ -194,6 +194,17 @@ configure_hw:
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = snd_pcm_hw_params_set_format(ad->pcmHandle, hwparams, bitformat);
|
err = snd_pcm_hw_params_set_format(ad->pcmHandle, hwparams, bitformat);
|
||||||
|
if (err == -EINVAL && audioFormat->bits != 16) {
|
||||||
|
/* fall back to 16 bit, let pcm_utils.c do the conversion */
|
||||||
|
err = snd_pcm_hw_params_set_format(ad->pcmHandle, hwparams,
|
||||||
|
SND_PCM_FORMAT_S16);
|
||||||
|
if (err == 0) {
|
||||||
|
DEBUG("ALSA device \"%s\": converting %u bit to 16 bit\n",
|
||||||
|
ad->device, audioFormat->bits);
|
||||||
|
audioFormat->bits = 16;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
ERROR("ALSA device \"%s\" does not support %u bit audio: "
|
ERROR("ALSA device \"%s\" does not support %u bit audio: "
|
||||||
"%s\n", ad->device, audioFormat->bits, snd_strerror(-err));
|
"%s\n", ad->device, audioFormat->bits, snd_strerror(-err));
|
||||||
|
Loading…
Reference in New Issue
Block a user