aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutputs
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2005-03-13 16:42:04 +0000
committerWarren Dukes <warren.dukes@gmail.com>2005-03-13 16:42:04 +0000
commit3d81a723c7b501f9b2333fd73ee012645547d01e (patch)
treee9921dbd7f21bf79d8627e32c1e66d60574514fe /src/audioOutputs
parent5ba5832f5ac55f2e41ec1664d67462486eb62d73 (diff)
downloadmpd-3d81a723c7b501f9b2333fd73ee012645547d01e.tar.gz
mpd-3d81a723c7b501f9b2333fd73ee012645547d01e.tar.xz
mpd-3d81a723c7b501f9b2333fd73ee012645547d01e.zip
slight changes to alsa errors
git-svn-id: https://svn.musicpd.org/mpd/trunk@3072 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/audioOutputs/audioOutput_alsa.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c
index 9cc15c842..021c5af48 100644
--- a/src/audioOutputs/audioOutput_alsa.c
+++ b/src/audioOutputs/audioOutput_alsa.c
@@ -119,6 +119,7 @@ static int alsa_openDevice(AudioOutput * audioOutput)
unsigned int alsa_buffer_time = MPD_ALSA_BUFFER_TIME;
unsigned int alsa_period_time = MPD_ALSA_PERIOD_TIME;
int err;
+ char * cmd = NULL;
switch(audioFormat->bits) {
case 8:
@@ -146,12 +147,14 @@ static int alsa_openDevice(AudioOutput * audioOutput)
goto error;
}
+ cmd = "snd_pcm_nonblock";
err = snd_pcm_nonblock(ad->pcmHandle, 0);
if(err < 0) goto error;
/* configure HW params */
snd_pcm_hw_params_alloca(&hwparams);
+ cmd = "snd_pcm_hw_params_any";
err = snd_pcm_hw_params_any(ad->pcmHandle, hwparams);
if(err < 0) goto error;
@@ -169,6 +172,7 @@ static int alsa_openDevice(AudioOutput * audioOutput)
}
if(!ad->useMmap) {
+ cmd = "snd_pcm_hw_params_set_access";
err = snd_pcm_hw_params_set_access(ad->pcmHandle, hwparams,
SND_PCM_ACCESS_RW_INTERLEAVED);
if(err < 0) goto error;
@@ -202,20 +206,25 @@ static int alsa_openDevice(AudioOutput * audioOutput)
}
audioFormat->sampleRate = sampleRate;
+ cmd = "snd_pcm_hw_params_set_buffer_time_near";
err = snd_pcm_hw_params_set_buffer_time_near(ad->pcmHandle, hwparams,
&alsa_buffer_time, 0);
if(err < 0) goto error;
+ cmd = "snd_pcm_hw_params_set_period_time_near";
err = snd_pcm_hw_params_set_period_time_near(ad->pcmHandle, hwparams,
&alsa_period_time, 0);
if(err < 0) goto error;
+ cmd = "snd_pcm_hw_params";
err = snd_pcm_hw_params(ad->pcmHandle, hwparams);
if(err < 0) goto error;
+ cmd = "snd_pcm_hw_params_get_buffer_size";
err = snd_pcm_hw_params_get_buffer_size(hwparams, &alsa_buffer_size);
if(err < 0) goto error;
+ cmd = "snd_pcm_hw_params_get_period_size";
err = snd_pcm_hw_params_get_period_size(hwparams, &alsa_period_size, 0);
if(err < 0) goto error;
@@ -224,12 +233,26 @@ static int alsa_openDevice(AudioOutput * audioOutput)
/* configure SW params */
snd_pcm_sw_params_alloca(&swparams);
- snd_pcm_sw_params_current(ad->pcmHandle, swparams);
+ cmd = "snd_pcm_sw_params_current";
+ err = snd_pcm_sw_params_current(ad->pcmHandle, swparams);
+ if(err < 0) goto error;
+
+ cmd = "snd_pcm_sw_params_set_start_threshold";
err = snd_pcm_sw_params_set_start_threshold(ad->pcmHandle, swparams,
alsa_buffer_size - alsa_period_size);
if(err < 0) goto error;
+ cmd = "snd_pcm_sw_params_set_avail_min";
+ err = snd_pcm_sw_params_set_avail_min(ad->pcmHandle, swparams,
+ alsa_period_size);
+ if(err < 0) goto error;
+
+ cmd = "snd_pcm_sw_params_set_xfer_align";
+ err = snd_pcm_sw_params_set_xfer_align(ad->pcmHandle, swparams, 1);
+ if(err < 0) goto error;
+
+ cmd = "snd_pcm_sw_params";
err = snd_pcm_sw_params(ad->pcmHandle, swparams);
if(err < 0) goto error;
@@ -243,8 +266,14 @@ static int alsa_openDevice(AudioOutput * audioOutput)
return 0;
error:
- ERROR("Error opening alsa device \"%s\": %s\n", ad->device,
- snd_strerror(-err));
+ if(cmd) {
+ ERROR("Error opening alsa device \"%s\" (%s): %s\n",
+ ad->device, cmd, snd_strerror(-err));
+ }
+ else {
+ ERROR("Error opening alsa device \"%s\": %s\n", ad->device,
+ snd_strerror(-err));
+ }
fail:
if(ad->pcmHandle) snd_pcm_close(ad->pcmHandle);
ad->pcmHandle = NULL;