diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-09-08 20:42:51 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-08 20:42:51 +0200 |
commit | 7d0c32b45089376f55a56f98472193a4802cba64 (patch) | |
tree | 2193a26aae81b8d20f075ac705cbb57592a82472 /src/audioOutputs/audioOutput_alsa.c | |
parent | 67c642c93501e206950f2e79a64fb334f1cb8ea3 (diff) | |
download | mpd-7d0c32b45089376f55a56f98472193a4802cba64.tar.gz mpd-7d0c32b45089376f55a56f98472193a4802cba64.tar.xz mpd-7d0c32b45089376f55a56f98472193a4802cba64.zip |
alsa: move bitformat reading code out of the way
Diffstat (limited to 'src/audioOutputs/audioOutput_alsa.c')
-rw-r--r-- | src/audioOutputs/audioOutput_alsa.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c index 759ef5db4..ccde87691 100644 --- a/src/audioOutputs/audioOutput_alsa.c +++ b/src/audioOutputs/audioOutput_alsa.c @@ -119,6 +119,17 @@ static int alsa_testDefault(void) return 0; } +static snd_pcm_format_t get_bitformat(const struct audio_format *af) +{ + switch (af->bits) { + case 8: return SND_PCM_FORMAT_S8; + case 16: return SND_PCM_FORMAT_S16; + case 24: return SND_PCM_FORMAT_S24; + case 32: return SND_PCM_FORMAT_S32; + } + return SND_PCM_FORMAT_UNKNOWN; +} + static int alsa_openDevice(struct audio_output *audioOutput) { AlsaData *ad = audioOutput->data; @@ -136,24 +147,9 @@ static int alsa_openDevice(struct audio_output *audioOutput) unsigned int period_time, period_time_ro; unsigned int buffer_time; - switch (audioFormat->bits) { - case 8: - bitformat = SND_PCM_FORMAT_S8; - break; - case 16: - bitformat = SND_PCM_FORMAT_S16; - break; - case 24: - bitformat = SND_PCM_FORMAT_S24; - break; - case 32: - bitformat = SND_PCM_FORMAT_S32; - break; - default: + if ((bitformat = get_bitformat(audioFormat)) == SND_PCM_FORMAT_UNKNOWN) ERROR("ALSA device \"%s\" doesn't support %i bit audio\n", ad->device, audioFormat->bits); - return -1; - } err = snd_pcm_open(&ad->pcmHandle, ad->device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); |