From 4e27b459e2ea2f50255de0f785be293278bc6df3 Mon Sep 17 00:00:00 2001 From: Hyunjin Song Date: Tue, 9 Oct 2018 15:51:57 +0900 Subject: [PATCH] Fix minor glitches with sample tracks Switches some signal-slot connections to Qt::DirectConnection. Now LMMS can handle loop points correctly and export samples without glitches. Also tweaks some Mixer-related code to avoid related deadlocks on export. --- include/Mixer.h | 5 +++-- src/core/Mixer.cpp | 10 ++++++---- src/core/ProjectRenderer.cpp | 5 ++++- src/core/Song.cpp | 4 +--- src/tracks/SampleTrack.cpp | 9 ++++++--- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/include/Mixer.h b/include/Mixer.h index 3063b0f2ba9..757a08d4991 100644 --- a/include/Mixer.h +++ b/include/Mixer.h @@ -171,10 +171,11 @@ class EXPORT Mixer : public QObject return m_audioDevStartFailed; } - void setAudioDevice( AudioDevice * _dev ); + void setAudioDevice( AudioDevice * _dev , bool startNow ); void setAudioDevice( AudioDevice * _dev, const struct qualitySettings & _qs, - bool _needs_fifo ); + bool _needs_fifo, + bool startNow ); void storeAudioDevice(); void restoreAudioDevice(); inline AudioDevice * audioDev() diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index 67736742d39..fae7b35dba5 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -575,7 +575,8 @@ void Mixer::changeQuality( const struct qualitySettings & _qs ) -void Mixer::setAudioDevice( AudioDevice * _dev ) +void Mixer::setAudioDevice( AudioDevice * _dev, + bool startNow ) { stopProcessing(); @@ -592,7 +593,7 @@ void Mixer::setAudioDevice( AudioDevice * _dev ) emit sampleRateChanged(); - startProcessing(); + if (startNow) {startProcessing();} } @@ -600,7 +601,8 @@ void Mixer::setAudioDevice( AudioDevice * _dev ) void Mixer::setAudioDevice( AudioDevice * _dev, const struct qualitySettings & _qs, - bool _needs_fifo ) + bool _needs_fifo, + bool startNow ) { // don't delete the audio-device stopProcessing(); @@ -621,7 +623,7 @@ void Mixer::setAudioDevice( AudioDevice * _dev, emit qualitySettingsChanged(); emit sampleRateChanged(); - startProcessing( _needs_fifo ); + if (startNow) {startProcessing( _needs_fifo );} } diff --git a/src/core/ProjectRenderer.cpp b/src/core/ProjectRenderer.cpp index 3e3004db798..95ed1bd8dc4 100644 --- a/src/core/ProjectRenderer.cpp +++ b/src/core/ProjectRenderer.cpp @@ -146,7 +146,7 @@ void ProjectRenderer::startProcessing() // make slots connected to sampleRateChanged()-signals being // called immediately Engine::mixer()->setAudioDevice( m_fileDev, - m_qualitySettings, false ); + m_qualitySettings, false, false ); start( #ifndef LMMS_BUILD_WIN32 @@ -185,6 +185,9 @@ void ProjectRenderer::run() tick_t endTick = exportEndpoints.second.getTicks(); tick_t lengthTicks = endTick - startTick; + // Now start processing + Engine::mixer()->startProcessing(false); + // Continually track and emit progress percentage to listeners while( exportPos.getTicks() < endTick && Engine::getSong()->isExporting() == true diff --git a/src/core/Song.cpp b/src/core/Song.cpp index 1ebc684c196..f715c83192a 100644 --- a/src/core/Song.cpp +++ b/src/core/Song.cpp @@ -356,9 +356,7 @@ void Song::processNextBuffer() m_vstSyncController.setAbsolutePosition( ticks ); m_vstSyncController.setPlaybackJumped( true ); - } - else if( m_playPos[m_playMode] == tl->loopEnd() - 1 ) - { + emit updateSampleTracks(); } } diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index 63efa4d26fc..fd9a92a234e 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -72,13 +72,16 @@ SampleTCO::SampleTCO( Track * _track ) : connect( timeLine, SIGNAL( positionMarkerMoved() ), this, SLOT( playbackPositionChanged() ) ); } //playbutton clicked or space key / on Export Song set isPlaying to false - connect( Engine::getSong(), SIGNAL( playbackStateChanged() ), this, SLOT( playbackPositionChanged() ) ); + connect( Engine::getSong(), SIGNAL( playbackStateChanged() ), + this, SLOT( playbackPositionChanged() ), Qt::DirectConnection ); //care about loops - connect( Engine::getSong(), SIGNAL( updateSampleTracks() ), this, SLOT( playbackPositionChanged() ) ); + connect( Engine::getSong(), SIGNAL( updateSampleTracks() ), + this, SLOT( playbackPositionChanged() ), Qt::DirectConnection ); //care about mute TCOs connect( this, SIGNAL( dataChanged() ), this, SLOT( playbackPositionChanged() ) ); //care about mute track - connect( getTrack()->getMutedModel(), SIGNAL( dataChanged() ),this, SLOT( playbackPositionChanged() ) ); + connect( getTrack()->getMutedModel(), SIGNAL( dataChanged() ), + this, SLOT( playbackPositionChanged() ), Qt::DirectConnection ); //care about TCO position connect( this, SIGNAL( positionChanged() ), this, SLOT( updateTrackTcos() ) );