aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutputs
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2005-03-08 01:53:13 +0000
committerWarren Dukes <warren.dukes@gmail.com>2005-03-08 01:53:13 +0000
commitb5e55a648f12cea229f49c00730ef11a8583b66b (patch)
tree2ca0130ddee4b343c3aea396f0539136010ff185 /src/audioOutputs
parentfa08a7e3ff0d0f60415c29c080cc4130cf4032c9 (diff)
downloadmpd-b5e55a648f12cea229f49c00730ef11a8583b66b.tar.gz
mpd-b5e55a648f12cea229f49c00730ef11a8583b66b.tar.xz
mpd-b5e55a648f12cea229f49c00730ef11a8583b66b.zip
we ne allow audioOutput plugins to set the final outAudioFormat that will be used. we now use alsa's _near functions to detect what to use.
git-svn-id: https://svn.musicpd.org/mpd/trunk@3038 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/audioOutputs')
-rw-r--r--src/audioOutputs/audioOutput_alsa.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c
index 0cf453ffe..d804720b0 100644
--- a/src/audioOutputs/audioOutput_alsa.c
+++ b/src/audioOutputs/audioOutput_alsa.c
@@ -93,6 +93,7 @@ static int alsa_openDevice(AudioOutput * audioOutput)
snd_pcm_hw_params_t * hwparams;
snd_pcm_sw_params_t * swparams;
unsigned int sampleRate = audioFormat->sampleRate;
+ unsigned int channels = audioFormat->channels;
snd_pcm_uframes_t alsa_buffer_size;
snd_pcm_uframes_t alsa_period_size;
unsigned int alsa_buffer_time = MPD_ALSA_BUFFER_TIME;
@@ -107,10 +108,10 @@ static int alsa_openDevice(AudioOutput * audioOutput)
bitformat = SND_PCM_FORMAT_S16;
break;
case 24:
- bitformat = SND_PCM_FORMAT_S16;
+ bitformat = SND_PCM_FORMAT_S24;
break;
case 32:
- bitformat = SND_PCM_FORMAT_S16;
+ bitformat = SND_PCM_FORMAT_S32;
break;
default:
ERROR("Alsa device \"%s\" doesn't support %i bit audio\n",
@@ -162,14 +163,15 @@ static int alsa_openDevice(AudioOutput * audioOutput)
goto fail;
}
- err = snd_pcm_hw_params_set_channels(ad->pcmHandle, hwparams,
- audioFormat->channels);
+ err = snd_pcm_hw_params_set_channels_near(ad->pcmHandle, hwparams,
+ &channels);
if(err < 0) {
ERROR("Alsa device \"%s\" does not support %i channels: "
"%s\n", ad->device, (int)audioFormat->channels,
snd_strerror(-err));
goto fail;
}
+ audioFormat->channels = channels;
err = snd_pcm_hw_params_set_rate_near(ad->pcmHandle, hwparams,
&sampleRate, 0);
@@ -178,6 +180,7 @@ static int alsa_openDevice(AudioOutput * audioOutput)
ad->device, (int)audioFormat->sampleRate);
goto fail;
}
+ audioFormat->sampleRate = sampleRate;
err = snd_pcm_hw_params_set_buffer_time_near(ad->pcmHandle, hwparams,
&alsa_buffer_time, 0);
@@ -214,6 +217,9 @@ static int alsa_openDevice(AudioOutput * audioOutput)
audioOutput->open = 1;
+ DEBUG("alsa device \"%s\" will be playing %i channel audio at %i Hz\n",
+ ad->device, channels, sampleRate);
+
return 0;
error: