For now, only use the multi-threaded process code if we are
authorCarl Hetherington <carl@carlh.net>
Sun, 22 Jan 2012 12:28:49 +0000 (12:28 +0000)
committerCarl Hetherington <carl@carlh.net>
Sun, 22 Jan 2012 12:28:49 +0000 (12:28 +0000)
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

gtk2_ardour/option_editor.cc
gtk2_ardour/option_editor.h
gtk2_ardour/rc_option_editor.cc
libs/ardour/ardour/graph.h
libs/ardour/graph.cc
libs/ardour/session.cc
libs/ardour/session_process.cc

index dcae19ef77b6c1fcbfcf1693119182159908e98f..f1185664055b127b49253c1205f9b932b6cf836e 100644 (file)
@@ -40,17 +40,47 @@ void
 OptionEditorComponent::add_widget_to_page (OptionEditorPage* p, Gtk::Widget* w)
 {
        int const n = p->table.property_n_rows();
-       p->table.resize (n + 1, 3);
+       int m = n + 1;
+       if (!_note.empty ()) {
+               ++m;
+       }
+
+       p->table.resize (m, 3);
        p->table.attach (*w, 1, 3, n, n + 1, FILL | EXPAND);
+
+       maybe_add_note (p, n + 1);
 }
 
 void
 OptionEditorComponent::add_widgets_to_page (OptionEditorPage* p, Gtk::Widget* wa, Gtk::Widget* wb)
 {
        int const n = p->table.property_n_rows();
-       p->table.resize (n + 1, 3);
+       int m = n + 1;
+       if (!_note.empty ()) {
+               ++m;
+       }
+       
+       p->table.resize (m, 3);
        p->table.attach (*wa, 1, 2, n, n + 1, FILL);
        p->table.attach (*wb, 2, 3, n, n + 1, FILL | EXPAND);
+       
+       maybe_add_note (p, n + 1);
+}
+
+void
+OptionEditorComponent::maybe_add_note (OptionEditorPage* p, int n)
+{
+       if (!_note.empty ()) {
+               Gtk::Label* l = manage (new Gtk::Label (string_compose (X_("<i>%1</i>"), _note)));
+               l->set_use_markup (true);
+               p->table.attach (*l, 1, 3, n, n + 1, FILL | EXPAND);
+       }
+}
+
+void
+OptionEditorComponent::set_note (string const & n)
+{
+       _note = n;
 }
 
 OptionEditorHeading::OptionEditorHeading (string const & h)
index df1f531a774b153fb3788c8d28f4ec2e91cfef41..dd34b850579437347b5b77f4fe352115170644be 100644 (file)
@@ -71,6 +71,13 @@ public:
 
        void add_widget_to_page (OptionEditorPage*, Gtk::Widget*);
        void add_widgets_to_page (OptionEditorPage*, Gtk::Widget*, Gtk::Widget*);
+
+       void set_note (std::string const &);
+
+private:
+       void maybe_add_note (OptionEditorPage *, int);
+       
+       std::string _note;
 };
 
 /** A component which provides a subheading within the dialog */
index 5c67005386c83ee9e686d9d572b0203a111fa899..472faf484c0810f15fc588ab33b1e3f3d3b04871 100644 (file)
@@ -877,6 +877,8 @@ RCOptionEditor::RCOptionEditor ()
                         procs->add (i, string_compose (_("%1 processors"), i));
                 }
 
+               procs->set_note (_("This setting will only take effect when Ardour is restarted."));
+
                 add_option (_("Misc"), procs);
         }
 
index f1ebba698a70b05205b5cb3bd2f64207166e7bd4..b735d6988828d9ae1f76ec804750ed8766c31cc8 100644 (file)
@@ -94,9 +94,7 @@ protected:
 private:
        std::list<pthread_t> _thread_list;
        volatile bool        _quit_threads;
-       PBD::ScopedConnection processor_usage_connection;
 
-       void parameter_changed (std::string);
        void reset_thread_list ();
        void drop_threads ();
 
index 5b435884d4fe7d056248ba0d8f2b03275828b425..c38106506edc8f21146d839a2313f92686aea00d 100644 (file)
@@ -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);
        }
index 7ee854dc2dead1aa30a6d9e6a63bf56f37f7cbee..f2343e1013af059a50a7a03fffd07df3b940da2a 100644 (file)
@@ -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<RouteList> rl = routes.reader ();
        for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
@@ -1460,7 +1464,10 @@ Session::resort_routes_using (boost::shared_ptr<RouteList> 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> 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 */
 
index 80f922117da4e4bf29deec16f1afc9a155ef4be6..897b58ec8e14453cd5d1dec5773efddf20dfab8a 100644 (file)
@@ -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) {