remove XML-based constructors for several types of Processors; less debugging
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 24 Mar 2010 14:01:31 +0000 (14:01 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 24 Mar 2010 14:01:31 +0000 (14:01 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@6790 d708f5d6-7413-0410-9779-e7cbd77b26cf

13 files changed:
gtk2_ardour/processor_box.cc
libs/ardour/ardour/delivery.h
libs/ardour/ardour/internal_return.h
libs/ardour/ardour/internal_send.h
libs/ardour/ardour/meter.h
libs/ardour/ardour/monitor_processor.h
libs/ardour/delivery.cc
libs/ardour/internal_return.cc
libs/ardour/internal_send.cc
libs/ardour/meter.cc
libs/ardour/monitor_processor.cc
libs/ardour/return.cc
libs/ardour/route.cc

index 201e89db3b2a4b848972e2c57dd7d5a0c1cb5baf..de4af60136465e048f4cd01cda1affcc0ea9ddcf 100644 (file)
@@ -1305,18 +1305,33 @@ ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr
 
                                XMLNode n (**niter);
                                Send::make_unique (n, *_session);
-                               p.reset (new Send (*_session, _route->mute_master(), n));
+                                Send* s = new Send (*_session, _route->mute_master());
+                                if (s->set_state (n, Stateful::loading_state_version)) {
+                                        delete s;
+                                        return;
+                                }
+
+                               p.reset (s);
+                                        
 
                        } else if (type->value() == "return") {
 
                                XMLNode n (**niter);
                                Return::make_unique (n, *_session);
-                               p.reset (new Return (*_session, **niter));
+                                Return* r = new Return (*_session);
+
+                                if (r->set_state (n, Stateful::loading_state_version)) {
+                                        delete r;
+                                        return;
+                                }
+
+                               p.reset (r);
 
                        } else {
                                /* XXX its a bit limiting to assume that everything else
                                   is a plugin.
                                */
+
                                p.reset (new PluginInsert (*_session, **niter));
                        }
 
index b2bd283ef8cb132e17136af0fd8c53220c313271..95ef485527ae458756528b25b22657c35c11cda2 100644 (file)
@@ -53,12 +53,10 @@ public:
        /* Delivery to an existing output */
 
        Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<MuteMaster> mm, const std::string& name, Role);
-       Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<MuteMaster> mm, const XMLNode&);
 
        /* Delivery to a new output owned by this object */
 
        Delivery (Session& s, boost::shared_ptr<MuteMaster> mm, const std::string& name, Role);
-       Delivery (Session&, boost::shared_ptr<MuteMaster> mm, const XMLNode&);
        ~Delivery ();
 
        bool set_name (const std::string& name);
index c5facebef602303657cbf3bd3e1401ef02e97151..25aba5415d793e2113df2af48f27705b6a3c1c3a 100644 (file)
@@ -31,7 +31,6 @@ class InternalReturn : public Return
 {
   public:
        InternalReturn (Session&);
-       InternalReturn (Session&, const XMLNode&);
 
        bool visible() const;
 
index ad498b852d96416ff0a1d3e1bfb243a8a0526a0b..eabe26301367c21891ae703ae947c5b8842a8816 100644 (file)
@@ -29,7 +29,6 @@ class InternalSend : public Send
 {
   public:
        InternalSend (Session&, boost::shared_ptr<MuteMaster>, boost::shared_ptr<Route> send_to, Delivery::Role role);
-       InternalSend (Session&, boost::shared_ptr<MuteMaster>, const XMLNode&);
        virtual ~InternalSend ();
 
        std::string display_name() const;
@@ -55,11 +54,13 @@ class InternalSend : public Send
        boost::shared_ptr<Route> _send_to;
        PBD::ID _send_to_id;
        PBD::ScopedConnection connect_c;
+        PBD::ScopedConnectionList target_connections;
 
        void send_to_going_away ();
        void send_to_property_changed (const PBD::PropertyChange&);
        int  connect_when_legal ();
        int  set_our_state (XMLNode const &, int);
+        int  use_target (boost::shared_ptr<Route>);
 };
 
 } // namespace ARDOUR
