From 49bb15637f243a28c5c41178901efeb773b532f2 Mon Sep 17 00:00:00 2001 From: Roman Pudashkin Date: Mon, 10 Jun 2024 16:43:03 +0300 Subject: [PATCH] fix #23112: don't call shared_from_this() in MuseSamplerWrapper Because it locks the pointer, EventAudioSource loses ownership of it and can no longer destroy it --- src/framework/musesampler/internal/imusesamplertracks.h | 2 -- src/framework/musesampler/internal/musesamplersequencer.cpp | 2 +- src/framework/musesampler/internal/musesamplersequencer.h | 4 ++-- src/framework/musesampler/internal/musesamplerwrapper.cpp | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/framework/musesampler/internal/imusesamplertracks.h b/src/framework/musesampler/internal/imusesamplertracks.h index 0a7ba029284da..5b654865a2b39 100644 --- a/src/framework/musesampler/internal/imusesamplertracks.h +++ b/src/framework/musesampler/internal/imusesamplertracks.h @@ -34,8 +34,6 @@ class IMuseSamplerTracks virtual const TrackList& allTracks() const = 0; virtual ms_Track addTrack() = 0; }; - -using IMuseSamplerTracksPtr = std::shared_ptr; } #endif // MU_MUSESAMPLER_IMUSESAMPLERTRACKS_H diff --git a/src/framework/musesampler/internal/musesamplersequencer.cpp b/src/framework/musesampler/internal/musesamplersequencer.cpp index 9be4c9e28ab7d..c88a3bd2c6842 100644 --- a/src/framework/musesampler/internal/musesamplersequencer.cpp +++ b/src/framework/musesampler/internal/musesamplersequencer.cpp @@ -100,7 +100,7 @@ static const std::unordered_map NOTEHEAD_TYP { mpe::ArticulationType::SlashedForwardsNote, ms_NoteHead_SlashLeftFilled }, }; -void MuseSamplerSequencer::init(MuseSamplerLibHandlerPtr samplerLib, ms_MuseSampler sampler, IMuseSamplerTracksPtr tracks, +void MuseSamplerSequencer::init(MuseSamplerLibHandlerPtr samplerLib, ms_MuseSampler sampler, IMuseSamplerTracks* tracks, std::string&& defaultPresetCode) { m_samplerLib = samplerLib; diff --git a/src/framework/musesampler/internal/musesamplersequencer.h b/src/framework/musesampler/internal/musesamplersequencer.h index ccb3166a70823..8b0fa73212ea1 100644 --- a/src/framework/musesampler/internal/musesamplersequencer.h +++ b/src/framework/musesampler/internal/musesamplersequencer.h @@ -64,7 +64,7 @@ namespace mu::musesampler { class MuseSamplerSequencer : public audio::AbstractEventSequencer { public: - void init(MuseSamplerLibHandlerPtr samplerLib, ms_MuseSampler sampler, IMuseSamplerTracksPtr tracks, std::string&& defaultPresetCode); + void init(MuseSamplerLibHandlerPtr samplerLib, ms_MuseSampler sampler, IMuseSamplerTracks* tracks, std::string&& defaultPresetCode); void updateOffStreamEvents(const mpe::PlaybackEventsMap& events, const mpe::PlaybackParamMap& params) override; void updateMainStreamEvents(const mpe::PlaybackEventsMap& events, const mpe::DynamicLevelMap& dynamics, @@ -98,7 +98,7 @@ class MuseSamplerSequencer : public audio::AbstractEventSequencer m_layerIdxToTrackIdx; diff --git a/src/framework/musesampler/internal/musesamplerwrapper.cpp b/src/framework/musesampler/internal/musesamplerwrapper.cpp index 0dbd37ed0311a..fe845b9f4d347 100644 --- a/src/framework/musesampler/internal/musesamplerwrapper.cpp +++ b/src/framework/musesampler/internal/musesamplerwrapper.cpp @@ -175,7 +175,7 @@ void MuseSamplerWrapper::setupSound(const mpe::PlaybackSetupData& setupData) } } - m_sequencer.init(m_samplerLib, m_sampler, shared_from_this(), resolveDefaultPresetCode(m_instrument)); + m_sequencer.init(m_samplerLib, m_sampler, this, resolveDefaultPresetCode(m_instrument)); } void MuseSamplerWrapper::setupEvents(const mpe::PlaybackData& playbackData)