diff options
author | Eugene Sandulenko | 2019-08-21 21:06:55 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:35 +0200 |
commit | 73b6724b929c78bdc4724b6648b03ed66a29bab7 (patch) | |
tree | 2025e4b5f187a39cbbea96d2a7013c20a307e800 /engines | |
parent | c3032f7742f48551eb1d00f771c56f2b03f0931d (diff) | |
download | scummvm-rg350-73b6724b929c78bdc4724b6648b03ed66a29bab7.tar.gz scummvm-rg350-73b6724b929c78bdc4724b6648b03ed66a29bab7.tar.bz2 scummvm-rg350-73b6724b929c78bdc4724b6648b03ed66a29bab7.zip |
HDB: Do not allocate sound handles dynamically
Diffstat (limited to 'engines')
-rw-r--r-- | engines/hdb/sound.cpp | 46 | ||||
-rw-r--r-- | engines/hdb/sound.h | 18 |
2 files changed, 29 insertions, 35 deletions
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp index 85e20f0036..c1a702584a 100644 --- a/engines/hdb/sound.cpp +++ b/engines/hdb/sound.cpp @@ -1469,13 +1469,13 @@ void Sound::setMusicVolume(int volume) { if (_song1.fadingIn) _song1.fadeInVol = volume; if (!_song1.fadingOut) - g_hdb->_mixer->setChannelVolume(*_song1.handle, volume); + g_hdb->_mixer->setChannelVolume(_song1.handle, volume); } if (_song2.playing) { if (_song2.fadingIn) _song1.fadeInVol = volume; if (!_song2.fadingOut) - g_hdb->_mixer->setChannelVolume(*_song2.handle, volume); + g_hdb->_mixer->setChannelVolume(_song2.handle, volume); } } @@ -1629,7 +1629,7 @@ void Sound::playVoice(int index, int actor) { // is voice channel already active? if so, shut 'er down (automagically called StopVoice via callback) if (_voices[actor].active) - g_hdb->_mixer->stopHandle(*_voices[actor].handle); + g_hdb->_mixer->stopHandle(_voices[actor].handle); // make sure we aren't playing a line more than once this time (only on CHANNEL 0) if (!actor && _voicePlayed[index - FIRST_VOICE]) @@ -1652,11 +1652,11 @@ void Sound::playVoice(int index, int actor) { return; } - g_hdb->_mixer->setChannelVolume(*_voices[actor].handle, _sfxVolume); + g_hdb->_mixer->setChannelVolume(_voices[actor].handle, _sfxVolume); g_hdb->_mixer->playStream( Audio::Mixer::kSpeechSoundType, - _voices[actor].handle, + &_voices[actor].handle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, @@ -1674,11 +1674,11 @@ void Sound::playVoice(int index, int actor) { return; } - g_hdb->_mixer->setChannelVolume(*_voices[actor].handle, _sfxVolume); + g_hdb->_mixer->setChannelVolume(_voices[actor].handle, _sfxVolume); g_hdb->_mixer->playStream( Audio::Mixer::kSpeechSoundType, - _voices[actor].handle, + &_voices[actor].handle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, @@ -1744,11 +1744,11 @@ void Sound::stopChannel(int channel) { void Sound::stopMusic() { if (_song1.playing) { _song1.playing = false; - g_hdb->_mixer->stopHandle(*_song1.handle); + g_hdb->_mixer->stopHandle(_song1.handle); } if (_song2.playing) { _song2.playing = false; - g_hdb->_mixer->stopHandle(*_song2.handle); + g_hdb->_mixer->stopHandle(_song2.handle); } } @@ -1797,19 +1797,19 @@ void Sound::beginMusic(SoundType song, bool fadeIn, int ramp) { Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES); Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); - g_hdb->_mixer->setChannelVolume(*_song1.handle, _musicVolume); + g_hdb->_mixer->setChannelVolume(_song1.handle, _musicVolume); // do we need to fade-in this song? if (fadeIn) { _song1.fadeInRamp = ramp; _song1.fadingIn = true; _song1.fadeInVol = 0; - g_hdb->_mixer->setChannelVolume(*_song1.handle, 0); + g_hdb->_mixer->setChannelVolume(_song1.handle, 0); } g_hdb->_mixer->playStream( Audio::Mixer::kMusicSoundType, - _song1.handle, + &_song1.handle, loopingStream, -1, Audio::Mixer::kMaxChannelVolume, @@ -1825,19 +1825,19 @@ void Sound::beginMusic(SoundType song, bool fadeIn, int ramp) { Audio::SeekableAudioStream *audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES); Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); - g_hdb->_mixer->setChannelVolume(*_song1.handle, _musicVolume); + g_hdb->_mixer->setChannelVolume(_song1.handle, _musicVolume); // do we need to fade-in this song? if (fadeIn) { _song1.fadeInRamp = ramp; _song1.fadingIn = true; _song1.fadeInVol = 0; - g_hdb->_mixer->setChannelVolume(*_song1.handle, 0); + g_hdb->_mixer->setChannelVolume(_song1.handle, 0); } g_hdb->_mixer->playStream( Audio::Mixer::kMusicSoundType, - _song1.handle, + &_song1.handle, loopingStream, -1, Audio::Mixer::kMaxChannelVolume, @@ -1869,19 +1869,19 @@ void Sound::beginMusic(SoundType song, bool fadeIn, int ramp) { Audio::SeekableAudioStream *audioStream = Audio::makeMP3Stream(stream, DisposeAfterUse::YES); Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); - g_hdb->_mixer->setChannelVolume(*_song2.handle, _musicVolume); + g_hdb->_mixer->setChannelVolume(_song2.handle, _musicVolume); // do we need to fade-in this song? if (fadeIn) { _song2.fadeInRamp = ramp; _song2.fadingIn = true; _song2.fadeInVol = 0; - g_hdb->_mixer->setChannelVolume(*_song2.handle, 0); + g_hdb->_mixer->setChannelVolume(_song2.handle, 0); } g_hdb->_mixer->playStream( Audio::Mixer::kMusicSoundType, - _song2.handle, + &_song2.handle, loopingStream, -1, Audio::Mixer::kMaxChannelVolume, @@ -1897,19 +1897,19 @@ void Sound::beginMusic(SoundType song, bool fadeIn, int ramp) { Audio::SeekableAudioStream *audioStream = Audio::makeVorbisStream(stream, DisposeAfterUse::YES); Audio::AudioStream *loopingStream = new Audio::LoopingAudioStream(audioStream, 0, DisposeAfterUse::YES); - g_hdb->_mixer->setChannelVolume(*_song2.handle, _musicVolume); + g_hdb->_mixer->setChannelVolume(_song2.handle, _musicVolume); // do we need to fade-in this song? if (fadeIn) { _song2.fadeInRamp = ramp; _song2.fadingIn = true; _song2.fadeInVol = 0; - g_hdb->_mixer->setChannelVolume(*_song2.handle, 0); + g_hdb->_mixer->setChannelVolume(_song2.handle, 0); } g_hdb->_mixer->playStream( Audio::Mixer::kMusicSoundType, - _song2.handle, + &_song2.handle, loopingStream, -1, Audio::Mixer::kMaxChannelVolume, @@ -1930,7 +1930,7 @@ void Sound::updateMusic() { if (_song1.fadingOut) { _song1.fadeOutVol = 0; _song1.playing = false; - g_hdb->_mixer->stopHandle(*_song1.handle); + g_hdb->_mixer->stopHandle(_song1.handle); } else if (_song1.fadingIn) { _song1.fadeInVol = _musicVolume; _song1.fadingIn = false; @@ -1941,7 +1941,7 @@ void Sound::updateMusic() { if (_song2.fadingOut) { _song2.fadeOutVol = 0; _song2.playing = false; - g_hdb->_mixer->stopHandle(*_song2.handle); + g_hdb->_mixer->stopHandle(_song2.handle); } else if (_song2.fadingIn) { _song2.fadeInVol = _musicVolume; _song2.fadingIn = false; diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h index 6797808a7d..4d2e6eea86 100644 --- a/engines/hdb/sound.h +++ b/engines/hdb/sound.h @@ -1427,12 +1427,9 @@ struct SoundLookUp { struct Voice { bool active; - Audio::SoundHandle *handle; + Audio::SoundHandle handle; - Voice() : active(false), handle(new Audio::SoundHandle) {} - ~Voice() { - delete handle; - } + Voice() : active(false) {} }; enum SndMem { @@ -1462,7 +1459,7 @@ struct SoundCache { struct Song { bool playing; SoundType song; - Audio::SoundHandle *handle; + Audio::SoundHandle handle; bool fadingOut; int fadeOutVol; @@ -1472,12 +1469,9 @@ struct Song { int fadeInVol; int fadeInRamp; - Song() : playing(false), song(SONG_NONE), handle(new Audio::SoundHandle()), + Song() : playing(false), song(SONG_NONE), fadingOut(false), fadeOutVol(0), fadeOutRamp(0), fadingIn(false), fadeInVol(0), fadeInRamp(0) {} - ~Song() { - delete handle; - } }; class Sound { @@ -1515,11 +1509,11 @@ public: void playVoice(int index, int actor); void stopVoices() { if (_voices[0].active) { - g_hdb->_mixer->stopHandle(*_voices[0].handle); + g_hdb->_mixer->stopHandle(_voices[0].handle); _voices[0].active = false; } if (_voices[1].active) { - g_hdb->_mixer->stopHandle(*_voices[1].handle); + g_hdb->_mixer->stopHandle(_voices[1].handle); _voices[1].active = false; } } |