From 7c9401e26675fb43d0c5d10abbff790a957d2a70 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sun, 10 May 2020 10:41:49 +0200 Subject: [PATCH] bug fix: fixed that Jamulus segfaults when jackd is restarted (Ticket #122, #127) --- ChangeLog | 3 +++ linux/sound.cpp | 23 +++++++++++++---------- linux/sound.h | 3 ++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index d9fa2a7c..fdd8fe30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,8 @@ - bug fix: for mono capture jack audio interface Jamulus complains it cannot make connections (Ticket #137) +- bug fix: fixed that Jamulus segfaults when jackd is restarted (Ticket #122, #127) + TODO WIP support internationalization @@ -30,6 +32,7 @@ TODO show mute state of others + 3.5.2 (2020-04-24) - use audio level meter bars for normal skin diff --git a/linux/sound.cpp b/linux/sound.cpp index 00f9a3e0..b55b550e 100755 --- a/linux/sound.cpp +++ b/linux/sound.cpp @@ -184,16 +184,20 @@ void CSound::Stop() int CSound::Init ( const int /* iNewPrefMonoBufferSize */ ) { - // try setting buffer size // TODO seems not to work! -> no audio after this operation! - // Doesn't this give an infinite loop? The set buffer size function will call our // registerd callback which calls "EmitReinitRequestSignal()". In that function // this CSound::Init() function is called... - //jack_set_buffer_size ( pJackClient, iNewPrefMonoBufferSize ); + // without a Jack server, Jamulus makes no sense to run, throw an error message + if ( bJackWasShutDown ) + { + throw CGenErr ( tr ( "The Jack server was shut down. This software " + "requires a Jack server to run. Try to restart the software to " + "solve the issue." ) ); + } // get actual buffer size iJACKBufferSizeMono = jack_get_buffer_size ( pJackClient ); @@ -321,7 +325,7 @@ int CSound::process ( jack_nframes_t nframes, void* arg ) return 0; // zero on success, non-zero on error } -int CSound::bufferSizeCallback ( jack_nframes_t, void *arg ) +int CSound::bufferSizeCallback ( jack_nframes_t, void* arg ) { CSound* pSound = static_cast ( arg ); @@ -330,12 +334,11 @@ int CSound::bufferSizeCallback ( jack_nframes_t, void *arg ) return 0; // zero on success, non-zero on error } -void CSound::shutdownCallback ( void* ) +void CSound::shutdownCallback ( void* arg ) { - // without a Jack server, our software makes no sense to run, throw - // error message - throw CGenErr ( tr ( "The Jack server was shut down. This software " - "requires a Jack server to run. Try to restart the software to " - "solve the issue." ) ); + CSound* pSound = static_cast ( arg ); + + pSound->bJackWasShutDown = true; + pSound->EmitReinitRequestSignal ( RS_ONLY_RESTART_AND_INIT ); } #endif // WITH_SOUND diff --git a/linux/sound.h b/linux/sound.h index bb753ee7..23e9bf59 100755 --- a/linux/sound.h +++ b/linux/sound.h @@ -66,7 +66,7 @@ public: const bool bNoAutoJackConnect, const QString& strJackClientName ) : CSoundBase ( "Jack", true, fpNewProcessCallback, arg, iCtrlMIDIChannel ), - iJACKBufferSizeMono ( 0 ) { OpenJack ( bNoAutoJackConnect, strJackClientName.toLocal8Bit().data() ); } + iJACKBufferSizeMono ( 0 ), bJackWasShutDown ( false ) { OpenJack ( bNoAutoJackConnect, strJackClientName.toLocal8Bit().data() ); } virtual ~CSound() { CloseJack(); } @@ -79,6 +79,7 @@ public: CVector vecsTmpAudioSndCrdStereo; int iJACKBufferSizeMono; int iJACKBufferSizeStero; + bool bJackWasShutDown; jack_port_t* input_port_left; jack_port_t* input_port_right;