index 478a88efcfa86c6524d2b3ff5400d39384174450..80adcd41560bb3d862c2fd661d48b972daa18787 100644 (file)
@@ -46,7 +46,6 @@ class Metering {
 class PeakMeter : public Processor {
 public:
        PeakMeter(Session& s) : Processor(s, "Meter") {}
-       PeakMeter(Session&s, const XMLNode& node);
 
        void meter();
        void reset ();
index 2bef0286c832ddb0ed67f15dfc16133febbfab01..18c50e51043293af9ff045a2bf081dec2c2544dc 100644 (file)
@@ -37,7 +37,6 @@ class MonitorProcessor : public Processor
 {
   public:
         MonitorProcessor (Session&);
-        MonitorProcessor (Session&, const XMLNode& name);
 
         bool display_to_user() const;
 
index 7d6a4d9d79fccdfab9d4a113bd489427a96c28b7..eaf58c0a9bca120ba15eef119a4cdd4417090d9e 100644 (file)
@@ -94,61 +94,6 @@ Delivery::Delivery (Session& s, boost::shared_ptr<MuteMaster> mm, const string&
        CycleStart.connect_same_thread (*this, boost::bind (&Delivery::cycle_start, this, _1));
 }
 
-/* deliver to a new IO object, reconstruct from XML */
-
-Delivery::Delivery (Session& s, boost::shared_ptr<MuteMaster> mm, const XMLNode& node)
-       : IOProcessor (s, false, true, "reset")
-       , _role (Role (0))
-       , _output_buffers (new BufferSet())
-       , _current_gain (1.0)
-       , _output_offset (0)
-       , _no_outs_cuz_we_no_monitor (false)
-       , _solo_level (0)
-       , _solo_isolated (false)
-       , _mute_master (mm)
-       , no_panner_reset (false)
-{
-       _panner = boost::shared_ptr<Panner>(new Panner (_name, _session));
-       _display_to_user = false;
-
-       if (set_state (node, Stateful::loading_state_version)) {
-               throw failed_constructor ();
-       }
-
-       if (_output) {
-               _output->changed.connect_same_thread (*this, boost::bind (&Delivery::output_changed, this, _1, _2));
-       }
-
-       CycleStart.connect_same_thread (*this, boost::bind (&Delivery::cycle_start, this, _1));
-}
-
-/* deliver to an existing IO object, reconstruct from XML */
-
-Delivery::Delivery (Session& s, boost::shared_ptr<IO> out, boost::shared_ptr<MuteMaster> mm, const XMLNode& node)
-       : IOProcessor (s, boost::shared_ptr<IO>(), out, "reset")
-       , _role (Role (0))
-       , _output_buffers (new BufferSet())
-       , _current_gain (1.0)
-       , _output_offset (0)
-       , _no_outs_cuz_we_no_monitor (false)
-       , _solo_level (0)
-       , _solo_isolated (false)
-       , _mute_master (mm)
-       , no_panner_reset (false)
-{
-       _panner = boost::shared_ptr<Panner>(new Panner (_name, _session));
-       _display_to_user = false;
-
-       if (set_state (node, Stateful::loading_state_version)) {
-               throw failed_constructor ();
-       }
-
-       if (_output) {
-               _output->changed.connect_same_thread (*this, boost::bind (&Delivery::output_changed, this, _1, _2));
-       }
-
-       CycleStart.connect_same_thread (*this, boost::bind (&Delivery::cycle_start, this, _1));
-}
 
 Delivery::~Delivery()
 {
index 279472e02d18cda39eef14d6236aed6f56303eeb..280568131fd8bbb5383c77865a1693ddc1767a43 100644 (file)
@@ -36,13 +36,6 @@ InternalReturn::InternalReturn (Session& s)
        CycleStart.connect_same_thread (*this, boost::bind (&InternalReturn::cycle_start, this, _1));
 }
 
-InternalReturn::InternalReturn (Session& s, const XMLNode& node)
-       : Return (s, node, true)
-       , user_count (0)
-{
-       CycleStart.connect_same_thread (*this, boost::bind (&InternalReturn::cycle_start, this, _1));
-}
-
 void
 InternalReturn::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t nframes, bool)
 {
index 9cfc8d9702e2097d9d169ccc375511fd486ba691..36621717404cd62c720fb776f1f3e91706e6448f 100644 (file)
@@ -34,24 +34,12 @@ using namespace std;
 
 InternalSend::InternalSend (Session& s, boost::shared_ptr<MuteMaster> mm, boost::shared_ptr<Route> sendto, Delivery::Role role)
        : Send (s, mm, role)
-       , _send_to (sendto)
 {
-       if ((target = _send_to->get_return_buffer ()) == 0) {
-               throw failed_constructor();
-       }
-
-       set_name (sendto->name());
-
-       _send_to->DropReferences.connect_same_thread (*this, boost::bind (&InternalSend::send_to_going_away, this));
-       _send_to->PropertyChanged.connect_same_thread (*this, boost::bind (&InternalSend::send_to_property_changed, this, _1));;
-}
-
-InternalSend::InternalSend (Session& s, boost::shared_ptr<MuteMaster> mm, const XMLNode& node)
-       : Send (s, mm, node, Stateful::loading_state_version, Delivery::Aux /* will be reset in set_state() */),
-         target (0)
-{
-       /* Send constructor will set its state, so here we just need to set up our own */
-       set_our_state (node, Stateful::loading_state_version);
+        if (sendto) {
+                if (use_target (sendto)) {
+                        throw failed_constructor();
+                }
+        }
 }
 
 InternalSend::~InternalSend ()
@@ -59,14 +47,34 @@ InternalSend::~InternalSend ()
        if (_send_to) {
                _send_to->release_return_buffer ();
        }
+}
 
-       connect_c.disconnect ();
+int
+InternalSend::use_target (boost::shared_ptr<Route> sendto)
+{
+        _send_to = sendto;
+
+        if ((target = _send_to->get_return_buffer ()) == 0) {
+                return -1;
+        }
+        
+        set_name (sendto->name());
+        _send_to_id = _send_to->id();
+
+        target_connections.drop_connections ();
+
+        _send_to->DropReferences.connect_same_thread (target_connections, boost::bind (&InternalSend::send_to_going_away, this));
+        _send_to->PropertyChanged.connect_same_thread (target_connections, boost::bind (&InternalSend::send_to_property_changed, this, _1));;
+
+        return 0;
 }
 
+
 void
 InternalSend::send_to_going_away ()
 {
        target = 0;
+        target_connections.drop_connections ();
        _send_to.reset ();
        _send_to_id = "0";
 }
@@ -212,17 +220,14 @@ InternalSend::connect_when_legal ()
                return 0;
        }
 
-       if ((_send_to = _session.route_by_id (_send_to_id)) == 0) {
-               error << X_("cannot find route to connect to") << endmsg;
-               return -1;
-       }
+        boost::shared_ptr<Route> sendto;
 
-       if ((target = _send_to->get_return_buffer ()) == 0) {
-               error << X_("target for internal send has no return buffer") << endmsg;
+       if ((sendto = _session.route_by_id (_send_to_id)) == 0) {
+               error << X_("cannot find route to connect to") << endmsg;
                return -1;
        }
 
-       return 0;
+        return use_target (sendto);
 }
 
 bool
index e49b69574e3e8bfbcc19e5deba9f235df4bda71a..0104de4bbddaae772fc5504cecfccd9d340b895e 100644 (file)
@@ -33,12 +33,6 @@ using namespace ARDOUR;
 
 PBD::Signal0<void> Metering::Meter;
 
-PeakMeter::PeakMeter (Session& s, const XMLNode& node)
-       : Processor (s, node)
-{
-       
-}
-
 /** Get peaks from @a bufs
  * Input acceptance is lenient - the first n buffers from @a bufs will
  * be metered, where n was set by the last call to setup(), excess meters will
index 8399c0382ad290b3d61ab360cf3e3aa9e011dec3..51bd30a389bff38807f8ca6ea33ccc634fd8ba3f 100644 (file)
@@ -25,12 +25,6 @@ MonitorProcessor::MonitorProcessor (Session& s)
         _solo_boost_level = 1.0;
 }
 
-MonitorProcessor::MonitorProcessor (Session& s, const XMLNode& node)
-        : Processor (s, node)
-{
-        set_state (node, Stateful::loading_state_version);
-}
-
 void
 MonitorProcessor::allocate_channels (uint32_t size)
 {
index c2c227769d932c1670ec801f3685c67208122c43..39acf0ddf103ebe716e95b993d43070380c03e29 100644 (file)
@@ -49,22 +49,6 @@ Return::Return (Session& s, bool internal)
        ProcessorCreated (this); /* EMIT SIGNAL */
 }
 
