From e317386c5cde5741a8279bf480240293720d6788 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 22 Jan 2012 12:28:49 +0000 Subject: For now, only use the multi-threaded process code if we are using >1 processor for DSP; this involves making the DSP use setting only take effect on a restart of Ardour. git-svn-id: svn://localhost/ardour2/branches/3.0@11302 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/graph.h | 2 -- libs/ardour/graph.cc | 23 +++-------------------- libs/ardour/session.cc | 19 ++++++++++++++----- libs/ardour/session_process.cc | 14 +++----------- 4 files changed, 20 insertions(+), 38 deletions(-) (limited to 'libs') diff --git a/libs/ardour/ardour/graph.h b/libs/ardour/ardour/graph.h index f1ebba698a..b735d69888 100644 --- a/libs/ardour/ardour/graph.h +++ b/libs/ardour/ardour/graph.h @@ -94,9 +94,7 @@ protected: private: std::list _thread_list; volatile bool _quit_threads; - PBD::ScopedConnection processor_usage_connection; - void parameter_changed (std::string); void reset_thread_list (); void drop_threads (); diff --git a/libs/ardour/graph.cc b/libs/ardour/graph.cc index 5b435884d4..c38106506e 100644 --- a/libs/ardour/graph.cc +++ b/libs/ardour/graph.cc @@ -77,28 +77,21 @@ Graph::Graph (Session & session) reset_thread_list (); - Config->ParameterChanged.connect_same_thread (processor_usage_connection, boost::bind (&Graph::parameter_changed, this, _1)); - #ifdef DEBUG_RT_ALLOC graph = this; pbd_alloc_allowed = &::alloc_allowed; #endif } -void -Graph::parameter_changed (std::string param) -{ - if (param == X_("processor-usage")) { - reset_thread_list (); - } -} - /** Set up threads for running the graph */ void Graph::reset_thread_list () { uint32_t num_threads = how_many_dsp_threads (); + /* For now, we shouldn't be using the graph code if we only have 1 DSP thread */ + assert (num_threads > 1); + /* don't bother doing anything here if we already have the right number of threads. */ @@ -114,16 +107,6 @@ Graph::reset_thread_list () drop_threads (); } -#if 0 - /* XXX this only makes sense when we can use just the AudioEngine thread - and still keep the graph current with the route list - */ - if (num_threads <= 1) { - /* no point creating 1 thread - the AudioEngine already gives us one - */ - return; - } -#endif if (AudioEngine::instance()->create_process_thread (boost::bind (&Graph::main_thread, this), &a_thread, 100000) == 0) { _thread_list.push_back (a_thread); } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 7ee854dc2d..f2343e1013 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -153,7 +153,6 @@ Session::Session (AudioEngine &eng, , _post_transport_work (0) , _send_timecode_update (false) , _all_route_group (new RouteGroup (*this, "all")) - , _process_graph (new Graph (*this)) , routes (new RouteList) , _total_free_4k_blocks (0) , _bundles (new BundleList) @@ -169,6 +168,13 @@ Session::Session (AudioEngine &eng, { _locations = new Locations (*this); + if (how_many_dsp_threads () > 1) { + /* For now, only create the graph if we are using >1 DSP threads, as + it is a bit slower than the old code with 1 thread. + */ + _process_graph.reset (new Graph (*this)); + } + playlists.reset (new SessionPlaylists); _all_route_group->set_active (true, this); @@ -1384,8 +1390,6 @@ Session::resort_routes () /* writer goes out of scope and forces update */ } - //_process_graph->dump(1); - #ifndef NDEBUG boost::shared_ptr rl = routes.reader (); for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { @@ -1460,7 +1464,10 @@ Session::resort_routes_using (boost::shared_ptr r) Note: the process graph rechain does not require a topologically-sorted list, but hey ho. */ - _process_graph->rechain (sorted_routes, edges); + if (_process_graph) { + _process_graph->rechain (sorted_routes, edges); + } + _current_route_graph = edges; /* Complete the building of the routes' lists of what directly @@ -2315,7 +2322,9 @@ Session::remove_route (boost::shared_ptr route) */ resort_routes (); - _process_graph->clear_other_chain (); + if (_process_graph) { + _process_graph->clear_other_chain (); + } /* get rid of it from the dead wood collection in the route list manager */ diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index 80f922117d..897b58ec8e 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -115,7 +115,7 @@ Session::no_roll (pframes_t nframes) _click_io->silence (nframes); } - if (1 || _process_graph->threads_in_use() > 0) { + if (_process_graph) { DEBUG_TRACE(DEBUG::ProcessThreads,"calling graph/no-roll\n"); _process_graph->routes_no_roll( nframes, _transport_frame, end_frame, non_realtime_work_pending(), declick); } else { @@ -155,11 +155,7 @@ Session::process_routes (pframes_t nframes, bool& need_butler) const framepos_t start_frame = _transport_frame; const framepos_t end_frame = _transport_frame + floor (nframes * _transport_speed); - /* XXX this is hack to force use of the graph even if we are only - using 1 thread. its needed because otherwise when we remove - tracks, the graph never gets updated. - */ - if (1 || _process_graph->threads_in_use() > 0) { + if (_process_graph) { DEBUG_TRACE(DEBUG::ProcessThreads,"calling graph/process-routes\n"); _process_graph->process_routes (nframes, start_frame, end_frame, declick, need_butler); } else { @@ -192,11 +188,7 @@ Session::silent_process_routes (pframes_t nframes, bool& need_butler) const framepos_t start_frame = _transport_frame; const framepos_t end_frame = _transport_frame + lrintf(nframes * _transport_speed); - /* XXX this is hack to force use of the graph even if we are only - using 1 thread. its needed because otherwise when we remove - tracks, the graph never gets updated. - */ - if (1 || _process_graph->threads_in_use() > 0) { + if (_process_graph) { _process_graph->silent_process_routes (nframes, start_frame, end_frame, need_butler); } else { for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { -- cgit v1.2.3