From 5b06eef1597ce701a4f6d16854be077b952d29f7 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 21 Apr 2015 00:43:43 -0400 Subject: AUDIO: Allow for changing the OPL timer rate --- audio/fmopl.cpp | 14 ++++++++++++++ audio/fmopl.h | 12 ++++++++++++ 2 files changed, 26 insertions(+) (limited to 'audio') diff --git a/audio/fmopl.cpp b/audio/fmopl.cpp index c9cb1040d6..07c5b44427 100644 --- a/audio/fmopl.cpp +++ b/audio/fmopl.cpp @@ -183,6 +183,14 @@ void OPL::stop() { _callback.reset(); } +void OPL::setCallbackFrequency(int timerFrequency) { + if (!isRunning()) + return; + + stopCallbacks(); + startCallbacks(timerFrequency); +} + bool OPL::_hasInstance = false; EmulatedOPL::EmulatedOPL() : @@ -249,4 +257,10 @@ void EmulatedOPL::stopCallbacks() { //g_system->getMixer()->stopHandle(*_handle); } +bool EmulatedOPL::isRunning() const { + // TODO + //return g_system->getMixer()->isSoundHandleActive(*_handle); + return true; +} + } // End of namespace OPL diff --git a/audio/fmopl.h b/audio/fmopl.h index 0e2e2b2dda..243cd294e8 100644 --- a/audio/fmopl.h +++ b/audio/fmopl.h @@ -175,6 +175,17 @@ public: */ void stop(); + /** + * Is the OPL running? + */ + virtual bool isRunning() const = 0; + + /** + * Change the callback frequency. This has no effect if start() + * has not already been called. + */ + void setCallbackFrequency(int timerFrequency); + enum { /** * The default callback frequency that start() uses @@ -206,6 +217,7 @@ public: // OPL API int readBuffer(int16 *buffer, const int numSamples); + bool isRunning() const; int getRate() const; -- cgit v1.2.3