aboutsummaryrefslogtreecommitdiff
path: root/audio/softsynth
diff options
context:
space:
mode:
authorMatthew Hoops2015-04-03 10:59:10 -0400
committerMatthew Hoops2015-07-07 20:19:43 -0400
commited8830fcc807f9620185e143558f90f9b2cb8aea (patch)
treec3968b62e97bab0fc4135154b8972552fff3d5a9 /audio/softsynth
parent0bb13b358e1126f25bd8e6053da2b4343269252f (diff)
downloadscummvm-rg350-ed8830fcc807f9620185e143558f90f9b2cb8aea.tar.gz
scummvm-rg350-ed8830fcc807f9620185e143558f90f9b2cb8aea.tar.bz2
scummvm-rg350-ed8830fcc807f9620185e143558f90f9b2cb8aea.zip
AUDIO: Use the built-in OPL timer for MidiDriver_ADLIB
Diffstat (limited to 'audio/softsynth')
-rw-r--r--audio/softsynth/adlib.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/audio/softsynth/adlib.cpp b/audio/softsynth/adlib.cpp
index 49e69ecd57..c7b5297e2d 100644
--- a/audio/softsynth/adlib.cpp
+++ b/audio/softsynth/adlib.cpp
@@ -948,9 +948,12 @@ public:
// AudioStream API
+ int readBuffer(int16 *data, const int numSamples);
bool isStereo() const { return _opl->isStereo(); }
int getRate() const { return _mixer->getOutputRate(); }
+ virtual void setTimerCallback(void *timerParam, Common::TimerManager::TimerProc timerProc);
+
private:
bool _scummSmallHeader; // FIXME: This flag controls a special mode for SCUMM V3 games
#ifdef ENABLE_OPL3
@@ -963,6 +966,9 @@ private:
byte *_regCacheSecondary;
#endif
+ Common::TimerManager::TimerProc _adlibTimerProc;
+ void *_adlibTimerParam;
+
int _timerCounter;
uint16 _channelTable2[9];
@@ -1403,6 +1409,8 @@ MidiDriver_ADLIB::MidiDriver_ADLIB(Audio::Mixer *mixer)
_timerIncrease = 0xD69;
_timerThreshold = 0x411B;
_opl = 0;
+ _adlibTimerProc = 0;
+ _adlibTimerParam = 0;
}
int MidiDriver_ADLIB::open() {
@@ -1452,6 +1460,7 @@ int MidiDriver_ADLIB::open() {
}
#endif
+ _opl->start(new Common::Functor0Mem<void, MidiDriver_ADLIB>(this, &MidiDriver_ADLIB::onTimer));
_mixer->playStream(Audio::Mixer::kPlainSoundType, &_mixerSoundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
return 0;
@@ -1617,13 +1626,17 @@ void MidiDriver_ADLIB::adlibWriteSecondary(byte reg, byte value) {
#endif
void MidiDriver_ADLIB::generateSamples(int16 *data, int len) {
- if (_opl->isStereo()) {
- len *= 2;
- }
- _opl->readBuffer(data, len);
+ // Dummy implementation until we no longer inherit from MidiDriver_Emulated
+}
+
+int MidiDriver_ADLIB::readBuffer(int16 *data, const int numSamples) {
+ return _opl->readBuffer(data, numSamples);
}
void MidiDriver_ADLIB::onTimer() {
+ if (_adlibTimerProc)
+ (*_adlibTimerProc)(_adlibTimerParam);
+
_timerCounter += _timerIncrease;
while (_timerCounter >= _timerThreshold) {
_timerCounter -= _timerThreshold;
@@ -1655,6 +1668,11 @@ void MidiDriver_ADLIB::onTimer() {
}
}
+void MidiDriver_ADLIB::setTimerCallback(void *timerParam, Common::TimerManager::TimerProc timerProc) {
+ _adlibTimerProc = timerProc;
+ _adlibTimerParam = timerParam;
+}
+
void MidiDriver_ADLIB::mcOff(AdLibVoice *voice) {
AdLibVoice *tmp;