diff options
author | Willem Jan Palenstijn | 2015-07-22 22:37:40 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2015-07-22 22:43:42 +0200 |
commit | 6ec9c81b575f13b2c4b30aeac592ebf2557b5890 (patch) | |
tree | 503d50902bad2d800165593039d08d5ccf0c98ab /engines/scumm/players/player_ad.cpp | |
parent | 5ec05f6b647c5ea41418be7ed19ad381f97cabd8 (diff) | |
parent | 4e5c8d35f7e133e2e72a846fdbd54900c91eeb73 (diff) | |
download | scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.gz scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.tar.bz2 scummvm-rg350-6ec9c81b575f13b2c4b30aeac592ebf2557b5890.zip |
Merge branch 'master' into mm
Conflicts:
engines/access/access.cpp
engines/access/asurface.h
engines/access/bubble_box.cpp
engines/access/bubble_box.h
engines/access/martian/martian_game.cpp
engines/access/player.cpp
engines/access/player.h
engines/access/resources.cpp
engines/access/screen.cpp
engines/access/screen.h
engines/access/sound.cpp
engines/access/sound.h
Diffstat (limited to 'engines/scumm/players/player_ad.cpp')
-rw-r--r-- | engines/scumm/players/player_ad.cpp | 48 |
1 files changed, 10 insertions, 38 deletions
diff --git a/engines/scumm/players/player_ad.cpp b/engines/scumm/players/player_ad.cpp index adcda68e10..4d4be2c3c2 100644 --- a/engines/scumm/players/player_ad.cpp +++ b/engines/scumm/players/player_ad.cpp @@ -27,6 +27,7 @@ #include "scumm/saveload.h" #include "audio/fmopl.h" +#include "audio/mixer.h" #include "common/textconsole.h" #include "common/config-manager.h" @@ -35,26 +36,19 @@ namespace Scumm { #define AD_CALLBACK_FREQUENCY 472 -Player_AD::Player_AD(ScummEngine *scumm, Audio::Mixer *mixer) - : _vm(scumm), _mixer(mixer), _rate(mixer->getOutputRate()) { +Player_AD::Player_AD(ScummEngine *scumm) + : _vm(scumm) { _opl2 = OPL::Config::create(); - if (!_opl2->init(_rate)) { + if (!_opl2->init()) { error("Could not initialize OPL2 emulator"); } - _samplesPerCallback = _rate / AD_CALLBACK_FREQUENCY; - _samplesPerCallbackRemainder = _rate % AD_CALLBACK_FREQUENCY; - _samplesTillCallback = 0; - _samplesTillCallbackRemainder = 0; - memset(_registerBackUpTable, 0, sizeof(_registerBackUpTable)); writeReg(0x01, 0x00); writeReg(0xBD, 0x00); writeReg(0x08, 0x00); writeReg(0x01, 0x20); - _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true); - _engineMusicTimer = 0; _soundPlaying = -1; @@ -78,11 +72,11 @@ Player_AD::Player_AD(ScummEngine *scumm, Audio::Mixer *mixer) _musicVolume = _sfxVolume = 255; _isSeeking = false; + + _opl2->start(new Common::Functor0Mem<void, Player_AD>(this, &Player_AD::onTimer), AD_CALLBACK_FREQUENCY); } Player_AD::~Player_AD() { - _mixer->stopHandle(_soundHandle); - stopAllSounds(); Common::StackLock lock(_mutex); delete _opl2; @@ -244,36 +238,14 @@ void Player_AD::saveLoadWithSerializer(Serializer *ser) { } } -int Player_AD::readBuffer(int16 *buffer, const int numSamples) { +void Player_AD::onTimer() { Common::StackLock lock(_mutex); - int len = numSamples; - - while (len > 0) { - if (!_samplesTillCallback) { - if (_curOffset) { - updateMusic(); - } - - updateSfx(); - - _samplesTillCallback = _samplesPerCallback; - _samplesTillCallbackRemainder += _samplesPerCallbackRemainder; - if (_samplesTillCallbackRemainder >= AD_CALLBACK_FREQUENCY) { - ++_samplesTillCallback; - _samplesTillCallbackRemainder -= AD_CALLBACK_FREQUENCY; - } - } - - const int samplesToRead = MIN(len, _samplesTillCallback); - _opl2->readBuffer(buffer, samplesToRead); - - buffer += samplesToRead; - len -= samplesToRead; - _samplesTillCallback -= samplesToRead; + if (_curOffset) { + updateMusic(); } - return numSamples; + updateSfx(); } void Player_AD::setupVolume() { |