summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-10-09 20:54:18 +0000
committerDavid Robillard <d@drobilla.net>2011-10-09 20:54:18 +0000
commit64d33fe4054c31d2d22e251293058780ec8fbf98 (patch)
tree1d9f7748be001b48a0b0a139314930890c9fb8a0
parentca12acb6cb9b1f7618b88f2c95efd8ab275e1f57 (diff)
downloadingen-64d33fe4054c31d2d22e251293058780ec8fbf98.tar.gz
ingen-64d33fe4054c31d2d22e251293058780ec8fbf98.tar.bz2
ingen-64d33fe4054c31d2d22e251293058780ec8fbf98.zip
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
-rw-r--r--src/server/JackDriver.cpp20
-rw-r--r--src/server/JackDriver.hpp29
2 files changed, 21 insertions, 28 deletions
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<Raul::Thread>(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 <list>
#include <string>
#include <jack/jack.h>
@@ -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<JackPort*> _ports;
- ProcessContext _process_context;
- PatchImpl* _root_patch;
+ Engine& _engine;
+ std::list< SharedPtr<Raul::Thread> > _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<JackPort*> _ports;
+ ProcessContext _process_context;
+ PatchImpl* _root_patch;
};
} // namespace Server