From 6e5650c50a7f465954f4b984132d9beec9272dd7 Mon Sep 17 00:00:00 2001 From: Johannes Lorenz <1042576+JohannesLorenz@users.noreply.github.com> Date: Fri, 7 Jun 2019 18:28:11 +0200 Subject: [PATCH] Fixes #4996: Fix metadata when exporting multiple tracks (#5005) Co-Authored-By: Hyunjin Song --- include/Mixer.h | 4 ++++ src/core/Mixer.cpp | 46 +++++++++++++++++++++++++--------------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/include/Mixer.h b/include/Mixer.h index 757a08d49..79fbf7db3 100644 --- a/include/Mixer.h +++ b/include/Mixer.h @@ -171,7 +171,10 @@ public: return m_audioDevStartFailed; } + //! Set new audio device. Old device will be deleted, + //! unless it's stored using storeAudioDevice void setAudioDevice( AudioDevice * _dev , bool startNow ); + //! See overloaded function void setAudioDevice( AudioDevice * _dev, const struct qualitySettings & _qs, bool _needs_fifo, @@ -396,6 +399,7 @@ private: bool m_isProcessing; // audio device stuff + void doSetAudioDevice( AudioDevice *_dev ); AudioDevice * m_audioDev; AudioDevice * m_oldAudioDev; QString m_audioDevName; diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index c87305641..ac1aa2564 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -575,21 +575,35 @@ void Mixer::changeQuality( const struct qualitySettings & _qs ) -void Mixer::setAudioDevice( AudioDevice * _dev, - bool startNow ) +void Mixer::doSetAudioDevice( AudioDevice * _dev ) { - stopProcessing(); + // TODO: Use shared_ptr here in the future. + // Currently, this is safe, because this is only called by + // ProjectRenderer, and after ProjectRenderer calls this function, + // it does not access the old device anymore. + if( m_audioDev != m_oldAudioDev ) {delete m_audioDev;} - if( _dev == NULL ) + if( _dev ) + { + m_audioDev = _dev; + } + else { printf( "param _dev == NULL in Mixer::setAudioDevice(...). " "Trying any working audio-device\n" ); m_audioDev = tryAudioDevices(); } - else - { - m_audioDev = _dev; - } +} + + + + +void Mixer::setAudioDevice( AudioDevice * _dev, + bool startNow ) +{ + stopProcessing(); + + doSetAudioDevice( _dev ); emit sampleRateChanged(); @@ -599,26 +613,16 @@ void Mixer::setAudioDevice( AudioDevice * _dev, -void Mixer::setAudioDevice( AudioDevice * _dev, +void Mixer::setAudioDevice(AudioDevice * _dev, const struct qualitySettings & _qs, bool _needs_fifo, - bool startNow ) + bool startNow) { - // don't delete the audio-device stopProcessing(); m_qualitySettings = _qs; - if( _dev == NULL ) - { - printf( "param _dev == NULL in Mixer::setAudioDevice(...). " - "Trying any working audio-device\n" ); - m_audioDev = tryAudioDevices(); - } - else - { - m_audioDev = _dev; - } + doSetAudioDevice( _dev ); emit qualitySettingsChanged(); emit sampleRateChanged();