From 438f100d5eb7a27cac5131568968cedf14e33e07 Mon Sep 17 00:00:00 2001 From: Ori Avtalion Date: Sun, 22 May 2016 22:02:37 +0300 Subject: AGI: Reduce audio header dependencies --- engines/agi/global.cpp | 1 + engines/agi/preagi.cpp | 8 ++++++-- engines/agi/preagi.h | 3 ++- engines/agi/sound.cpp | 10 ++++++++++ engines/agi/sound.h | 14 +++++++------- engines/agi/sound_2gs.cpp | 5 +++-- engines/agi/sound_pcjr.cpp | 5 +++-- engines/agi/sound_sarien.cpp | 5 +++-- 8 files changed, 35 insertions(+), 16 deletions(-) (limited to 'engines') diff --git a/engines/agi/global.cpp b/engines/agi/global.cpp index 23256f27fb..6f83f02a4e 100644 --- a/engines/agi/global.cpp +++ b/engines/agi/global.cpp @@ -21,6 +21,7 @@ */ #include "common/config-manager.h" +#include "audio/mixer.h" #include "agi/agi.h" #include "agi/graphics.h" diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp index 7e2e65a3eb..f8630db0b6 100644 --- a/engines/agi/preagi.cpp +++ b/engines/agi/preagi.cpp @@ -20,6 +20,7 @@ * */ +#include "audio/mixer.h" #include "audio/softsynth/pcspk.h" #include "common/debug-channels.h" @@ -50,6 +51,8 @@ PreAgiEngine::PreAgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : memset(&_game, 0, sizeof(struct AgiGame)); memset(&_debug, 0, sizeof(struct AgiDebug)); memset(&_mouse, 0, sizeof(struct Mouse)); + + _speakerHandle = new Audio::SoundHandle(); } void PreAgiEngine::initialize() { @@ -74,7 +77,7 @@ void PreAgiEngine::initialize() { _gfx->initVideo(); _speakerStream = new Audio::PCSpeaker(_mixer->getOutputRate()); - _mixer->playStream(Audio::Mixer::kSFXSoundType, &_speakerHandle, + _mixer->playStream(Audio::Mixer::kSFXSoundType, _speakerHandle, _speakerStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); debugC(2, kDebugLevelMain, "Detect game"); @@ -89,8 +92,9 @@ void PreAgiEngine::initialize() { } PreAgiEngine::~PreAgiEngine() { - _mixer->stopHandle(_speakerHandle); + _mixer->stopHandle(*_speakerHandle); delete _speakerStream; + delete _speakerHandle; delete _picture; delete _gfx; diff --git a/engines/agi/preagi.h b/engines/agi/preagi.h index d6026a5d4d..6950aa30cd 100644 --- a/engines/agi/preagi.h +++ b/engines/agi/preagi.h @@ -26,6 +26,7 @@ #include "agi/agi.h" namespace Audio { +class SoundHandle; class PCSpeaker; } @@ -110,7 +111,7 @@ private: int _defaultColor; Audio::PCSpeaker *_speakerStream; - Audio::SoundHandle _speakerHandle; + Audio::SoundHandle *_speakerHandle; }; } // End of namespace Agi diff --git a/engines/agi/sound.cpp b/engines/agi/sound.cpp index edf17960ad..8834068ace 100644 --- a/engines/agi/sound.cpp +++ b/engines/agi/sound.cpp @@ -29,9 +29,19 @@ #include "agi/sound_pcjr.h" #include "common/textconsole.h" +#include "audio/mixer.h" namespace Agi { +SoundGen::SoundGen(AgiBase *vm, Audio::Mixer *pMixer) : _vm(vm), _mixer(pMixer) { + _sampleRate = pMixer->getOutputRate(); + _soundHandle = new Audio::SoundHandle(); +} + +SoundGen::~SoundGen() { + delete _soundHandle; +} + // // TODO: add support for variable sampling rate in the output device // diff --git a/engines/agi/sound.h b/engines/agi/sound.h index 4b668e8cf2..8aa7a5d1df 100644 --- a/engines/agi/sound.h +++ b/engines/agi/sound.h @@ -23,7 +23,10 @@ #ifndef AGI_SOUND_H #define AGI_SOUND_H -#include "audio/mixer.h" +namespace Audio { +class Mixer; +class SoundHandle; +} namespace Agi { @@ -71,11 +74,8 @@ class SoundMgr; class SoundGen { public: - SoundGen(AgiBase *vm, Audio::Mixer *pMixer) : _vm(vm), _mixer(pMixer) { - _sampleRate = pMixer->getOutputRate(); - } - - virtual ~SoundGen() {} + SoundGen(AgiBase *vm, Audio::Mixer *pMixer); + virtual ~SoundGen(); virtual void play(int resnum) = 0; virtual void stop(void) = 0; @@ -83,7 +83,7 @@ public: AgiBase *_vm; Audio::Mixer *_mixer; - Audio::SoundHandle _soundHandle; + Audio::SoundHandle *_soundHandle; uint32 _sampleRate; }; diff --git a/engines/agi/sound_2gs.cpp b/engines/agi/sound_2gs.cpp index b1bcee3920..4992b6516c 100644 --- a/engines/agi/sound_2gs.cpp +++ b/engines/agi/sound_2gs.cpp @@ -27,6 +27,7 @@ #include "common/memstream.h" #include "common/str-array.h" #include "common/textconsole.h" +#include "audio/mixer.h" #include "agi/agi.h" #include "agi/sound_2gs.h" @@ -55,11 +56,11 @@ SoundGen2GS::SoundGen2GS(AgiBase *vm, Audio::Mixer *pMixer) : SoundGen(vm, pMixe // Load instruments _disableMidi = !loadInstruments(); - _mixer->playStream(Audio::Mixer::kMusicSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); + _mixer->playStream(Audio::Mixer::kMusicSoundType, _soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); } SoundGen2GS::~SoundGen2GS() { - _mixer->stopHandle(_soundHandle); + _mixer->stopHandle(*_soundHandle); delete[] _wavetable; delete[] _out; } diff --git a/engines/agi/sound_pcjr.cpp b/engines/agi/sound_pcjr.cpp index 9d556e048a..0a0c456e14 100644 --- a/engines/agi/sound_pcjr.cpp +++ b/engines/agi/sound_pcjr.cpp @@ -54,6 +54,7 @@ * */ +#include "audio/mixer.h" #include "agi/agi.h" #include "agi/sound.h" #include "agi/sound_pcjr.h" @@ -123,7 +124,7 @@ SoundGenPCJr::SoundGenPCJr(AgiBase *vm, Audio::Mixer *pMixer) : SoundGen(vm, pMi memset(_channel, 0, sizeof(_channel)); memset(_tchannel, 0, sizeof(_tchannel)); - _mixer->playStream(Audio::Mixer::kMusicSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); + _mixer->playStream(Audio::Mixer::kMusicSoundType, _soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); _v1data = NULL; _v1size = 0; @@ -132,7 +133,7 @@ SoundGenPCJr::SoundGenPCJr(AgiBase *vm, Audio::Mixer *pMixer) : SoundGen(vm, pMi SoundGenPCJr::~SoundGenPCJr() { free(_chanData); - _mixer->stopHandle(_soundHandle); + _mixer->stopHandle(*_soundHandle); } void SoundGenPCJr::play(int resnum) { diff --git a/engines/agi/sound_sarien.cpp b/engines/agi/sound_sarien.cpp index 939c3d2c77..1b3542b89c 100644 --- a/engines/agi/sound_sarien.cpp +++ b/engines/agi/sound_sarien.cpp @@ -21,6 +21,7 @@ */ #include "common/random.h" +#include "audio/mixer.h" #include "agi/agi.h" @@ -92,11 +93,11 @@ SoundGenSarien::SoundGenSarien(AgiBase *vm, Audio::Mixer *pMixer) : SoundGen(vm, debug(0, "Initializing sound: envelopes disabled"); } - _mixer->playStream(Audio::Mixer::kMusicSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); + _mixer->playStream(Audio::Mixer::kMusicSoundType, _soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); } SoundGenSarien::~SoundGenSarien() { - _mixer->stopHandle(_soundHandle); + _mixer->stopHandle(*_soundHandle); free(_sndBuffer); } -- cgit v1.2.3