gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit fffacff3c4515280663597485f5422e264891398
parent 4d2f3d7e5dfc2fcd6858e5d220a42a0407f7a971
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Tue, 30 Jul 2024 16:53:45 +0200

implement shutdown

Diffstat:
Msource/nord/n2x/n2xLib/n2xdsp.cpp | 8++++++++
Msource/nord/n2x/n2xLib/n2xdsp.h | 2++
Msource/nord/n2x/n2xLib/n2xhardware.cpp | 21+++++++++++++++++++--
3 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/source/nord/n2x/n2xLib/n2xdsp.cpp b/source/nord/n2x/n2xLib/n2xdsp.cpp @@ -139,6 +139,14 @@ namespace n2x }); } + void DSP::terminate() + { + for(uint32_t i=0; i<32768; ++i) + m_triggerInterruptDone.notify(); + + m_thread.reset(); + } + void DSP::onUCRxEmpty(const bool _needMoreData) { if(_needMoreData) diff --git a/source/nord/n2x/n2xLib/n2xdsp.h b/source/nord/n2x/n2xLib/n2xdsp.h @@ -41,6 +41,8 @@ namespace n2x dsp56k::DSPThread& getDSPThread() const { return *m_thread; } auto& getHaltDSP() { return m_haltDSP; } + void terminate(); + private: void onUCRxEmpty(bool _needMoreData); void hdiTransferUCtoDSP(uint32_t _word); diff --git a/source/nord/n2x/n2xLib/n2xhardware.cpp b/source/nord/n2x/n2xLib/n2xhardware.cpp @@ -36,8 +36,25 @@ namespace n2x Hardware::~Hardware() { m_destroy = true; - m_dspA.dsp().terminate(); - m_dspB.dsp().terminate(); + + // showdown DSP A first, it waits for space to push to DSP B + for(uint32_t i=0; i<dsp56k::Audio::RingBufferSize * 2; ++i) + m_semDspAtoB.notify(); + m_dspA.terminate(); + + // shutdown DSP B next, waits for ESAI rate limiting + m_esaiFrameIndex = 0; + m_maxEsaiCallbacks = std::numeric_limits<uint32_t>::max(); + m_esaiLatency = 0; + for(uint32_t i=0; i<dsp56k::Audio::RingBufferSize * 2; ++i) + m_haltDSPcv.notify_all(); + m_dspB.terminate(); + + // Now shutdown UC, waits for ESAI to sync to DSPs + m_esaiFrameIndex = 1; + m_lastEsaiFrameIndex = 0; + for(uint32_t i=0; i<dsp56k::Audio::RingBufferSize * 2; ++i) + m_esaiFrameAddedCv.notify_all(); m_ucThread->join(); }