1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-29 09:44:52 +01:00

Close #12399: Refactor MIXER_GROUP to strong enum (#12531)

This commit is contained in:
pizza2004
2020-08-03 17:51:12 -06:00
committed by GitHub
parent bf0c4c4f0e
commit 156be224f9
8 changed files with 24 additions and 22 deletions

View File

@@ -26,7 +26,7 @@ namespace OpenRCT2::Audio
AudioSource_* _source = nullptr;
SpeexResamplerState* _resampler = nullptr;
int32_t _group = MIXER_GROUP_SOUND;
MixerGroup _group = MixerGroup::Sound;
double _rate = 0;
uint64_t _offset = 0;
int32_t _loop = 0;
@@ -80,12 +80,12 @@ namespace OpenRCT2::Audio
_resampler = value;
}
[[nodiscard]] int32_t GetGroup() const override
[[nodiscard]] MixerGroup GetGroup() const override
{
return _group;
}
void SetGroup(int32_t group) override
void SetGroup(MixerGroup group) override
{
_group = group;
}

View File

@@ -219,8 +219,8 @@ namespace OpenRCT2::Audio
while (it != _channels.end())
{
auto channel = *it;
int32_t group = channel->GetGroup();
if ((group != MIXER_GROUP_SOUND || gConfigSound.sound_enabled) && gConfigSound.master_sound_enabled
MixerGroup group = channel->GetGroup();
if ((group != MixerGroup::Sound || gConfigSound.sound_enabled) && gConfigSound.master_sound_enabled
&& gConfigSound.master_volume != 0)
{
MixChannel(channel, dst, length);
@@ -386,7 +386,7 @@ namespace OpenRCT2::Audio
switch (channel->GetGroup())
{
case MIXER_GROUP_SOUND:
case MixerGroup::Sound:
volumeAdjust *= _adjustSoundVolume;
// Cap sound volume on title screen so music is more audible
@@ -395,7 +395,8 @@ namespace OpenRCT2::Audio
volumeAdjust = std::min(volumeAdjust, 0.75f);
}
break;
case MIXER_GROUP_RIDE_MUSIC:
case MixerGroup::RideMusic:
case MixerGroup::TitleMusic:
volumeAdjust *= _adjustMusicVolume;
break;
}

View File

@@ -283,7 +283,7 @@ void audio_start_title_music()
gTitleMusicChannel = Mixer_Play_Music(pathId, MIXER_LOOP_INFINITE, true);
if (gTitleMusicChannel != nullptr)
{
Mixer_Channel_SetGroup(gTitleMusicChannel, MIXER_GROUP_TITLE_MUSIC);
Mixer_Channel_SetGroup(gTitleMusicChannel, OpenRCT2::Audio::MixerGroup::TitleMusic);
}
}

View File

@@ -10,6 +10,7 @@
#pragma once
#include "../common.h"
#include "AudioMixer.h"
namespace OpenRCT2::Audio
{
@@ -25,8 +26,8 @@ namespace OpenRCT2::Audio
virtual IAudioSource* GetSource() const abstract;
virtual int32_t GetGroup() const abstract;
virtual void SetGroup(int32_t group) abstract;
virtual MixerGroup GetGroup() const abstract;
virtual void SetGroup(MixerGroup group) abstract;
virtual double GetRate() const abstract;
virtual void SetRate(double rate) abstract;

View File

@@ -124,7 +124,7 @@ int32_t Mixer_Channel_SetOffset(void* channel, uint64_t offset)
return static_cast<IAudioChannel*>(channel)->SetOffset(offset);
}
void Mixer_Channel_SetGroup(void* channel, int32_t group)
void Mixer_Channel_SetGroup(void* channel, MixerGroup group)
{
static_cast<IAudioChannel*>(channel)->SetGroup(group);
}
@@ -161,7 +161,7 @@ void* Mixer_Play_Music(int32_t pathId, int32_t loop, int32_t streaming)
}
if (channel != nullptr)
{
channel->SetGroup(MIXER_GROUP_RIDE_MUSIC);
channel->SetGroup(MixerGroup::RideMusic);
}
return channel;
}

View File

@@ -17,15 +17,15 @@
enum class SoundId : uint8_t;
enum MIXER_GROUP
{
MIXER_GROUP_SOUND,
MIXER_GROUP_RIDE_MUSIC,
MIXER_GROUP_TITLE_MUSIC,
};
namespace OpenRCT2::Audio
{
enum class MixerGroup : int32_t
{
Sound,
RideMusic,
TitleMusic,
};
interface IAudioSource;
interface IAudioChannel;
@@ -66,7 +66,7 @@ void Mixer_Channel_Rate(void* channel, double rate);
int32_t Mixer_Channel_IsPlaying(void* channel);
uint64_t Mixer_Channel_GetOffset(void* channel);
int32_t Mixer_Channel_SetOffset(void* channel, uint64_t offset);
void Mixer_Channel_SetGroup(void* channel, int32_t group);
void Mixer_Channel_SetGroup(void* channel, OpenRCT2::Audio::MixerGroup group);
void* Mixer_Play_Music(int32_t pathId, int32_t loop, int32_t streaming);
void Mixer_SetVolume(float volume);

View File

@@ -1395,7 +1395,7 @@ void peep_update_crowd_noise()
_crowdSoundChannel = Mixer_Play_Music(PATH_ID_CSS2, MIXER_LOOP_INFINITE, false);
if (_crowdSoundChannel != nullptr)
{
Mixer_Channel_SetGroup(_crowdSoundChannel, MIXER_GROUP_SOUND);
Mixer_Channel_SetGroup(_crowdSoundChannel, OpenRCT2::Audio::MixerGroup::Sound);
}
}
if (_crowdSoundChannel != nullptr)

View File

@@ -3704,7 +3704,7 @@ void ride_music_update_final()
// Move circus music to the sound mixer group
if (ride_music_info->path_id == PATH_ID_CSS24)
{
Mixer_Channel_SetGroup(ride_music_3->sound_channel, MIXER_GROUP_SOUND);
Mixer_Channel_SetGroup(ride_music_3->sound_channel, Audio::MixerGroup::Sound);
}
}
return;