aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMatthew Hoops2015-04-03 16:48:33 -0400
committerMatthew Hoops2015-07-07 20:19:43 -0400
commit984cd9b01875ae1cfcf6fb6fa12293e9e125a73b (patch)
treefc7f4f4c48042be04d1dfcb7f8daf29f64683e41 /engines
parent24add3c7457f5a13f659b9f2e5c8c8f46ef785c4 (diff)
downloadscummvm-rg350-984cd9b01875ae1cfcf6fb6fa12293e9e125a73b.tar.gz
scummvm-rg350-984cd9b01875ae1cfcf6fb6fa12293e9e125a73b.tar.bz2
scummvm-rg350-984cd9b01875ae1cfcf6fb6fa12293e9e125a73b.zip
CINE: Use the built-in OPL timer
Diffstat (limited to 'engines')
-rw-r--r--engines/cine/sound.cpp26
1 files changed, 6 insertions, 20 deletions
diff --git a/engines/cine/sound.cpp b/engines/cine/sound.cpp
index 2ac0f91cac..a20ad5d330 100644
--- a/engines/cine/sound.cpp
+++ b/engines/cine/sound.cpp
@@ -119,7 +119,7 @@ public:
virtual int getRate() const { return _sampleRate; }
void initCard();
- void update(int16 *buf, int len);
+ void onTimer();
void setupInstrument(const byte *data, int channel);
void loadRegisterInstrument(const byte *data, AdLibRegisterSoundInstrument *reg);
virtual void loadInstrument(const byte *data, AdLibSoundInstrument *asi) = 0;
@@ -291,6 +291,7 @@ AdLibSoundDriver::AdLibSoundDriver(Audio::Mixer *mixer)
memset(_channelsVolumeTable, 0, sizeof(_channelsVolumeTable));
memset(_instrumentsTable, 0, sizeof(_instrumentsTable));
initCard();
+ _opl->start(new Common::Functor0Mem<void, AdLibSoundDriver>(this, &AdLibSoundDriver::onTimer), 50);
_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
}
@@ -346,8 +347,7 @@ void AdLibSoundDriver::stopAll() {
}
int AdLibSoundDriver::readBuffer(int16 *buffer, const int numSamples) {
- update(buffer, numSamples);
- return numSamples;
+ return _opl->readBuffer(buffer, numSamples);
}
void AdLibSoundDriver::initCard() {
@@ -374,23 +374,9 @@ void AdLibSoundDriver::initCard() {
_opl->writeReg(1, 0);
}
-void AdLibSoundDriver::update(int16 *buf, int len) {
- static int samplesLeft = 0;
- while (len != 0) {
- int count = samplesLeft;
- if (count > len) {
- count = len;
- }
- samplesLeft -= count;
- len -= count;
- _opl->readBuffer(buf, count);
- if (samplesLeft == 0) {
- if (_upCb) {
- (*_upCb)(_upRef);
- }
- samplesLeft = _sampleRate / 50;
- }
- buf += count;
+void AdLibSoundDriver::onTimer() {
+ if (_upCb) {
+ (*_upCb)(_upRef);
}
}