From 2726184f42652a84816096887948658177ea24f8 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 24 Mar 2010 14:01:31 +0000 Subject: remove XML-based constructors for several types of Processors; less debugging git-svn-id: svn://localhost/ardour2/branches/3.0@6790 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/processor_box.cc | 19 ++++- libs/ardour/ardour/delivery.h | 2 - libs/ardour/ardour/internal_return.h | 1 - libs/ardour/ardour/internal_send.h | 3 +- libs/ardour/ardour/meter.h | 1 - libs/ardour/ardour/monitor_processor.h | 1 - libs/ardour/delivery.cc | 55 -------------- libs/ardour/internal_return.cc | 7 -- libs/ardour/internal_send.cc | 55 +++++++------- libs/ardour/meter.cc | 6 -- libs/ardour/monitor_processor.cc | 6 -- libs/ardour/return.cc | 16 ---- libs/ardour/route.cc | 132 ++++++++++++++++++++++----------- 13 files changed, 137 insertions(+), 167 deletions(-) diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index 201e89db3b..de4af60136 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -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)); } diff --git a/libs/ardour/ardour/delivery.h b/libs/ardour/ardour/delivery.h index b2bd283ef8..95ef485527 100644 --- a/libs/ardour/ardour/delivery.h +++ b/libs/ardour/ardour/delivery.h @@ -53,12 +53,10 @@ public: /* Delivery to an existing output */ Delivery (Session& s, boost::shared_ptr io, boost::shared_ptr mm, const std::string& name, Role); - Delivery (Session& s, boost::shared_ptr io, boost::shared_ptr mm, const XMLNode&); /* Delivery to a new output owned by this object */ Delivery (Session& s, boost::shared_ptr mm, const std::string& name, Role); - Delivery (Session&, boost::shared_ptr mm, const XMLNode&); ~Delivery (); bool set_name (const std::string& name); diff --git a/libs/ardour/ardour/internal_return.h b/libs/ardour/ardour/internal_return.h index c5facebef6..25aba5415d 100644 --- a/libs/ardour/ardour/internal_return.h +++ b/libs/ardour/ardour/internal_return.h @@ -31,7 +31,6 @@ class InternalReturn : public Return { public: InternalReturn (Session&); - InternalReturn (Session&, const XMLNode&); bool visible() const; diff --git a/libs/ardour/ardour/internal_send.h b/libs/ardour/ardour/internal_send.h index ad498b852d..eabe263013 100644 --- a/libs/ardour/ardour/internal_send.h +++ b/libs/ardour/ardour/internal_send.h @@ -29,7 +29,6 @@ class InternalSend : public Send { public: InternalSend (Session&, boost::shared_ptr, boost::shared_ptr send_to, Delivery::Role role); - InternalSend (Session&, boost::shared_ptr, const XMLNode&); virtual ~InternalSend (); std::string display_name() const; @@ -55,11 +54,13 @@ class InternalSend : public Send boost::shared_ptr _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); }; } // namespace ARDOUR diff --git a/libs/ardour/ardour/meter.h b/libs/ardour/ardour/meter.h index 478a88efcf..80adcd4156 100644 --- a/libs/ardour/ardour/meter.h +++ b/libs/ardour/ardour/meter.h @@ -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 (); diff --git a/libs/ardour/ardour/monitor_processor.h b/libs/ardour/ardour/monitor_processor.h index 2bef0286c8..18c50e5104 100644 --- a/libs/ardour/ardour/monitor_processor.h +++ b/libs/ardour/ardour/monitor_processor.h @@ -37,7 +37,6 @@ class MonitorProcessor : public Processor { public: MonitorProcessor (Session&); - MonitorProcessor (Session&, const XMLNode& name); bool display_to_user() const; diff --git a/libs/ardour/delivery.cc b/libs/ardour/delivery.cc index 7d6a4d9d79..eaf58c0a9b 100644 --- a/libs/ardour/delivery.cc +++ b/libs/ardour/delivery.cc @@ -94,61 +94,6 @@ Delivery::Delivery (Session& s, boost::shared_ptr 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 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(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 out, boost::shared_ptr mm, const XMLNode& node) - : IOProcessor (s, boost::shared_ptr(), 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(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() { diff --git a/libs/ardour/internal_return.cc b/libs/ardour/internal_return.cc index 279472e02d..280568131f 100644 --- a/libs/ardour/internal_return.cc +++ b/libs/ardour/internal_return.cc @@ -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) { diff --git a/libs/ardour/internal_send.cc b/libs/ardour/internal_send.cc index 9cfc8d9702..3662171740 100644 --- a/libs/ardour/internal_send.cc +++ b/libs/ardour/internal_send.cc @@ -34,24 +34,12 @@ using namespace std; InternalSend::InternalSend (Session& s, boost::shared_ptr mm, boost::shared_ptr 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 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 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 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 diff --git a/libs/ardour/meter.cc b/libs/ardour/meter.cc index e49b69574e..0104de4bbd 100644 --- a/libs/ardour/meter.cc +++ b/libs/ardour/meter.cc @@ -33,12 +33,6 @@ using namespace ARDOUR; PBD::Signal0 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 diff --git a/libs/ardour/monitor_processor.cc b/libs/ardour/monitor_processor.cc index 8399c0382a..51bd30a389 100644 --- a/libs/ardour/monitor_processor.cc +++ b/libs/ardour/monitor_processor.cc @@ -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) { diff --git a/libs/ardour/return.cc b/libs/ardour/return.cc index c2c227769d..39acf0ddf1 100644 --- a/libs/ardour/return.cc +++ b/libs/ardour/return.cc @@ -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())); - _meter.reset (new PeakMeter (_session)); - - if (set_state (node, Stateful::loading_state_version)) { - throw failed_constructor(); - } - - ProcessorCreated (this); /* EMIT SIGNAL */ -} - Return::~Return () { } diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 2199c71caa..f0c52daa6f 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -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, ProcessorList::ite } + /* is this the monitor send ? if so, make sure we keep track of it */ + + boost::shared_ptr isend = boost::dynamic_pointer_cast (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; - 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(), 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; -- cgit v1.2.3