2 Copyright (C) 2016 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <boost/algorithm/string.hpp>
22 #include "pbd/compose.h"
23 #include "pbd/convert.h"
25 #include "ardour/debug.h"
26 #include "ardour/rc_configuration.h"
27 #include "ardour/stripable.h"
31 using namespace ARDOUR;
35 PBD::Signal0<void> Stripable::PresentationInfoChange;
37 Stripable::Stripable (Session& s, string const & name, PresentationInfo const & pi)
38 : SessionObject (s, name)
39 , _presentation_info (pi)
44 Stripable::set_presentation_group_order (PresentationInfo::order_t order, bool notify_class_listeners)
46 set_presentation_info (PresentationInfo (order, _presentation_info.flags()), notify_class_listeners);
50 Stripable::set_presentation_group_order_explicit (PresentationInfo::order_t order)
52 set_presentation_group_order (order, false);
56 Stripable::set_presentation_info (PresentationInfo pi, bool notify_class_listeners)
58 if (pi != presentation_info()) {
60 DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("%1: set edit-based RID to %2\n", name(), pi));
63 _presentation_info = PresentationInfo (0, PresentationInfo::MasterOut);
64 } else if (is_monitor()) {
65 _presentation_info = PresentationInfo (0, PresentationInfo::MonitorOut);
67 _presentation_info = pi;
70 PresentationInfoChanged ();
72 if (notify_class_listeners) {
73 PresentationInfoChange ();
79 Stripable::set_presentation_info_explicit (PresentationInfo pi)
81 set_presentation_info (pi, false);
85 Stripable::set_state (XMLNode const& node, int version)
87 const XMLProperty *prop;
88 XMLNodeList const & nlist (node.children());
89 XMLNodeConstIterator niter;
94 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
97 if (child->name() == X_("PresentationInfo")) {
98 if ((prop = child->property (X_("value"))) != 0) {
99 _presentation_info = prop->value ();
106 /* Older versions of Ardour stored "_flags" as a property of the Route
107 * node, only for 3 special Routes (MasterOut, MonitorOut, Auditioner.
109 * Their presentation order was stored in a node called "RemoteControl"
111 * This information is now part of the PresentationInfo of every Stripable.
114 if ((prop = node.property (X_("flags"))) != 0) {
116 /* 4.x and earlier - didn't have Stripable but the
117 * relevant enums have the same names (MasterOut,
118 * MonitorOut, Auditioner), so we can use string_2_enum
121 PresentationInfo::Flag flags;
123 if (version < 3000) {
124 string f (prop->value());
125 boost::replace_all (f, "ControlOut", "MonitorOut");
126 flags = PresentationInfo::Flag (string_2_enum (f, flags));
128 flags = PresentationInfo::Flag (string_2_enum (prop->value(), flags));
131 _presentation_info.set_flags (flags);
135 if (!_presentation_info.special()) {
136 if ((prop = node.property (X_("order-key"))) != 0) {
137 _presentation_info.set_group_order (atol (prop->value()));
146 Stripable::add_state (XMLNode& node) const
148 XMLNode* remote_control_node = new XMLNode (X_("PresentationInfo"));
149 remote_control_node->add_property (X_("value"), _presentation_info.to_string());
150 node.add_child_nocopy (*remote_control_node);