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 8fc27a471a0b0fba80e5089f0eb0a15eae829a39
parent 4451bcb60e74a8d0bb15ab87f32fa0a269d79b6f
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Wed, 31 Jul 2024 13:22:54 +0200

fix more shutdown issues

Diffstat:
Msource/nord/n2x/n2xLib/n2xdsp.cpp | 2+-
Msource/nord/n2x/n2xLib/n2xhardware.cpp | 22++++++++++++++--------
2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/source/nord/n2x/n2xLib/n2xdsp.cpp b/source/nord/n2x/n2xLib/n2xdsp.cpp @@ -144,7 +144,7 @@ namespace n2x for(uint32_t i=0; i<32768; ++i) m_triggerInterruptDone.notify(); - m_thread.reset(); + m_thread->terminate(); } void DSP::onUCRxEmpty(const bool _needMoreData) diff --git a/source/nord/n2x/n2xLib/n2xhardware.cpp b/source/nord/n2x/n2xLib/n2xhardware.cpp @@ -36,25 +36,31 @@ namespace n2x Hardware::~Hardware() { m_destroy = true; + m_dspA.terminate(); + m_dspB.terminate(); + + constexpr auto notifyCount = dsp56k::Audio::RingBufferSize * 2; - // showdown DSP A first, it waits for space to push to DSP B - for(uint32_t i=0; i<dsp56k::Audio::RingBufferSize * 2; ++i) + // DSP A waits for space to push to DSP B + for(uint32_t i=0; i<notifyCount; ++i) m_semDspAtoB.notify(); - m_dspA.terminate(); - // shutdown DSP B next, waits for ESAI rate limiting + // DSP B 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) + for(uint32_t i=0; i<notifyCount; ++i) m_haltDSPcv.notify_all(); - m_dspB.terminate(); - // Now shutdown UC, waits for ESAI to sync to DSPs + // UC waits for ESAI to sync to DSPs and on HDI to push data m_esaiFrameIndex = 1; m_lastEsaiFrameIndex = 0; - for(uint32_t i=0; i<dsp56k::Audio::RingBufferSize * 2; ++i) + for(uint32_t i=0; i<notifyCount; ++i) m_esaiFrameAddedCv.notify_all(); + while(m_dspA.getPeriph().getHDI08().hasTX()) + m_dspA.getPeriph().getHDI08().readTX(); + while(m_dspB.getPeriph().getHDI08().hasTX()) + m_dspB.getPeriph().getHDI08().readTX(); m_ucThread->join(); }