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
This commit is contained in:
parent
8feaf84b24
commit
4e5cffaa7b
16
src/audio.c
16
src/audio.c
@ -272,23 +272,27 @@ int isCurrentAudioFormat(AudioFormat * audioFormat)
|
|||||||
|
|
||||||
static void syncAudioDeviceStates(void)
|
static void syncAudioDeviceStates(void)
|
||||||
{
|
{
|
||||||
|
AudioOutput *audioOutput;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!audio_format.channels)
|
if (!audio_format.channels)
|
||||||
return;
|
return;
|
||||||
for (i = 0; i < audioOutputArraySize; ++i ) {
|
|
||||||
|
for (i = 0; i < audioOutputArraySize; ++i) {
|
||||||
|
audioOutput = &audioOutputArray[i];
|
||||||
switch (audioDeviceStates[i]) {
|
switch (audioDeviceStates[i]) {
|
||||||
case DEVICE_ON:
|
case DEVICE_ON:
|
||||||
/* This will reopen only if the audio format changed */
|
/* 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;
|
break;
|
||||||
case DEVICE_ENABLE:
|
case DEVICE_ENABLE:
|
||||||
openAudioOutput(&audioOutputArray[i], &audio_format);
|
if (openAudioOutput(audioOutput, &audio_format) == 0)
|
||||||
audioDeviceStates[i] = DEVICE_ON;
|
audioDeviceStates[i] = DEVICE_ON;
|
||||||
break;
|
break;
|
||||||
case DEVICE_DISABLE:
|
case DEVICE_DISABLE:
|
||||||
dropBufferedAudioOutput(&audioOutputArray[i]);
|
dropBufferedAudioOutput(audioOutput);
|
||||||
closeAudioOutput(&audioOutputArray[i]);
|
closeAudioOutput(audioOutput);
|
||||||
audioDeviceStates[i] = DEVICE_OFF;
|
audioDeviceStates[i] = DEVICE_OFF;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user