Skip to content

Commit

Permalink
Give better error if SDL_mixer causes a crash
Browse files Browse the repository at this point in the history
  • Loading branch information
bradharding committed Oct 13, 2023
1 parent f62fc0d commit 11dfa38
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/i_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ static void ReleaseSoundOnChannel(const int channel)
if (!snd)
return;

Mix_HaltChannel(channel);
if (Mix_HaltChannel(channel) == -1)
I_SDLError("Mix_HaltChannel", -1);

channels_playing[channel] = NULL;
UnlockAllocatedSound(snd);
Expand Down Expand Up @@ -319,7 +320,8 @@ bool CacheSFX(sfxinfo_t *sfxinfo)

void I_UpdateSoundParms(const int channel, const int vol, const int sep)
{
Mix_SetPanning(channel, (254 - sep) * vol / (MIX_MAX_VOLUME - 1), sep * vol / (MIX_MAX_VOLUME - 1));
if (!Mix_SetPanning(channel, (254 - sep) * vol / (MIX_MAX_VOLUME - 1), sep * vol / (MIX_MAX_VOLUME - 1)))
I_SDLError("Mix_SetPanning", -1);
}

//
Expand Down Expand Up @@ -357,7 +359,8 @@ int I_StartSound(const sfxinfo_t *sfxinfo, const int channel, const int vol, con
LockAllocatedSound(snd);

// Play sound
Mix_PlayChannel(channel, &snd->chunk, 0);
if (Mix_PlayChannel(channel, &snd->chunk, 0) == -1)
I_SDLError("Mix_PlayChannel", -1);

channels_playing[channel] = snd;

Expand Down
1 change: 1 addition & 0 deletions src/i_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include "d_event.h"
#include "doomdef.h"
#include "m_misc.h"

#if defined(_WIN32)
#define DEVICE "PC"
Expand Down

0 comments on commit 11dfa38

Please sign in to comment.