aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2015-04-03 17:20:29 -0400
committerMatthew Hoops2015-07-07 20:19:43 -0400
commit5803dffead8cdf51bac64f00d095e5f5604d9e27 (patch)
tree042673a795020425dec4167db1a0b7c46a952ac7
parent3c7c217f4418d3ce9865f8950462a5e9dc0a9ef9 (diff)
downloadscummvm-rg350-5803dffead8cdf51bac64f00d095e5f5604d9e27.tar.gz
scummvm-rg350-5803dffead8cdf51bac64f00d095e5f5604d9e27.tar.bz2
scummvm-rg350-5803dffead8cdf51bac64f00d095e5f5604d9e27.zip
KYRA: Use the built-in OPL timer
-rw-r--r--engines/kyra/sound_adlib.cpp37
1 files changed, 5 insertions, 32 deletions
diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp
index ad3395b74a..999bd96972 100644
--- a/engines/kyra/sound_adlib.cpp
+++ b/engines/kyra/sound_adlib.cpp
@@ -72,28 +72,10 @@ public:
// AudioStream API
int readBuffer(int16 *buffer, const int numSamples) {
- int32 samplesLeft = numSamples;
- memset(buffer, 0, sizeof(int16) * numSamples);
- while (samplesLeft) {
- if (!_samplesTillCallback) {
- callback();
- _samplesTillCallback = _samplesPerCallback;
- _samplesTillCallbackRemainder += _samplesPerCallbackRemainder;
- if (_samplesTillCallbackRemainder >= CALLBACKS_PER_SECOND) {
- _samplesTillCallback++;
- _samplesTillCallbackRemainder -= CALLBACKS_PER_SECOND;
- }
- }
-
- int32 render = MIN(samplesLeft, _samplesTillCallback);
- samplesLeft -= render;
- _samplesTillCallback -= render;
- _adlib->readBuffer(buffer, render);
- buffer += render;
- }
- return numSamples;
+ return _adlib->readBuffer(buffer, numSamples);
}
+
bool isStereo() const { return false; }
bool endOfData() const { return false; }
int getRate() const { return _mixer->getOutputRate(); }
@@ -334,11 +316,6 @@ private:
// _unkTable2_2[] - One of the tables in _unkTable2[]
// _unkTable2_3[] - One of the tables in _unkTable2[]
- int32 _samplesPerCallback;
- int32 _samplesPerCallbackRemainder;
- int32 _samplesTillCallback;
- int32 _samplesTillCallbackRemainder;
-
int _curChannel;
uint8 _soundTrigger;
@@ -452,13 +429,6 @@ AdLibDriver::AdLibDriver(Audio::Mixer *mixer, int version) {
_tablePtr1 = _tablePtr2 = 0;
- _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
-
- _samplesPerCallback = getRate() / CALLBACKS_PER_SECOND;
- _samplesPerCallbackRemainder = getRate() % CALLBACKS_PER_SECOND;
- _samplesTillCallback = 0;
- _samplesTillCallbackRemainder = 0;
-
_syncJumpMask = 0;
_musicVolume = 0;
@@ -468,6 +438,9 @@ AdLibDriver::AdLibDriver(Audio::Mixer *mixer, int version) {
_programQueueStart = _programQueueEnd = 0;
_retrySounds = false;
+
+ _adlib->start(new Common::Functor0Mem<void, AdLibDriver>(this, &AdLibDriver::callback), CALLBACKS_PER_SECOND);
+ _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
}
AdLibDriver::~AdLibDriver() {