From 014ba4fb2d72bdc481c2ba76bd53901a39725b86 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 15 Jan 2007 21:36:22 +0000 Subject: Fix potential crash on module removal. Don't "pretend" to set Jack buffer size when change fails. git-svn-id: http://svn.drobilla.net/lad/patchage@260 a436a847-0d15-0410-975c-d299462d15a1 --- src/JackDriver.cpp | 18 ++++++++++++++---- src/JackDriver.h | 2 +- src/Patchage.cpp | 3 ++- src/PatchageModule.h | 1 - 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index ddb6744..77625bc 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -459,14 +459,24 @@ JackDriver::reset_xruns() } -void +bool JackDriver::set_buffer_size(jack_nframes_t size) { - if (buffer_size() == size) - return; + if (buffer_size() == size) { + return true; + } + + if (!m_client) { + m_buffer_size = size; + return true; + } - if (m_client && jack_set_buffer_size(m_client, size)) + if (jack_set_buffer_size(m_client, size)) { m_app->status_message("[JACK] ERROR: Unable to set buffer size"); + return false; + } else { + return true; + } } void diff --git a/src/JackDriver.h b/src/JackDriver.h index c37970c..7acbad8 100644 --- a/src/JackDriver.h +++ b/src/JackDriver.h @@ -76,7 +76,7 @@ public: jack_client_t* client() { return m_client; } jack_nframes_t buffer_size(); - void set_buffer_size(jack_nframes_t size); + bool set_buffer_size(jack_nframes_t size); inline float sample_rate() { return jack_get_sample_rate(m_client); } diff --git a/src/Patchage.cpp b/src/Patchage.cpp index f60bdef..61a9abd 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -712,7 +712,8 @@ Patchage::buffer_size_changed() //cerr << "BS Changed: " << selected << ": " << buffer_size << endl; - m_jack_driver->set_buffer_size(buffer_size); + if ( ! m_jack_driver->set_buffer_size(buffer_size)) + update_toolbar(); // reset combo box to actual value } } diff --git a/src/PatchageModule.h b/src/PatchageModule.h index e047c52..cb490ad 100644 --- a/src/PatchageModule.h +++ b/src/PatchageModule.h @@ -14,7 +14,6 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - #ifndef PATCHAGEMODULE_H #define PATCHAGEMODULE_H -- cgit v1.2.1