From bed9da8b9dbbaa19d317f71663e42875c1717fda Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 30 Apr 2015 00:01:30 -0400 Subject: AUDIO: Remove all AudioStream access to OPL --- engines/gob/sound/adlib.cpp | 26 -------------------------- engines/gob/sound/adlib.h | 10 +--------- engines/gob/sound/musplayer.cpp | 8 +++++--- 3 files changed, 6 insertions(+), 38 deletions(-) (limited to 'engines/gob') diff --git a/engines/gob/sound/adlib.cpp b/engines/gob/sound/adlib.cpp index 866eecf8bd..995cc48824 100644 --- a/engines/gob/sound/adlib.cpp +++ b/engines/gob/sound/adlib.cpp @@ -118,8 +118,6 @@ const uint16 AdLib::kHihatParams [kParamCount] = { AdLib::AdLib(Audio::Mixer &mixer, int callbackFreq) : _mixer(&mixer), _opl(0), _toPoll(0), _repCount(0), _first(true), _playing(false), _ended(true), _volume(0) { - _rate = _mixer->getOutputRate(); - initFreqs(); createOPL(); @@ -128,13 +126,9 @@ AdLib::AdLib(Audio::Mixer &mixer, int callbackFreq) : _mixer(&mixer), _opl(0), syncVolume(); _opl->start(new Common::Functor0Mem(this, &AdLib::onTimer), callbackFreq); - _mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, - this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); } AdLib::~AdLib() { - _mixer->stopHandle(_handle); - delete _opl; } @@ -168,10 +162,6 @@ void AdLib::createOPL() { } } -int AdLib::readBuffer(int16 *buffer, const int numSamples) { - return _opl->readBuffer(buffer, numSamples); -} - void AdLib::onTimer() { Common::StackLock slock(_mutex); @@ -218,22 +208,6 @@ void AdLib::onTimer() { } } -bool AdLib::isStereo() const { - return _opl->isStereo(); -} - -bool AdLib::endOfData() const { - return false; -} - -bool AdLib::endOfStream() const { - return false; -} - -int AdLib::getRate() const { - return _rate; -} - bool AdLib::isPlaying() const { return _playing; } diff --git a/engines/gob/sound/adlib.h b/engines/gob/sound/adlib.h index 2c83b15f5b..28ebf9d998 100644 --- a/engines/gob/sound/adlib.h +++ b/engines/gob/sound/adlib.h @@ -35,7 +35,7 @@ namespace OPL { namespace Gob { /** Base class for a player of an AdLib music format. */ -class AdLib : public Audio::AudioStream { +class AdLib { public: AdLib(Audio::Mixer &mixer, int callbackFrequency); virtual ~AdLib(); @@ -55,13 +55,6 @@ public: void stopPlay(); void syncVolume(); -// AudioStream API - int readBuffer(int16 *buffer, const int numSamples); - bool isStereo() const; - bool endOfData() const; - bool endOfStream() const; - int getRate() const; - protected: enum kVoice { kVoiceMelody0 = 0, @@ -233,7 +226,6 @@ private: Audio::Mixer *_mixer; - Audio::SoundHandle _handle; OPL::OPL *_opl; Common::Mutex _mutex; diff --git a/engines/gob/sound/musplayer.cpp b/engines/gob/sound/musplayer.cpp index bf90d44735..2c0330e70a 100644 --- a/engines/gob/sound/musplayer.cpp +++ b/engines/gob/sound/musplayer.cpp @@ -57,8 +57,12 @@ uint32 MUSPlayer::pollMusic(bool first) { return 0; } - if (first) + if (first) { + // Set the timer frequency on first run. + // Do not set it in rewind() for thread safety reasons. + setTimerFrequency((_ticksPerBeat * _tempo) / 60); return *_playPos++; + } uint16 delay = 0; while (delay == 0) { @@ -185,8 +189,6 @@ void MUSPlayer::rewind() { setPercussionMode(_soundMode != 0); setPitchRange(_pitchBendRange); - - setTimerFrequency((_ticksPerBeat * _tempo) / 60); } bool MUSPlayer::loadSND(Common::SeekableReadStream &snd) { -- cgit v1.2.3