diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2006-10-03 02:57:01 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2006-10-03 02:57:01 +0000 |
commit | d3040d1eb5aca9f6147007e3684acb361d281349 (patch) | |
tree | 0a4bf109d84751f36da5d02c0486544e6cbe6b02 /src/audio.c | |
parent | 347a33b009700a447e723ae83359851d6b4e7e02 (diff) | |
download | mpd-d3040d1eb5aca9f6147007e3684acb361d281349.tar.gz mpd-d3040d1eb5aca9f6147007e3684acb361d281349.tar.xz mpd-d3040d1eb5aca9f6147007e3684acb361d281349.zip |
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
Diffstat (limited to 'src/audio.c')
-rw-r--r-- | src/audio.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/audio.c b/src/audio.c index 7b659a895..b98540b7d 100644 --- a/src/audio.c +++ b/src/audio.c @@ -121,29 +121,37 @@ void initAudioDriver(void) audioDeviceStates = (getPlayerData())->audioDeviceStates; audioOutputArray = xmalloc(sizeof(AudioOutput) * audioOutputArraySize); - i = 0; - param = getNextConfigParam(CONF_AUDIO_OUTPUT, param); - - do { + for (i = 0; i < audioOutputArraySize; i++) + { AudioOutput *output = &audioOutputArray[i]; int j; - if (!initAudioOutput(output, param) && param) { - ERROR("problems configuring output device defined at " - "line %i\n", param->line); + param = getNextConfigParam(CONF_AUDIO_OUTPUT, param); + + 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); } /* require output names to be unique: */ - for (j = i; --j >= 0; ) { + for (j = 0; j < i; j++) { if (!strcmp(output->name, audioOutputArray[j].name)) { ERROR("output devices with identical " "names: %s\n", output->name); exit(EXIT_FAILURE); } } - audioDeviceStates[i++] = DEVICE_ENABLE; - } while ((param = getNextConfigParam(CONF_AUDIO_OUTPUT, param))); + audioDeviceStates[i] = DEVICE_ENABLE; + } } void getOutputAudioFormat(AudioFormat * inAudioFormat, |