audio: don't allow isCurrentAudioFormat(NULL)

Passing NULL to this function doesn't make sense, and complicates its
implementation.  The one caller which might pass NULL should rather
check this.
This commit is contained in:
Max Kellermann 2008-09-10 11:43:40 +02:00
parent a53047af7d
commit 9f16a34d76
1 changed files with 5 additions and 3 deletions

View File

@ -222,8 +222,9 @@ void finishAudioDriver(void)
int isCurrentAudioFormat(const struct audio_format *audioFormat)
{
return audioFormat == NULL ||
audio_format_equals(audioFormat, &audio_format);
assert(audioFormat != NULL);
return audio_format_equals(audioFormat, &audio_format);
}
static void syncAudioDeviceStates(void)
@ -292,7 +293,8 @@ int openAudioDevice(const struct audio_format *audioFormat)
if (!audioOutputArray)
return -1;
if (!audioOpened || !isCurrentAudioFormat(audioFormat)) {
if (!audioOpened ||
(audioFormat != NULL && !isCurrentAudioFormat(audioFormat))) {
flushAudioBuffer();
if (audioFormat != NULL)
audio_format = *audioFormat;