aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-12 12:02:55 +0200
committerMax Kellermann <max@duempel.org>2008-10-12 12:02:55 +0200
commitffed2fdca7b8757770fe01a7642a8d4e0c7fe3c8 (patch)
tree19870163c0241668ed98ee259b0e48279b7be99f
parent9b0693d8ef564b16d1cff70588baf86a24d41d82 (diff)
downloadmpd-ffed2fdca7b8757770fe01a7642a8d4e0c7fe3c8.tar.gz
mpd-ffed2fdca7b8757770fe01a7642a8d4e0c7fe3c8.tar.xz
mpd-ffed2fdca7b8757770fe01a7642a8d4e0c7fe3c8.zip
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.
Diffstat (limited to '')
-rw-r--r--src/audioOutputs/audioOutput_alsa.c11
1 files changed, 11 insertions, 0 deletions
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));