mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -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;
|
if (!ctx->Handle) return;
|
||||||
|
|
||||||
ReturnCode result = waveOutClose(ctx->Handle);
|
ReturnCode result = waveOutClose(ctx->Handle);
|
||||||
Mem_Set(ctx, 0, sizeof(struct AudioContext));
|
|
||||||
ErrorHandler_CheckOrFail(result, "Audio - closing device");
|
ErrorHandler_CheckOrFail(result, "Audio - closing device");
|
||||||
|
Mem_Set(ctx, 0, sizeof(struct AudioContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AudioFormat* Audio_GetFormat(AudioHandle handle) {
|
struct AudioFormat* Audio_GetFormat(AudioHandle handle) {
|
||||||
@ -648,9 +648,11 @@ void Audio_SetFormat(AudioHandle handle, struct AudioFormat* format) {
|
|||||||
|
|
||||||
/* only recreate handle if we need to */
|
/* only recreate handle if we need to */
|
||||||
if (AudioFormat_Eq(cur, format)) return;
|
if (AudioFormat_Eq(cur, format)) return;
|
||||||
if (ctx->Handle) Audio_Free(handle);
|
if (ctx->Handle) {
|
||||||
ctx->Format = *format;
|
ReturnCode result = waveOutClose(ctx->Handle);
|
||||||
|
ErrorHandler_CheckOrFail(result, "Audio - closing device");
|
||||||
|
}
|
||||||
|
|
||||||
WAVEFORMATEX fmt = { 0 };
|
WAVEFORMATEX fmt = { 0 };
|
||||||
fmt.nChannels = format->Channels;
|
fmt.nChannels = format->Channels;
|
||||||
fmt.wFormatTag = WAVE_FORMAT_PCM;
|
fmt.wFormatTag = WAVE_FORMAT_PCM;
|
||||||
@ -662,6 +664,7 @@ void Audio_SetFormat(AudioHandle handle, struct AudioFormat* format) {
|
|||||||
if (waveOutGetNumDevs() == 0u) ErrorHandler_Fail("No audio devices found");
|
if (waveOutGetNumDevs() == 0u) ErrorHandler_Fail("No audio devices found");
|
||||||
ReturnCode result = waveOutOpen(&ctx->Handle, WAVE_MAPPER, &fmt, NULL, NULL, CALLBACK_NULL);
|
ReturnCode result = waveOutOpen(&ctx->Handle, WAVE_MAPPER, &fmt, NULL, NULL, CALLBACK_NULL);
|
||||||
ErrorHandler_CheckOrFail(result, "Audio - opening device");
|
ErrorHandler_CheckOrFail(result, "Audio - opening device");
|
||||||
|
ctx->Format = *format;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio_PlayData(AudioHandle handle, Int32 idx, void* data, UInt32 dataSize) {
|
void Audio_PlayData(AudioHandle handle, Int32 idx, void* data, UInt32 dataSize) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user