projects
/
ardour.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
DummyBackend: fix midi event mux+sorting
[ardour.git]
/
libs
/
ardour
/
graph.cc
diff --git
a/libs/ardour/graph.cc
b/libs/ardour/graph.cc
index b37de547cdf3e32617cdb265460c26c2d71af6bd..3e878533193afcada7f3d5d9f0bcb3958c890c2d 100644
(file)
--- a/
libs/ardour/graph.cc
+++ b/
libs/ardour/graph.cc
@@
-22,6
+22,7
@@
#include "pbd/compose.h"
#include "pbd/debug_rt_alloc.h"
#include "pbd/compose.h"
#include "pbd/debug_rt_alloc.h"
+#include "pbd/pthread_utils.h"
#include "ardour/debug.h"
#include "ardour/graph.h"
#include "ardour/debug.h"
#include "ardour/graph.h"
@@
-31,8
+32,6
@@
#include "ardour/process_thread.h"
#include "ardour/audioengine.h"
#include "ardour/process_thread.h"
#include "ardour/audioengine.h"
-#include <jack/thread.h>
-
#include "i18n.h"
using namespace ARDOUR;
#include "i18n.h"
using namespace ARDOUR;
@@
-96,29
+95,24
@@
Graph::reset_thread_list ()
number of threads.
*/
number of threads.
*/
- if (
_thread_list.size
() == num_threads) {
+ if (
AudioEngine::instance()->process_thread_count
() == num_threads) {
return;
}
Glib::Threads::Mutex::Lock lm (_session.engine().process_lock());
return;
}
Glib::Threads::Mutex::Lock lm (_session.engine().process_lock());
- AudioBackendNativeThread a_thread;
- if (
!_thread_list.empty()
) {
+ if (
AudioEngine::instance()->process_thread_count() != 0
) {
drop_threads ();
}
drop_threads ();
}
- if (AudioEngine::instance()->create_process_thread (boost::bind (&Graph::main_thread, this)
, &a_thread, 100000
) != 0) {
+ if (AudioEngine::instance()->create_process_thread (boost::bind (&Graph::main_thread, this)) != 0) {
throw failed_constructor ();
}
throw failed_constructor ();
}
- _thread_list.push_back (a_thread);
-
for (uint32_t i = 1; i < num_threads; ++i) {
for (uint32_t i = 1; i < num_threads; ++i) {
- if (AudioEngine::instance()->create_process_thread (boost::bind (&Graph::helper_thread, this)
, &a_thread, 100000) != 0
) {
+ if (AudioEngine::instance()->create_process_thread (boost::bind (&Graph::helper_thread, this)
)
) {
throw failed_constructor ();
}
throw failed_constructor ();
}
-
- _thread_list.push_back (a_thread);
}
}
}
}
@@
-140,17
+134,15
@@
Graph::drop_threads ()
{
_quit_threads = true;
{
_quit_threads = true;
- for (unsigned int i=0; i< _thread_list.size(); i++) {
+ uint32_t thread_count = AudioEngine::instance()->process_thread_count ();
+
+ for (unsigned int i=0; i < thread_count; i++) {
_execution_sem.signal ();
}
_callback_start_sem.signal ();
_execution_sem.signal ();
}
_callback_start_sem.signal ();
- for (list<AudioBackendNativeThread>::iterator i = _thread_list.begin(); i != _thread_list.end(); ++i) {
- AudioEngine::instance()->wait_for_process_thread_exit (*i);
- }
-
- _thread_list.clear ();
+ AudioEngine::instance()->join_process_threads ();
_execution_tokens = 0;
_execution_tokens = 0;
@@
-365,7
+357,7
@@
Graph::run_one()
/* update the number of threads that will still be sleeping */
_execution_tokens -= wakeup;
/* update the number of threads that will still be sleeping */
_execution_tokens -= wakeup;
- DEBUG_TRACE(DEBUG::ProcessThreads, string_compose ("%1 signals %2\n", pthread_
self
(), wakeup));
+ DEBUG_TRACE(DEBUG::ProcessThreads, string_compose ("%1 signals %2\n", pthread_
name
(), wakeup));
for (int i = 0; i < wakeup; i++) {
_execution_sem.signal ();
for (int i = 0; i < wakeup; i++) {
_execution_sem.signal ();
@@
-374,12
+366,12
@@
Graph::run_one()
while (to_run == 0) {
_execution_tokens += 1;
pthread_mutex_unlock (&_trigger_mutex);
while (to_run == 0) {
_execution_tokens += 1;
pthread_mutex_unlock (&_trigger_mutex);
- DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 goes to sleep\n", pthread_
self
()));
+ DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 goes to sleep\n", pthread_
name
()));
_execution_sem.wait ();
if (_quit_threads) {
return true;
}
_execution_sem.wait ();
if (_quit_threads) {
return true;
}
- DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 is awake\n", pthread_
self
()));
+ DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 is awake\n", pthread_
name
()));
pthread_mutex_lock (&_trigger_mutex);
if (_trigger_queue.size()) {
to_run = _trigger_queue.back();
pthread_mutex_lock (&_trigger_mutex);
if (_trigger_queue.size()) {
to_run = _trigger_queue.back();
@@
-391,7
+383,7
@@
Graph::run_one()
to_run->process();
to_run->finish (_current_chain);
to_run->process();
to_run->finish (_current_chain);
- DEBUG_TRACE(DEBUG::ProcessThreads, string_compose ("%1 has finished run_one()\n", pthread_
self
()));
+ DEBUG_TRACE(DEBUG::ProcessThreads, string_compose ("%1 has finished run_one()\n", pthread_
name
()));
return false;
}
return false;
}
@@
-559,7
+551,7
@@
Graph::process_one_route (Route* route)
assert (route);
assert (route);
- DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 runs route %2\n", pthread_
self
(), route->name()));
+ DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 runs route %2\n", pthread_
name
(), route->name()));
if (_process_silent) {
retval = route->silent_roll (_process_nframes, _process_start_frame, _process_end_frame, need_butler);
if (_process_silent) {
retval = route->silent_roll (_process_nframes, _process_start_frame, _process_end_frame, need_butler);
@@
-583,10
+575,5
@@
Graph::process_one_route (Route* route)
bool
Graph::in_process_thread () const
{
bool
Graph::in_process_thread () const
{
- for (list<AudioBackendNativeThread>::const_iterator i = _thread_list.begin (); i != _thread_list.end(); ++i) {
- if (self_thread_equal (*i)) {
- return true;
- }
- }
- return false;
+ return AudioEngine::instance()->in_process_thread ();
}
}