aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutputs
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-09-07 22:01:47 -0700
committerEric Wong <normalperson@yhbt.net>2008-09-07 22:25:01 -0700
commit544efdf5aaaf4b77f44f250b4dbfdd3ed0c87a4c (patch)
tree8457d4ce6f3572ad1e55d942fed09173351042e7 /src/audioOutputs
parent3370945c13ac29700dab2dc94aac850992573b80 (diff)
downloadmpd-544efdf5aaaf4b77f44f250b4dbfdd3ed0c87a4c.tar.gz
mpd-544efdf5aaaf4b77f44f250b4dbfdd3ed0c87a4c.tar.xz
mpd-544efdf5aaaf4b77f44f250b4dbfdd3ed0c87a4c.zip
alsa: move bitformat reading code out of the way
Diffstat (limited to '')
-rw-r--r--src/audioOutputs/audioOutput_alsa.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c
index 62f34e854..ef4ae54ff 100644
--- a/src/audioOutputs/audioOutput_alsa.c
+++ b/src/audioOutputs/audioOutput_alsa.c
@@ -134,6 +134,17 @@ static int alsa_testDefault(void)
return 0;
}
+static snd_pcm_format_t get_bitformat(const AudioFormat * 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(AudioOutput * audioOutput)
{
AlsaData *ad = audioOutput->data;
@@ -151,24 +162,9 @@ static int alsa_openDevice(AudioOutput * 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 = E(snd_pcm_open, &ad->pcmHandle, ad->device,
SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK);