From ffed2fdca7b8757770fe01a7642a8d4e0c7fe3c8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 12 Oct 2008 12:02:55 +0200 Subject: 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. --- src/audioOutputs/audioOutput_alsa.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/audioOutputs') diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c index ab6e888b2..ebe40d04c 100644 --- a/src/audioOutputs/audioOutput_alsa.c +++ b/src/audioOutputs/audioOutput_alsa.c @@ -194,6 +194,17 @@ configure_hw: } 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) { ERROR("ALSA device \"%s\" does not support %u bit audio: " "%s\n", ad->device, audioFormat->bits, snd_strerror(-err)); -- cgit v1.2.3