From b9307ef1a4420ef61aa35c747d2f3f11875d3b72 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Fri, 3 Apr 2015 01:38:14 -0400 Subject: AUDIO: Introduce a callback to the OPL code Currently unused, but ready to be hooked up to various classes using it. --- audio/softsynth/opl/dosbox.cpp | 6 +++++- audio/softsynth/opl/dosbox.h | 6 ++++-- audio/softsynth/opl/mame.cpp | 11 +++++++++-- audio/softsynth/opl/mame.h | 6 ++++-- 4 files changed, 22 insertions(+), 7 deletions(-) (limited to 'audio/softsynth') diff --git a/audio/softsynth/opl/dosbox.cpp b/audio/softsynth/opl/dosbox.cpp index bcc73a9b9e..f6f17c5e3c 100644 --- a/audio/softsynth/opl/dosbox.cpp +++ b/audio/softsynth/opl/dosbox.cpp @@ -153,6 +153,7 @@ OPL::~OPL() { } void OPL::free() { + stopCallbacks(); delete _emulator; _emulator = 0; } @@ -176,6 +177,9 @@ bool OPL::init() { _emulator->WriteReg(0x105, 1); } + // FIXME: Remove this once EmulatedOPL is actually controlling playback + start(0); + return true; } @@ -308,7 +312,7 @@ void OPL::dualWrite(uint8 index, uint8 reg, uint8 val) { _emulator->WriteReg(fullReg, val); } -void OPL::readBuffer(int16 *buffer, int length) { +void OPL::generateSamples(int16 *buffer, int length) { // For stereo OPL cards, we divide the sample count by 2, // to match stereo AudioStream behavior. if (_type != Config::kOpl2) diff --git a/audio/softsynth/opl/dosbox.h b/audio/softsynth/opl/dosbox.h index d3df6ba6ed..c52f06761a 100644 --- a/audio/softsynth/opl/dosbox.h +++ b/audio/softsynth/opl/dosbox.h @@ -69,7 +69,7 @@ namespace DBOPL { struct Chip; } // end of namespace DBOPL -class OPL : public ::OPL::OPL { +class OPL : public ::OPL::EmulatedOPL { private: Config::OplType _type; uint _rate; @@ -95,8 +95,10 @@ public: void writeReg(int r, int v); - void readBuffer(int16 *buffer, int length); bool isStereo() const { return _type != Config::kOpl2; } + +protected: + void generateSamples(int16 *buffer, int length); }; } // End of namespace DOSBox diff --git a/audio/softsynth/opl/mame.cpp b/audio/softsynth/opl/mame.cpp index 1a5810f6c8..fe23d300fa 100644 --- a/audio/softsynth/opl/mame.cpp +++ b/audio/softsynth/opl/mame.cpp @@ -48,15 +48,22 @@ namespace OPL { namespace MAME { OPL::~OPL() { + stopCallbacks(); MAME::OPLDestroy(_opl); _opl = 0; } bool OPL::init() { - if (_opl) + if (_opl) { + stopCallbacks(); MAME::OPLDestroy(_opl); + } _opl = MAME::makeAdLibOPL(g_system->getMixer()->getOutputRate()); + + // FIXME: Remove this once EmulatedOPL is actually controlling playback + start(0); + return (_opl != 0); } @@ -76,7 +83,7 @@ void OPL::writeReg(int r, int v) { MAME::OPLWriteReg(_opl, r, v); } -void OPL::readBuffer(int16 *buffer, int length) { +void OPL::generateSamples(int16 *buffer, int length) { MAME::YM3812UpdateOne(_opl, buffer, length); } diff --git a/audio/softsynth/opl/mame.h b/audio/softsynth/opl/mame.h index 080cc6d171..67d80bb193 100644 --- a/audio/softsynth/opl/mame.h +++ b/audio/softsynth/opl/mame.h @@ -174,7 +174,7 @@ void YM3812UpdateOne(FM_OPL *OPL, int16 *buffer, int length); FM_OPL *makeAdLibOPL(int rate); // OPL API implementation -class OPL : public ::OPL::OPL { +class OPL : public ::OPL::EmulatedOPL { private: FM_OPL *_opl; public: @@ -189,8 +189,10 @@ public: void writeReg(int r, int v); - void readBuffer(int16 *buffer, int length); bool isStereo() const { return false; } + +protected: + void generateSamples(int16 *buffer, int length); }; } // End of namespace MAME -- cgit v1.2.3