aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction/adlib.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2015-04-03 17:38:16 -0400
committerMatthew Hoops2015-07-07 20:19:43 -0400
commitb638efe0fad55e18513a9c0453100c0d3b9dd8c3 (patch)
tree9f2337eb16c378490a31b02e884b83e69a8348fa /engines/parallaction/adlib.cpp
parent5803dffead8cdf51bac64f00d095e5f5604d9e27 (diff)
downloadscummvm-rg350-b638efe0fad55e18513a9c0453100c0d3b9dd8c3.tar.gz
scummvm-rg350-b638efe0fad55e18513a9c0453100c0d3b9dd8c3.tar.bz2
scummvm-rg350-b638efe0fad55e18513a9c0453100c0d3b9dd8c3.zip
PARALLACTION: Use the built-in OPL timer
Diffstat (limited to 'engines/parallaction/adlib.cpp')
-rw-r--r--engines/parallaction/adlib.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/engines/parallaction/adlib.cpp b/engines/parallaction/adlib.cpp
index a2defa932b..302530bcad 100644
--- a/engines/parallaction/adlib.cpp
+++ b/engines/parallaction/adlib.cpp
@@ -285,8 +285,13 @@ public:
bool isStereo() const { return false; }
int getRate() const { return _mixer->getOutputRate(); }
+ int readBuffer(int16 *data, const int numSamples);
- void generateSamples(int16 *buf, int len);
+ void generateSamples(int16 *buf, int len) {}
+ virtual void setTimerCallback(void *timerParam, Common::TimerManager::TimerProc timerProc) {
+ _adlibTimerProc = timerProc;
+ _adlibTimerParam = timerParam;
+ }
protected:
OPL::OPL *_opl;
@@ -320,6 +325,12 @@ protected:
void muteMelodicVoice(uint8 voice);
void initVoices();
+
+private:
+ void onTimer();
+
+ Common::TimerManager::TimerProc _adlibTimerProc;
+ void *_adlibTimerParam;
};
MidiDriver *createAdLibDriver() {
@@ -364,6 +375,7 @@ int AdLibDriver::open() {
initVoices();
+ _opl->start(new Common::Functor0Mem<void, AdLibDriver>(this, &AdLibDriver::onTimer));
_mixer->playStream(Audio::Mixer::kMusicSoundType, &_mixerSoundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
return 0;
}
@@ -777,9 +789,13 @@ MidiChannel *AdLibDriver::allocateChannel() {
return NULL;
}
-void AdLibDriver::generateSamples(int16 *buf, int len) {
- memset(buf, 0, sizeof(int16) * len);
- _opl->readBuffer(buf, len);
+int AdLibDriver::readBuffer(int16 *data, const int numSamples) {
+ return _opl->readBuffer(data, numSamples);
+}
+
+void AdLibDriver::onTimer() {
+ if (_adlibTimerProc)
+ (*_adlibTimerProc)(_adlibTimerParam);
}
void AdLibDriver::initVoices() {