From 0a9bf3708f2852165d5f9e888f375d8fe35619e3 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Tue, 15 Jun 2021 23:24:46 +0100 Subject: [PATCH] DS: Update the MaxMod callback manually --- backends/events/ds/ds-events.cpp | 3 +++ backends/mixer/maxmod/maxmod-mixer.cpp | 7 ++++++- backends/mixer/maxmod/maxmod-mixer.h | 5 +++++ backends/platform/ds/osystem_ds.cpp | 8 +++++--- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/backends/events/ds/ds-events.cpp b/backends/events/ds/ds-events.cpp index 4f2ee92f687..95bd038a84e 100644 --- a/backends/events/ds/ds-events.cpp +++ b/backends/events/ds/ds-events.cpp @@ -26,6 +26,9 @@ #include "backends/platform/ds/osystem_ds.h" bool DSEventSource::pollEvent(Common::Event &event) { + // Ensure the mixer and timers are updated frequently + g_system->delayMillis(0); + if (_eventQueue.empty()) { if (!_firstPoll) { _firstPoll = true; diff --git a/backends/mixer/maxmod/maxmod-mixer.cpp b/backends/mixer/maxmod/maxmod-mixer.cpp index 161274c75a7..e28d28f8345 100644 --- a/backends/mixer/maxmod/maxmod-mixer.cpp +++ b/backends/mixer/maxmod/maxmod-mixer.cpp @@ -70,7 +70,7 @@ void MaxModMixerManager::init() { _stream.callback = on_stream_request; _stream.format = MM_STREAM_16BIT_STEREO; _stream.timer = MM_TIMER2; - _stream.manual = 0; + _stream.manual = 1; mmStreamOpen( &_stream ); @@ -91,4 +91,9 @@ int MaxModMixerManager::resumeAudio() { return 0; } +void MaxModMixerManager::updateAudio() { + if (!_audioSuspended) + mmStreamUpdate(); +} + #endif diff --git a/backends/mixer/maxmod/maxmod-mixer.h b/backends/mixer/maxmod/maxmod-mixer.h index 774a007a010..0e6c78b2085 100644 --- a/backends/mixer/maxmod/maxmod-mixer.h +++ b/backends/mixer/maxmod/maxmod-mixer.h @@ -52,6 +52,11 @@ public: */ virtual int resumeAudio(); + /** + * Updates the audio system + */ + void updateAudio(); + protected: mm_stream _stream; int _freq, _bufSize; diff --git a/backends/platform/ds/osystem_ds.cpp b/backends/platform/ds/osystem_ds.cpp index ce96045db77..81d7722a328 100644 --- a/backends/platform/ds/osystem_ds.cpp +++ b/backends/platform/ds/osystem_ds.cpp @@ -85,7 +85,7 @@ void OSystem_DS::initBackend() { _timerManager = new DefaultTimerManager(); timerStart(0, ClockDivider_1, (u16)TIMER_FREQ(1000), timerTickHandler); - _mixerManager = new MaxModMixerManager(11025, 4096); + _mixerManager = new MaxModMixerManager(11025, 32768); _mixerManager->init(); BaseBackend::initBackend(); @@ -102,9 +102,11 @@ uint32 OSystem_DS::getMillis(bool skipRecord) { void OSystem_DS::delayMillis(uint msecs) { int st = getMillis(); - while (st + msecs >= getMillis()); - doTimerCallback(); + if (_mixerManager) + ((MaxModMixerManager *)_mixerManager)->updateAudio(); + + while (st + msecs >= getMillis()); } void OSystem_DS::doTimerCallback(int interval) {