fix the segfault for when no audio_output is found and none is detected (bug found by normalperson!!!)
git-svn-id: https://svn.musicpd.org/mpd/trunk@4868 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
347a33b009
commit
d3040d1eb5
28
src/audio.c
28
src/audio.c
@ -121,29 +121,37 @@ void initAudioDriver(void)
|
|||||||
audioDeviceStates = (getPlayerData())->audioDeviceStates;
|
audioDeviceStates = (getPlayerData())->audioDeviceStates;
|
||||||
audioOutputArray = xmalloc(sizeof(AudioOutput) * audioOutputArraySize);
|
audioOutputArray = xmalloc(sizeof(AudioOutput) * audioOutputArraySize);
|
||||||
|
|
||||||
i = 0;
|
for (i = 0; i < audioOutputArraySize; i++)
|
||||||
param = getNextConfigParam(CONF_AUDIO_OUTPUT, param);
|
{
|
||||||
|
|
||||||
do {
|
|
||||||
AudioOutput *output = &audioOutputArray[i];
|
AudioOutput *output = &audioOutputArray[i];
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
if (!initAudioOutput(output, param) && param) {
|
param = getNextConfigParam(CONF_AUDIO_OUTPUT, param);
|
||||||
ERROR("problems configuring output device defined at "
|
|
||||||
"line %i\n", param->line);
|
if (!initAudioOutput(output, param)) {
|
||||||
|
if (param)
|
||||||
|
{
|
||||||
|
ERROR("problems configuring output device "
|
||||||
|
"defined at line %i\n", param->line);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ERROR("No audio_output specified and unable to "
|
||||||
|
"detect a default audio output device\n");
|
||||||
|
}
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* require output names to be unique: */
|
/* require output names to be unique: */
|
||||||
for (j = i; --j >= 0; ) {
|
for (j = 0; j < i; j++) {
|
||||||
if (!strcmp(output->name, audioOutputArray[j].name)) {
|
if (!strcmp(output->name, audioOutputArray[j].name)) {
|
||||||
ERROR("output devices with identical "
|
ERROR("output devices with identical "
|
||||||
"names: %s\n", output->name);
|
"names: %s\n", output->name);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
audioDeviceStates[i++] = DEVICE_ENABLE;
|
audioDeviceStates[i] = DEVICE_ENABLE;
|
||||||
} while ((param = getNextConfigParam(CONF_AUDIO_OUTPUT, param)));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void getOutputAudioFormat(AudioFormat * inAudioFormat,
|
void getOutputAudioFormat(AudioFormat * inAudioFormat,
|
||||||
|
Loading…
Reference in New Issue
Block a user