Reapply "Changed 'freesrc' parameter from int to SDL_bool" to SDL_wave.c

Commit bea99d4 was partially reverted by 905c4ff "audio: First shot at the SDL3 audio subsystem redesign!"
This commit is contained in:
meyraud705
2023-08-05 18:30:41 +02:00
committed by Ryan C. Gordon
parent 2ba03b4db0
commit 3a752ce650
3 changed files with 17 additions and 14 deletions

View File

@@ -2070,20 +2070,23 @@ static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 *
return 0;
}
int SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
int SDL_LoadWAV_RW(SDL_RWops *src, SDL_bool freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
{
int result = -1;
WaveFile file;
/* Make sure we are passed a valid data source */
if (src == NULL) {
return -1; /* Error may come from RWops. */
goto done; /* Error may come from RWops. */
} else if (spec == NULL) {
return SDL_InvalidParamError("spec");
SDL_InvalidParamError("spec");
goto done;
} else if (audio_buf == NULL) {
return SDL_InvalidParamError("audio_buf");
SDL_InvalidParamError("audio_buf");
goto done;
} else if (audio_len == NULL) {
return SDL_InvalidParamError("audio_len");
SDL_InvalidParamError("audio_len");
goto done;
}
*audio_buf = NULL;
@@ -2107,7 +2110,10 @@ int SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **aud
}
WaveFreeChunkData(&file.chunk);
SDL_free(file.decoderdata);
done:
if (freesrc && src) {
SDL_RWclose(src);
}
return result;
}