-Return::Return (Session& s, const XMLNode& node, bool internal)
-       : IOProcessor (s, (internal ? false : true), false, "return")
-       , _metering (false)
-{
-       /* never muted */
-
-       _amp.reset (new Amp (_session, boost::shared_ptr<MuteMaster>()));
-       _meter.reset (new PeakMeter (_session));
-
-       if (set_state (node, Stateful::loading_state_version)) {
-               throw failed_constructor();
-       }
-
-       ProcessorCreated (this); /* EMIT SIGNAL */
-}
-
 Return::~Return ()
 {
 }
index 2199c71caa2f2f19a0095f7c57401f4797e99fbd..f0c52daa6fb72c5d41a9e01d1eb68576c96d078b 100644 (file)
@@ -456,8 +456,6 @@ Route::process_output_buffers (BufferSet& bufs,
                        }
                        assert (bufs.count() == (*i)->input_streams());
                         
-                        cerr << _name << " run processor " << (*i)->name() << " with " << bufs.count() << endl;
-
                        (*i)->run (bufs, start_frame, end_frame, nframes, *i != _processors.back());
                        bufs.set_count ((*i)->output_streams());
                }
@@ -808,6 +806,20 @@ Route::add_processor (boost::shared_ptr<Processor> processor, ProcessorList::ite
 
                }
 
