From 4136dbb74408a04178d4dcfb210a0d7b1cca1ac6 Mon Sep 17 00:00:00 2001 From: "Raine M. Ekman" Date: Wed, 25 Mar 2015 21:16:55 +0200 Subject: [PATCH] SF2 Player, OpulenZ: addPlayHandle moved to end of constructor. Should mean smaller risk of race conditions and less need for mutexes. --- plugins/opl2/opl2instrument.cpp | 7 ++++--- plugins/sf2_player/sf2_player.cpp | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/opl2/opl2instrument.cpp b/plugins/opl2/opl2instrument.cpp index b84edf0b9..8e95d83a6 100644 --- a/plugins/opl2/opl2instrument.cpp +++ b/plugins/opl2/opl2instrument.cpp @@ -141,9 +141,6 @@ opl2instrument::opl2instrument( InstrumentTrack * _instrument_track ) : vib_depth_mdl(false, this, tr( "Vibrato Depth" ) ), trem_depth_mdl(false, this, tr( "Tremolo Depth" ) ) { - // Connect the plugin to the mixer... - InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrument_track ); - Engine::mixer()->addPlayHandle( iph ); // Create an emulator - samplerate, 16 bit, mono emulatorMutex.lock(); @@ -220,6 +217,10 @@ opl2instrument::opl2instrument( InstrumentTrack * _instrument_track ) : MOD_CON( fm_mdl ); MOD_CON( vib_depth_mdl ); MOD_CON( trem_depth_mdl ); + + // Connect the plugin to the mixer... + InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrument_track ); + Engine::mixer()->addPlayHandle( iph ); } opl2instrument::~opl2instrument() { diff --git a/plugins/sf2_player/sf2_player.cpp b/plugins/sf2_player/sf2_player.cpp index f2acd2f07..e94c40b6e 100644 --- a/plugins/sf2_player/sf2_player.cpp +++ b/plugins/sf2_player/sf2_player.cpp @@ -118,9 +118,6 @@ sf2Instrument::sf2Instrument( InstrumentTrack * _instrument_track ) : // everytime we load a new soundfont. m_synth = new_fluid_synth( m_settings ); - InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrument_track ); - Engine::mixer()->addPlayHandle( iph ); - loadFile( ConfigManager::inst()->defaultSoundfont() ); updateSampleRate(); @@ -152,6 +149,8 @@ sf2Instrument::sf2Instrument( InstrumentTrack * _instrument_track ) : connect( &m_chorusSpeed, SIGNAL( dataChanged() ), this, SLOT( updateChorus() ) ); connect( &m_chorusDepth, SIGNAL( dataChanged() ), this, SLOT( updateChorus() ) ); + InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrument_track ); + Engine::mixer()->addPlayHandle( iph ); }