mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 03:55:19 -04:00
fix crash with too many sounds
This commit is contained in:
parent
9208456be9
commit
c708cc0582
@ -633,8 +633,8 @@ void Audio_Free(AudioHandle handle) {
|
||||
if (!ctx->Handle) return;
|
||||
|
||||
ReturnCode result = waveOutClose(ctx->Handle);
|
||||
Mem_Set(ctx, 0, sizeof(struct AudioContext));
|
||||
ErrorHandler_CheckOrFail(result, "Audio - closing device");
|
||||
Mem_Set(ctx, 0, sizeof(struct AudioContext));
|
||||
}
|
||||
|
||||
struct AudioFormat* Audio_GetFormat(AudioHandle handle) {
|
||||
@ -648,8 +648,10 @@ void Audio_SetFormat(AudioHandle handle, struct AudioFormat* format) {
|
||||
|
||||
/* only recreate handle if we need to */
|
||||
if (AudioFormat_Eq(cur, format)) return;
|
||||
if (ctx->Handle) Audio_Free(handle);
|
||||
ctx->Format = *format;
|
||||
if (ctx->Handle) {
|
||||
ReturnCode result = waveOutClose(ctx->Handle);
|
||||
ErrorHandler_CheckOrFail(result, "Audio - closing device");
|
||||
}
|
||||
|
||||
WAVEFORMATEX fmt = { 0 };
|
||||
fmt.nChannels = format->Channels;
|
||||
@ -662,6 +664,7 @@ void Audio_SetFormat(AudioHandle handle, struct AudioFormat* format) {
|
||||
if (waveOutGetNumDevs() == 0u) ErrorHandler_Fail("No audio devices found");
|
||||
ReturnCode result = waveOutOpen(&ctx->Handle, WAVE_MAPPER, &fmt, NULL, NULL, CALLBACK_NULL);
|
||||
ErrorHandler_CheckOrFail(result, "Audio - opening device");
|
||||
ctx->Format = *format;
|
||||
}
|
||||
|
||||
void Audio_PlayData(AudioHandle handle, Int32 idx, void* data, UInt32 dataSize) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user