aboutsummaryrefslogtreecommitdiff
path: root/audio
diff options
context:
space:
mode:
Diffstat (limited to 'audio')
-rw-r--r--audio/mixer.cpp28
-rw-r--r--audio/mixer_intern.h10
2 files changed, 18 insertions, 20 deletions
diff --git a/audio/mixer.cpp b/audio/mixer.cpp
index a2b50ddbc4..63f006cbc9 100644
--- a/audio/mixer.cpp
+++ b/audio/mixer.cpp
@@ -162,19 +162,11 @@ private:
MixerImpl::MixerImpl(OSystem *system, uint sampleRate)
- : _syst(system), _sampleRate(sampleRate), _mixerReady(false), _handleSeed(0) {
+ : _syst(system), _mutex(), _sampleRate(sampleRate), _mixerReady(false), _handleSeed(0), _soundTypeSettings() {
assert(sampleRate > 0);
- int i;
-
- for (i = 0; i < ARRAYSIZE(_mute); ++i)
- _mute[i] = false;
-
- for (i = 0; i < ARRAYSIZE(_volumeForSoundType); i++)
- _volumeForSoundType[i] = kMaxMixerVolume;
-
- for (i = 0; i != NUM_CHANNELS; i++)
+ for (int i = 0; i != NUM_CHANNELS; i++)
_channels[i] = 0;
}
@@ -326,8 +318,8 @@ void MixerImpl::stopHandle(SoundHandle handle) {
}
void MixerImpl::muteSoundType(SoundType type, bool mute) {
- assert(0 <= type && type < ARRAYSIZE(_mute));
- _mute[type] = mute;
+ assert(0 <= type && type < ARRAYSIZE(_soundTypeSettings));
+ _soundTypeSettings[type].mute = mute;
for (int i = 0; i != NUM_CHANNELS; ++i) {
if (_channels[i] && _channels[i]->getType() == type)
@@ -336,8 +328,8 @@ void MixerImpl::muteSoundType(SoundType type, bool mute) {
}
bool MixerImpl::isSoundTypeMuted(SoundType type) const {
- assert(0 <= type && type < ARRAYSIZE(_mute));
- return _mute[type];
+ assert(0 <= type && type < ARRAYSIZE(_soundTypeSettings));
+ return _soundTypeSettings[type].mute;
}
void MixerImpl::setChannelVolume(SoundHandle handle, byte volume) {
@@ -435,7 +427,7 @@ bool MixerImpl::hasActiveChannelOfType(SoundType type) {
}
void MixerImpl::setVolumeForSoundType(SoundType type, int volume) {
- assert(0 <= type && type < ARRAYSIZE(_volumeForSoundType));
+ assert(0 <= type && type < ARRAYSIZE(_soundTypeSettings));
// Check range
if (volume > kMaxMixerVolume)
@@ -447,7 +439,7 @@ void MixerImpl::setVolumeForSoundType(SoundType type, int volume) {
// scaling? See also Player_V2::setMasterVolume
Common::StackLock lock(_mutex);
- _volumeForSoundType[type] = volume;
+ _soundTypeSettings[type].volume = volume;
for (int i = 0; i != NUM_CHANNELS; ++i) {
if (_channels[i] && _channels[i]->getType() == type)
@@ -456,9 +448,9 @@ void MixerImpl::setVolumeForSoundType(SoundType type, int volume) {
}
int MixerImpl::getVolumeForSoundType(SoundType type) const {
- assert(0 <= type && type < ARRAYSIZE(_volumeForSoundType));
+ assert(0 <= type && type < ARRAYSIZE(_soundTypeSettings));
- return _volumeForSoundType[type];
+ return _soundTypeSettings[type].volume;
}
diff --git a/audio/mixer_intern.h b/audio/mixer_intern.h
index 14dff5d53b..d7764e50d9 100644
--- a/audio/mixer_intern.h
+++ b/audio/mixer_intern.h
@@ -64,8 +64,14 @@ private:
bool _mixerReady;
uint32 _handleSeed;
- bool _mute[4];
- int _volumeForSoundType[4];
+ struct SoundTypeSettings {
+ SoundTypeSettings() : mute(false), volume(kMaxMixerVolume) {}
+
+ bool mute;
+ int volume;
+ };
+
+ SoundTypeSettings _soundTypeSettings[4];
Channel *_channels[NUM_CHANNELS];