diff options
author | Max Kellermann <max@duempel.org> | 2008-09-10 11:44:06 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-10 11:44:06 +0200 |
commit | 688298e265af151ef0bb2a9d2f02055dce7cc1d6 (patch) | |
tree | 3ecdc8148426f5948b7a3789a328fc0654426831 /src/audio.c | |
parent | 5d0a8ce3af943c33c4287907033c6ad0a335fba6 (diff) | |
download | mpd-688298e265af151ef0bb2a9d2f02055dce7cc1d6.tar.gz mpd-688298e265af151ef0bb2a9d2f02055dce7cc1d6.tar.xz mpd-688298e265af151ef0bb2a9d2f02055dce7cc1d6.zip |
audio: make audio_configFormat a static variable
Save one allocation, since the whole audio_format struct is nearly the
same size as the pointer to it. Check audio_format_defined(af)
instead of af!=NULL.
Diffstat (limited to '')
-rw-r--r-- | src/audio.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/audio.c b/src/audio.c index 7c430b326..ca8b7b1d8 100644 --- a/src/audio.c +++ b/src/audio.c @@ -30,7 +30,7 @@ #define AUDIO_DEVICE_STATE_LEN (sizeof(AUDIO_DEVICE_STATE)-1) #define AUDIO_BUFFER_SIZE 2*MPD_PATH_MAX -static struct audio_format *audio_configFormat; +static struct audio_format audio_configFormat; static struct audio_output *audioOutputArray; static unsigned int audioOutputArraySize; @@ -115,8 +115,8 @@ void initAudioDriver(void) void getOutputAudioFormat(const struct audio_format *inAudioFormat, struct audio_format *outAudioFormat) { - *outAudioFormat = audio_configFormat != NULL - ? *audio_configFormat + *outAudioFormat = audio_format_defined(&audio_configFormat) + ? audio_configFormat : *inAudioFormat; } @@ -127,9 +127,7 @@ void initAudioConfig(void) if (NULL == param || NULL == param->value) return; - audio_configFormat = xmalloc(sizeof(*audio_configFormat)); - - if (0 != parseAudioConfig(audio_configFormat, param->value)) { + if (0 != parseAudioConfig(&audio_configFormat, param->value)) { FATAL("error parsing \"%s\" at line %i\n", CONF_AUDIO_OUTPUT_FORMAT, param->line); } @@ -204,8 +202,7 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf) void finishAudioConfig(void) { - if (audio_configFormat) - free(audio_configFormat); + audio_format_clear(&audio_configFormat); } void finishAudioDriver(void) |