diff options
author | Carl Hetherington <carl@carlh.net> | 2011-01-19 21:36:38 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-01-19 21:36:38 +0000 |
commit | 6636a65c100869e1d479cac97769fbaede7746c7 (patch) | |
tree | aee411a92e2453712fb699893d4313ebd4ef7fca /libs | |
parent | 19d1132afb8d1877f7b3e7c1ff27a11503f1b56d (diff) |
Configure option to abort when malloc is called in the process thread.
git-svn-id: svn://localhost/ardour2/branches/3.0@8548 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/graph.h | 2 | ||||
-rw-r--r-- | libs/ardour/graph.cc | 31 | ||||
-rw-r--r-- | libs/pbd/wscript | 4 |
3 files changed, 34 insertions, 3 deletions
diff --git a/libs/ardour/ardour/graph.h b/libs/ardour/ardour/graph.h index 6893c08d9d..812bc5b86c 100644 --- a/libs/ardour/ardour/graph.h +++ b/libs/ardour/ardour/graph.h @@ -84,6 +84,8 @@ class Graph : public SessionHandleRef void clear_other_chain (); + bool in_process_thread () const; + protected: virtual void session_going_away (); diff --git a/libs/ardour/graph.cc b/libs/ardour/graph.cc index 0d3749aff0..7cddd522e1 100644 --- a/libs/ardour/graph.cc +++ b/libs/ardour/graph.cc @@ -22,6 +22,7 @@ #include "pbd/compose.h" #include "pbd/cpus.h" +#include "pbd/debug_rt_alloc.h" #include "ardour/debug.h" #include "ardour/graph.h" @@ -39,6 +40,17 @@ using namespace ARDOUR; using namespace PBD; using namespace std; +#ifdef DEBUG_RT_ALLOC +static Graph* graph = 0; +extern "C" { + +int alloc_allowed () +{ + return !graph->in_process_thread (); +} + +} +#endif Graph::Graph (Session & session) : SessionHandleRef (session) @@ -97,6 +109,11 @@ Graph::Graph (Session & session) _thread_list.push_back (a_thread); } } + +#ifdef DEBUG_RT_ALLOC + graph = this; + pbd_alloc_allowed = &::alloc_allowed; +#endif } void @@ -380,7 +397,7 @@ static void get_rt() void Graph::helper_thread() { - ProcessThread *pt = new ProcessThread; + ProcessThread* pt = new ProcessThread (); pt->get_buffers(); get_rt(); @@ -397,7 +414,7 @@ Graph::helper_thread() void Graph::main_thread() { - ProcessThread *pt = new ProcessThread; + ProcessThread* pt = new ProcessThread (); pt->get_buffers(); get_rt(); @@ -557,5 +574,13 @@ Graph::process_one_route (Route* route) } } +bool +Graph::in_process_thread () const +{ + list<pthread_t>::const_iterator i = _thread_list.begin (); + while (i != _thread_list.end() && *i != pthread_self ()) { + ++i; + } - + return i != _thread_list.end (); +} diff --git a/libs/pbd/wscript b/libs/pbd/wscript index b952b63753..69eafe4285 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -106,6 +106,10 @@ def build(bld): whitespace.cc xml++.cc ''' + + if bld.env['DEBUG_RT_ALLOC']: + obj.source += 'debug_rt_alloc.c' + obj.export_incdirs = ['.'] obj.includes = ['.'] obj.name = 'libpbd' |