+                /* is this the monitor send ? if so, make sure we keep track of it */
+
+                boost::shared_ptr<InternalSend> isend = boost::dynamic_pointer_cast<InternalSend> (processor);
+
+                if (isend && _session.monitor_out() && (isend->target_id() == _session.monitor_out()->id())) {
+                        _monitor_send = isend;
+                        
+                        if (_monitor_send->active()) {
+                                _monitor_send->set_solo_level (1);
+                        } else {
+                                _monitor_send->set_solo_level (0);
+                        }
+                }
+
                if (activation_allowed && (processor != _monitor_send)) {
                        processor->activate ();
                }
@@ -836,22 +848,9 @@ Route::add_processor_from_xml (const XMLNode& node, ProcessorList::iterator iter
 
                        boost::shared_ptr<Processor> processor;
 
-                       if (prop->value() == "ladspa" || prop->value() == "Ladspa" ||
-                           prop->value() == "lv2" ||
-                           prop->value() == "vst" ||
-                           prop->value() == "audiounit") {
-
-                               processor.reset (new PluginInsert(_session, node));
-
-                       } else if (prop->value() == "port") {
-
-                               processor.reset (new PortInsert (_session, _mute_master, node));
-
-                       } else if (prop->value() == "send") {
-
-                               processor.reset (new Send (_session, _mute_master, node));
-
-                       } else if (prop->value() == "meter") {
+                        /* meter, amp, monitor and intreturn are all singletons, deal with them first */
+                        
+                       if (prop->value() == "meter") {
 
                                if (_meter) {
                                        if (_meter->set_state (node, Stateful::loading_state_version)) {
@@ -861,8 +860,16 @@ Route::add_processor_from_xml (const XMLNode& node, ProcessorList::iterator iter
                                        }
                                }
 
-                               _meter.reset (new PeakMeter (_session, node));
+                                PeakMeter* pm = new PeakMeter (_session);
+
+                                if (pm->set_state (node, Stateful::loading_state_version)) {
+                                        delete pm;
+                                        return false;
+                                }
+
+                               _meter.reset (pm);
                                _meter->set_display_to_user (_meter_point == MeterCustom);
+
                                processor = _meter;
 
                         } else if (prop->value() == "monitor") {
@@ -874,37 +881,36 @@ Route::add_processor_from_xml (const XMLNode& node, ProcessorList::iterator iter
                                                 return true;
                                         }
                                 }
-                                
-                                _monitor_control.reset (new MonitorProcessor (_session));
-                                _monitor_control->set_state (node, Stateful::loading_state_version);
-                                processor = _monitor_control;
-
-                       } else if (prop->value() == "amp") {
 
-                               /* amp always exists */
+                                MonitorProcessor* mp = new MonitorProcessor (_session);
+                                if (mp->set_state (node, Stateful::loading_state_version)) {
+                                        delete mp;
+                                        return false;
+                                }
 
-                               processor = _amp;
-                               if (processor->set_state (node, Stateful::loading_state_version)) {
-                                       return false;
-                               } else {
-                                       /* never any reason to add it */
-                                       return true;
-                               }
+                                _monitor_control.reset (mp);
+                                processor = _monitor_control;
 
-                       } else if (prop->value() == "intsend") {
+                       } else if (prop->value() == "amp") {
 
-                                InternalSend* isend = new InternalSend (_session, _mute_master, node);
-                                
-                                if (_session.monitor_out() && (isend->target_id() == _session.monitor_out()->id())) {
-                                        _monitor_send.reset (isend);
-                                        if (_monitor_send->active()) {
-                                                _monitor_send->set_solo_level (1);
+                                if (_amp) {
+                                        processor = _amp;
+                                        if (processor->set_state (node, Stateful::loading_state_version)) {
+                                                return false;
                                         } else {
-                                                _monitor_send->set_solo_level (0);
+                                                /* no reason to add it */
+                                                return true;
                                         }
                                 }
 
-                                processor.reset (isend);
+                                Amp* a = new Amp (_session, _mute_master);
+                                if (_amp->set_state (node, Stateful::loading_state_version)) {
+                                        delete a;
+                                        return false;
+                                }
+
+                                _amp.reset (a);
+                                processor = _amp;
 
                        } else if (prop->value() == "intreturn") {
 
@@ -919,7 +925,14 @@ Route::add_processor_from_xml (const XMLNode& node, ProcessorList::iterator iter
                                                return true;
                                        }
                                }
-                               _intreturn.reset (new InternalReturn (_session, node));
+
+                                InternalReturn* iret = new InternalReturn (_session);
+                                if (iret->set_state (node, Stateful::loading_state_version)) { 
+                                        delete iret;
+                                        return false;
+                                }
+
+                               _intreturn.reset (iret);
                                processor = _intreturn;
 
                        } else if (prop->value() == "main-outs") {
@@ -932,9 +945,40 @@ Route::add_processor_from_xml (const XMLNode& node, ProcessorList::iterator iter
                                        }
                                }
 
-                               _main_outs.reset (new Delivery (_session, _output, _mute_master, node));
+                                Delivery* del = new Delivery (_session, _output, _mute_master, X_("toBeResetFroXML"), Delivery::Role (0));
+                                if (del->set_state (node, Stateful::loading_state_version)) { 
+                                        delete del;
+                                        return false;
+                                }
+
+                               _main_outs.reset (del);
                                processor = _main_outs;
 
+                       } else if (prop->value() == "intsend") {
+
+                                InternalSend* isend = new InternalSend (_session, _mute_master, boost::shared_ptr<Route>(), Delivery::Role (0));
+                                if (isend->set_state (node, Stateful::loading_state_version)) {
+                                        delete isend;
+                                        return false;
+                                }
+                                
+                                processor.reset (isend);
+
+                        } else if (prop->value() == "ladspa" || prop->value() == "Ladspa" ||
+                                   prop->value() == "lv2" ||
+                                   prop->value() == "vst" ||
+                                   prop->value() == "audiounit") {
+                                
+                               processor.reset (new PluginInsert(_session, node));
+
+                       } else if (prop->value() == "port") {
+
+                               processor.reset (new PortInsert (_session, _mute_master, node));
+
+                       } else if (prop->value() == "send") {
+
+                               processor.reset (new Send (_session, _mute_master, node));
+
                        } else {
                                error << string_compose(_("unknown Processor type \"%1\"; ignored"), prop->value()) << endmsg;
                                return false;