Skip to content

Commit

Permalink
Fix minor glitches with sample tracks (LMMS#4666)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
PhysSong authored Oct 29, 2018
1 parent 0a49f5b commit 8fd15c5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
5 changes: 3 additions & 2 deletions include/Mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 6 additions & 4 deletions src/core/Mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ void Mixer::changeQuality( const struct qualitySettings & _qs )



void Mixer::setAudioDevice( AudioDevice * _dev )
void Mixer::setAudioDevice( AudioDevice * _dev,
bool startNow )
{
stopProcessing();

Expand All @@ -592,15 +593,16 @@ void Mixer::setAudioDevice( AudioDevice * _dev )

emit sampleRateChanged();

startProcessing();
if (startNow) {startProcessing();}
}




void Mixer::setAudioDevice( AudioDevice * _dev,
const struct qualitySettings & _qs,
bool _needs_fifo )
bool _needs_fifo,
bool startNow )
{
// don't delete the audio-device
stopProcessing();
Expand All @@ -621,7 +623,7 @@ void Mixer::setAudioDevice( AudioDevice * _dev,
emit qualitySettingsChanged();
emit sampleRateChanged();

startProcessing( _needs_fifo );
if (startNow) {startProcessing( _needs_fifo );}
}


Expand Down
5 changes: 4 additions & 1 deletion src/core/ProjectRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/core/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/tracks/SampleTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() ) );

Expand Down

0 comments on commit 8fd15c5

Please sign in to comment.