From e3a2dd9e9099fcbff44637e40a14821d289325f0 Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Fri, 20 Dec 2024 03:41:42 +0300 Subject: [PATCH] Make channel index a global variable in embedded player. --- UnleashedRecomp/apu/embedded_player.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/UnleashedRecomp/apu/embedded_player.cpp b/UnleashedRecomp/apu/embedded_player.cpp index e72b7b6a..5e6c7ea9 100644 --- a/UnleashedRecomp/apu/embedded_player.cpp +++ b/UnleashedRecomp/apu/embedded_player.cpp @@ -24,9 +24,7 @@ enum class EmbeddedSound struct EmbeddedSoundData { - static const int SimultaneousLimit = 4; Mix_Chunk* chunk{}; - int channelIndex{}; }; static std::array g_embeddedSoundData = {}; @@ -41,6 +39,8 @@ static const std::unordered_map g_embeddedSound { "sys_actstg_pausewinopen", EmbeddedSound::SysActStgPauseWinOpen }, }; +static size_t g_channelIndex; + static void PlayEmbeddedSound(EmbeddedSound s) { EmbeddedSoundData &data = g_embeddedSoundData[size_t(s)]; @@ -86,9 +86,9 @@ static void PlayEmbeddedSound(EmbeddedSound s) data.chunk = Mix_LoadWAV_RW(SDL_RWFromConstMem(soundData, soundDataSize), 1); } - - Mix_PlayChannel(data.channelIndex % EmbeddedSoundData::SimultaneousLimit, data.chunk, 0); - ++data.channelIndex; + + Mix_PlayChannel(g_channelIndex % MIX_CHANNELS, data.chunk, 0); + ++g_channelIndex; } void EmbeddedPlayer::Init()