From 64d33fe4054c31d2d22e251293058780ec8fbf98 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 9 Oct 2011 20:54:18 +0000 Subject: Fix memory errors in Jack2 caused by jack creating several threads. This is not really correct since Ingen assumes any jack created thread is the process thread. Probably not harmful, though it would certainly be nice to know (in code) what the role and properties of these other threads are... git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3539 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/JackDriver.cpp | 20 ++++++-------------- src/server/JackDriver.hpp | 29 +++++++++++++++-------------- 2 files changed, 21 insertions(+), 28 deletions(-) (limited to 'src/server') diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index 246d6fdb..2e2f7c0c 100644 --- a/src/server/JackDriver.cpp +++ b/src/server/JackDriver.cpp @@ -186,7 +186,6 @@ JackPort::post_process(ProcessContext& context) JackDriver::JackDriver(Engine& engine) : _engine(engine) - , _jack_thread(NULL) , _sem(0) , _flag(0) , _client(NULL) @@ -206,8 +205,6 @@ JackDriver::~JackDriver() if (_client) jack_client_close(_client); - - delete _jack_thread; } bool @@ -324,8 +321,7 @@ JackDriver::deactivate() _client = NULL; } - delete _jack_thread; - _jack_thread = NULL; + _jack_threads.clear(); LOG(info) << "Deactivated Jack client" << endl; } @@ -487,13 +483,10 @@ JackDriver::_process_cb(jack_nframes_t nframes) void JackDriver::_thread_init_cb() { - if (_jack_thread) { - delete _jack_thread; - } - - _jack_thread = &Thread::get(); - _jack_thread->set_name("Jack"); - _jack_thread->set_context(THREAD_PROCESS); + Raul::Thread* thread = &Thread::get(); + thread->set_name("Jack"); + thread->set_context(THREAD_PROCESS); + _jack_threads.push_back(SharedPtr(thread)); } void @@ -501,8 +494,7 @@ JackDriver::_shutdown_cb() { LOG(info) << "Jack shutdown. Exiting." << endl; _is_activated = false; - delete _jack_thread; - _jack_thread = NULL; + _jack_threads.clear(); _client = NULL; } diff --git a/src/server/JackDriver.hpp b/src/server/JackDriver.hpp index 5439c95c..d39319ba 100644 --- a/src/server/JackDriver.hpp +++ b/src/server/JackDriver.hpp @@ -20,6 +20,7 @@ #include "ingen-config.h" +#include #include #include @@ -161,20 +162,20 @@ private: void _session_cb(jack_session_event_t* event); #endif - Engine& _engine; - Raul::Thread* _jack_thread; - Raul::Semaphore _sem; - Raul::AtomicInt _flag; - jack_client_t* _client; - jack_nframes_t _block_length; - jack_nframes_t _sample_rate; - uint32_t _midi_event_type; - bool _is_activated; - jack_position_t _position; - jack_transport_state_t _transport_state; - Raul::List _ports; - ProcessContext _process_context; - PatchImpl* _root_patch; + Engine& _engine; + std::list< SharedPtr > _jack_threads; + Raul::Semaphore _sem; + Raul::AtomicInt _flag; + jack_client_t* _client; + jack_nframes_t _block_length; + jack_nframes_t _sample_rate; + uint32_t _midi_event_type; + bool _is_activated; + jack_position_t _position; + jack_transport_state_t _transport_state; + Raul::List _ports; + ProcessContext _process_context; + PatchImpl* _root_patch; }; } // namespace Server -- cgit v1.2.1