diff options
author | J. Alexander Treuman <jat@spatialrift.net> | 2007-06-09 21:40:56 +0000 |
---|---|---|
committer | J. Alexander Treuman <jat@spatialrift.net> | 2007-06-09 21:40:56 +0000 |
commit | 4e5cffaa7bed4cb11a30b7477da60055903e19f0 (patch) | |
tree | 694ac4fe9dec1b6bd2bdc950d902aa12f1e5ebd5 /src/audio.c | |
parent | 8feaf84b2439d8e9e321354939a5ec61da0a6ebc (diff) | |
download | mpd-4e5cffaa7bed4cb11a30b7477da60055903e19f0.tar.gz mpd-4e5cffaa7bed4cb11a30b7477da60055903e19f0.tar.xz mpd-4e5cffaa7bed4cb11a30b7477da60055903e19f0.zip |
If an audio output is in state DEVICE_ENABLE, and openAudioOutput fails,
leave it in that state. Likewise, if an audio output is in state
DEVICE_ON, and reopening the device due to a format change fails, change it
to state DEVICE_ENABLE. This will prevent flushAudioBuffer from even
attempting to play audio on a closed device (even though it would fail
anyway).
git-svn-id: https://svn.musicpd.org/mpd/trunk@6529 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/audio.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/audio.c b/src/audio.c index 027192793..366ec9c5e 100644 --- a/src/audio.c +++ b/src/audio.c @@ -272,23 +272,27 @@ int isCurrentAudioFormat(AudioFormat * audioFormat) static void syncAudioDeviceStates(void) { + AudioOutput *audioOutput; int i; if (!audio_format.channels) return; - for (i = 0; i < audioOutputArraySize; ++i ) { + + for (i = 0; i < audioOutputArraySize; ++i) { + audioOutput = &audioOutputArray[i]; switch (audioDeviceStates[i]) { case DEVICE_ON: /* This will reopen only if the audio format changed */ - openAudioOutput(&audioOutputArray[i], &audio_format); + if (openAudioOutput(audioOutput, &audio_format) < 0) + audioDeviceStates[i] = DEVICE_ENABLE; break; case DEVICE_ENABLE: - openAudioOutput(&audioOutputArray[i], &audio_format); - audioDeviceStates[i] = DEVICE_ON; + if (openAudioOutput(audioOutput, &audio_format) == 0) + audioDeviceStates[i] = DEVICE_ON; break; case DEVICE_DISABLE: - dropBufferedAudioOutput(&audioOutputArray[i]); - closeAudioOutput(&audioOutputArray[i]); + dropBufferedAudioOutput(audioOutput); + closeAudioOutput(audioOutput); audioDeviceStates[i] = DEVICE_OFF; break; } |