aboutsummaryrefslogtreecommitdiffstats
path: root/src/audioOutputs/audioOutput_alsa.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2006-08-12 18:20:55 +0000
committerEric Wong <normalperson@yhbt.net>2006-08-12 18:20:55 +0000
commit0511e14db09698c9665a2c8fe299235f1242d9ea (patch)
tree27d880bc5a5776318a0715561ccd67917a51c52d /src/audioOutputs/audioOutput_alsa.c
parentb5361f7789e560701b333bf27a2768c0a58c7576 (diff)
downloadmpd-0511e14db09698c9665a2c8fe299235f1242d9ea.tar.gz
mpd-0511e14db09698c9665a2c8fe299235f1242d9ea.tar.xz
mpd-0511e14db09698c9665a2c8fe299235f1242d9ea.zip
audioOutput_alsa.c: avoid changing our internal period and buffer time values
Passing a ref to snd_pcm_hw_params_set_{buffer,period}_time_near can modify our internal {period,buffer}_time members inside the AlsaData structure, making re-initializing the device across sample/bit rate and channel changes non-idempotent. git-svn-id: https://svn.musicpd.org/mpd/trunk@4616 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/audioOutputs/audioOutput_alsa.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c
index c129e2d6e..9aefb4be8 100644
--- a/src/audioOutputs/audioOutput_alsa.c
+++ b/src/audioOutputs/audioOutput_alsa.c
@@ -140,8 +140,9 @@ static int alsa_openDevice(AudioOutput * audioOutput)
snd_pcm_uframes_t alsa_period_size;
int err;
const char *cmd = NULL;
- unsigned int period_time;
int retry = MPD_ALSA_RETRY_NR;
+ unsigned int period_time, period_time_ro;
+ unsigned int buffer_time;
switch (audioFormat->bits) {
case 8:
@@ -175,6 +176,7 @@ static int alsa_openDevice(AudioOutput * audioOutput)
if (err < 0)
goto error;
+ period_time_ro = period_time = ad->period_time;
configure_hw:
/* configure HW params */
snd_pcm_hw_params_alloca(&hwparams);
@@ -231,28 +233,29 @@ configure_hw:
}
audioFormat->sampleRate = sampleRate;
+ buffer_time = ad->buffer_time;
cmd = "snd_pcm_hw_params_set_buffer_time_near";
err = snd_pcm_hw_params_set_buffer_time_near(ad->pcmHandle, hwparams,
- &ad->buffer_time, NULL);
+ &buffer_time, NULL);
if (err < 0)
goto error;
- period_time = ad->period_time;
+ period_time = period_time_ro;
cmd = "snd_pcm_hw_params_set_period_time_near";
err = snd_pcm_hw_params_set_period_time_near(ad->pcmHandle, hwparams,
- &ad->period_time, NULL);
+ &period_time, NULL);
if (err < 0)
goto error;
cmd = "snd_pcm_hw_params";
err = snd_pcm_hw_params(ad->pcmHandle, hwparams);
if (err == -EPIPE && --retry > 0) {
- ad->period_time = period_time >> 1;
+ period_time_ro = period_time_ro >> 1;
goto configure_hw;
} else if (err < 0)
goto error;
if (retry != MPD_ALSA_RETRY_NR)
- DEBUG("ALSA period_time set to %d\n", ad->period_time);
+ DEBUG("ALSA period_time set to %d\n", period_time);
cmd = "snd_pcm_hw_params_get_buffer_size";
err = snd_pcm_hw_params_get_buffer_size(hwparams, &alsa_buffer_size);