#include <cerrno>
#include <cstdio> /* snprintf(3) ... grrr */
#include <cmath>
+
#include <unistd.h>
#include <climits>
#include <signal.h>
#include "evoral/SMF.hpp"
-#include "pbd/boost_debug.h"
#include "pbd/basename.h"
-#include "pbd/controllable_descriptor.h"
#include "pbd/debug.h"
#include "pbd/enumwriter.h"
#include "pbd/error.h"
#include "ardour/audioengine.h"
#include "ardour/audiofilesource.h"
#include "ardour/audioregion.h"
+#include "ardour/auditioner.h"
#include "ardour/automation_control.h"
+#include "ardour/boost_debug.h"
#include "ardour/butler.h"
+#include "ardour/controllable_descriptor.h"
#include "ardour/control_protocol_manager.h"
#include "ardour/directory_names.h"
#include "ardour/filename_extensions.h"
#include "ardour/proxy_controllable.h"
#include "ardour/recent_sessions.h"
#include "ardour/region_factory.h"
+#include "ardour/revision.h"
#include "ardour/route_group.h"
#include "ardour/send.h"
#include "ardour/session.h"
#include "ardour/tempo.h"
#include "ardour/ticker.h"
#include "ardour/user_bundle.h"
+#include "ardour/vca.h"
+#include "ardour/vca_manager.h"
#include "control_protocol/control_protocol.h"
delete _tempo_map;
_tempo_map = new TempoMap (_current_frame_rate);
_tempo_map->PropertyChanged.connect_same_thread (*this, boost::bind (&Session::tempo_map_changed, this, _1));
+ _tempo_map->MetricPositionChanged.connect_same_thread (*this, boost::bind (&Session::gui_tempo_map_changed, this));
/* MidiClock requires a tempo map */
+ delete midi_clock;
midi_clock = new MidiClockTicker ();
midi_clock->set_session (this);
_state_of_the_state = Clean;
- /* set up Master Out and Control Out if necessary */
+ /* set up Master Out and Monitor Out if necessary */
if (bus_profile) {
// Waves Tracks: always create master bus for Tracks
if (ARDOUR::Profile->get_trx() || bus_profile->master_out_channels) {
- boost::shared_ptr<Route> r (new Route (*this, _("Master"), Route::MasterOut, DataType::AUDIO));
+ boost::shared_ptr<Route> r (new Route (*this, _("Master"), PresentationInfo::MasterOut, DataType::AUDIO));
if (r->init ()) {
return -1;
}
-#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
- // boost_debug_shared_ptr_mark_interesting (r.get(), "Route");
-#endif
- {
+
+ BOOST_MARK_ROUTE(r);
+
+ {
Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
r->input()->ensure_io (count, false, this);
r->output()->ensure_io (count, false, this);
}
if (!rl.empty()) {
- add_routes (rl, false, false, false);
+ add_routes (rl, false, false, false, PresentationInfo::max_order);
}
// Waves Tracks: Skip this. Always use autoconnection for Tracks
int
Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot, bool template_only)
{
+ DEBUG_TRACE (DEBUG::Locale, string_compose ("Session::save_state locale '%1'\n", setlocale (LC_NUMERIC, NULL)));
+
XMLTree tree;
std::string xml_path(_session_dir->root_path());
return -1;
}
- XMLNode& root (*state_tree->root());
+ XMLNode const & root (*state_tree->root());
if (root.name() != X_("Session")) {
error << string_compose (_("Session file %1 is not a session"), xmlpath) << endmsg;
return -1;
}
- const XMLProperty* prop;
+ XMLProperty const * prop;
if ((prop = root.property ("version")) == 0) {
/* no version implies very old version of Ardour */
int
Session::load_options (const XMLNode& node)
{
- LocaleGuard lg (X_("C"));
+ LocaleGuard lg;
config.set_variables (node);
return 0;
}
XMLNode&
Session::state (bool full_state)
{
+ LocaleGuard lg;
XMLNode* node = new XMLNode("Session");
XMLNode* child;
snprintf(buf, sizeof(buf), "%d", CURRENT_SESSION_FILE_VERSION);
node->add_property("version", buf);
+ child = node->add_child ("ProgramVersion");
+ child->add_property("created-with", created_with);
+
+ std::string modified_with = string_compose ("%1 %2", PROGRAM_NAME, revision);
+ child->add_property("modified-with", modified_with);
+
/* store configuration settings */
if (full_state) {
node->add_property ("name", _name);
- snprintf (buf, sizeof (buf), "%" PRId64, _nominal_frame_rate);
+ snprintf (buf, sizeof (buf), "%" PRId64, _base_frame_rate);
node->add_property ("sample-rate", buf);
if (session_dirs.size() > 1) {
snprintf (buf, sizeof (buf), "%d", Evoral::event_id_counter());
node->add_property ("event-counter", buf);
+ /* save the VCA counter */
+
+ snprintf (buf, sizeof (buf), "%" PRIu32, VCA::get_next_vca_number());
+ node->add_property ("vca-counter", buf);
+
/* various options */
list<XMLNode*> midi_port_nodes = _midi_ports->get_midi_port_states();
}
}
+ node->add_child_nocopy (_vca_manager->get_state());
+
child = node->add_child ("Routes");
{
boost::shared_ptr<RouteList> r = routes.reader ();
int
Session::set_state (const XMLNode& node, int version)
{
+ LocaleGuard lg;
XMLNodeList nlist;
XMLNode* child;
- const XMLProperty* prop;
+ XMLProperty const * prop;
int ret = -1;
_state_of_the_state = StateOfTheState (_state_of_the_state|CannotSave);
if ((prop = node.property (X_("sample-rate"))) != 0) {
- _nominal_frame_rate = atoi (prop->value());
+ _base_frame_rate = atoi (prop->value());
+ _nominal_frame_rate = _base_frame_rate;
- if (_nominal_frame_rate != _current_frame_rate) {
- boost::optional<int> r = AskAboutSampleRateMismatch (_nominal_frame_rate, _current_frame_rate);
+ assert (AudioEngine::instance()->running ());
+ if (_base_frame_rate != AudioEngine::instance()->sample_rate ()) {
+ boost::optional<int> r = AskAboutSampleRateMismatch (_base_frame_rate, _current_frame_rate);
if (r.get_value_or (0)) {
goto out;
}
}
}
+ created_with = "unknown";
+ if ((child = find_named_node (node, "ProgramVersion")) != 0) {
+ if ((prop = child->property (X_("created-with"))) != 0) {
+ created_with = prop->value ();
+ }
+ }
+
setup_raid_path(_session_dir->root_path());
if ((prop = node.property (X_("id-counter"))) != 0) {
Evoral::init_event_id_counter (atoi (prop->value()));
}
+ if ((prop = node.property (X_("vca-counter"))) != 0) {
+ uint32_t x;
+ sscanf (prop->value().c_str(), "%" PRIu32, &x);
+ VCA::set_next_vca_number (x);
+ } else {
+ VCA::set_next_vca_number (1);
+ }
+
if ((child = find_named_node (node, "MIDIPorts")) != 0) {
_midi_ports->set_midi_port_states (child->children());
}
}
}
+ if ((child = find_named_node (node, VCAManager::xml_node_name)) != 0) {
+ _vca_manager->set_state (*child, version);
+ }
+
if ((child = find_named_node (node, "Routes")) == 0) {
error << _("Session: XML state has no routes section") << endmsg;
goto out;
goto out;
}
+ /* Now that we have Routes and masters loaded, connect them if appropriate */
+
+ Slavable::Assign (_vca_manager); /* EMIT SIGNAL */
+
/* our diskstreams list is no longer needed as they are now all owned by their Route */
_diskstreams_2X.clear ();
BootMessage (_("Tracks/busses loaded; Adding to Session"));
- add_routes (new_routes, false, false, false);
+ add_routes (new_routes, false, false, false, PresentationInfo::max_order);
BootMessage (_("Finished adding tracks/busses"));
XMLNode* ds_child = find_named_node (node, X_("Diskstream"));
DataType type = DataType::AUDIO;
- const XMLProperty* prop = node.property("default-type");
+ XMLProperty const * prop = node.property("default-type");
if (prop) {
type = DataType (prop->value());
return ret;
}
-#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
- // boost_debug_shared_ptr_mark_interesting (track.get(), "Track");
-#endif
+ BOOST_MARK_TRACK (track);
ret = track;
} else {
- enum Route::Flag flags = Route::Flag(0);
- const XMLProperty* prop = node.property("flags");
- if (prop) {
- flags = Route::Flag (string_2_enum (prop->value(), flags));
- }
-
+ PresentationInfo::Flag flags = PresentationInfo::get_flags (node);
boost::shared_ptr<Route> r (new Route (*this, X_("toBeResetFroXML"), flags));
if (r->init () == 0 && r->set_state (node, version) == 0) {
-#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
- // boost_debug_shared_ptr_mark_interesting (r.get(), "Route");
-#endif
+ BOOST_MARK_ROUTE (r);
ret = r;
}
}
}
DataType type = DataType::AUDIO;
- const XMLProperty* prop = node.property("default-type");
+ XMLProperty const * prop = node.property("default-type");
if (prop) {
type = DataType (prop->value());
track->set_diskstream (*i);
-#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
- // boost_debug_shared_ptr_mark_interesting (track.get(), "Track");
-#endif
+ BOOST_MARK_TRACK (track);
ret = track;
} else {
- enum Route::Flag flags = Route::Flag(0);
- const XMLProperty* prop = node.property("flags");
- if (prop) {
- flags = Route::Flag (string_2_enum (prop->value(), flags));
- }
-
+ PresentationInfo::Flag flags = PresentationInfo::get_flags (node);
boost::shared_ptr<Route> r (new Route (*this, X_("toBeResetFroXML"), flags));
if (r->init () == 0 && r->set_state (node, version) == 0) {
-#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
- // boost_debug_shared_ptr_mark_interesting (r.get(), "Route");
-#endif
+ BOOST_MARK_ROUTE (r);
ret = r;
}
}
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
if ((region = XMLRegionFactory (**niter, false)) == 0) {
error << _("Session: cannot create Region from XML description.");
- const XMLProperty *name = (**niter).property("name");
+ XMLProperty const * name = (**niter).property("name");
if (name) {
error << " " << string_compose (_("Can not load state for region '%1'"), name->value());
{
XMLNodeList calist = node.children();
XMLNodeConstIterator caiter;
- XMLProperty *caprop;
+ XMLProperty const * caprop;
for (caiter = calist.begin(); caiter != calist.end(); ++caiter) {
XMLNode* ca = *caiter;
/* it may already exist, so don't recreate it unnecessarily
*/
- XMLProperty* prop = (*niter)->property (X_("id"));
+ XMLProperty const * prop = (*niter)->property (X_("id"));
if (!prop) {
error << _("Nested source has no ID info in session file! (ignored)") << endmsg;
continue;
boost::shared_ptr<Region>
Session::XMLRegionFactory (const XMLNode& node, bool full)
{
- const XMLProperty* type = node.property("type");
+ XMLProperty const * type = node.property("type");
try {
boost::shared_ptr<AudioRegion>
Session::XMLAudioRegionFactory (const XMLNode& node, bool /*full*/)
{
- const XMLProperty* prop;
+ XMLProperty const * prop;
boost::shared_ptr<Source> source;
boost::shared_ptr<AudioSource> as;
SourceList sources;
boost::shared_ptr<MidiRegion>
Session::XMLMidiRegionFactory (const XMLNode& node, bool /*full*/)
{
- const XMLProperty* prop;
+ XMLProperty const * prop;
boost::shared_ptr<Source> source;
boost::shared_ptr<MidiSource> ms;
SourceList sources;
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
- XMLProperty* prop;
+ XMLProperty const * prop;
if ((prop = (*niter)->property (X_("type"))) == 0) {
continue;
Session::controllable_by_descriptor (const ControllableDescriptor& desc)
{
boost::shared_ptr<Controllable> c;
+ boost::shared_ptr<Stripable> s;
boost::shared_ptr<Route> r;
switch (desc.top_level_type()) {
case ControllableDescriptor::NamedRoute:
{
std::string str = desc.top_level_name();
+
if (str == "Master" || str == "master") {
- r = _master_out;
- } else if (str == "control" || str == "listen") {
- r = _monitor_out;
+ s = _master_out;
+ } else if (str == "control" || str == "listen" || str == "monitor" || str == "Monitor") {
+ s = _monitor_out;
+ } else if (str == "auditioner") {
+ s = auditioner;
} else {
- r = route_by_name (desc.top_level_name());
+ s = route_by_name (desc.top_level_name());
}
+
break;
}
- case ControllableDescriptor::RemoteControlID:
- r = route_by_remote_id (desc.rid());
+ case ControllableDescriptor::PresentationOrderRoute:
+ s = get_remote_nth_stripable (desc.presentation_order(), PresentationInfo::Route);
+ break;
+
+ case ControllableDescriptor::PresentationOrderTrack:
+ s = get_remote_nth_stripable (desc.presentation_order(), PresentationInfo::Track);
+ break;
+
+ case ControllableDescriptor::PresentationOrderBus:
+ s = get_remote_nth_stripable (desc.presentation_order(), PresentationInfo::Bus);
+ break;
+
+ case ControllableDescriptor::PresentationOrderVCA:
+ s = get_remote_nth_stripable (desc.presentation_order(), PresentationInfo::VCA);
break;
case ControllableDescriptor::SelectionCount:
- r = route_by_selected_count (desc.selection_id());
+ s = route_by_selected_count (desc.selection_id());
break;
}
- if (!r) {
+ if (!s) {
return c;
}
+ r = boost::dynamic_pointer_cast<Route> (s);
+
switch (desc.subtype()) {
case ControllableDescriptor::Gain:
- c = r->gain_control ();
+ c = s->gain_control ();
break;
case ControllableDescriptor::Trim:
- c = r->trim()->gain_control ();
+ c = s->trim_control ();
break;
case ControllableDescriptor::Solo:
- c = r->solo_control();
+ c = s->solo_control();
break;
case ControllableDescriptor::Mute:
- c = r->mute_control();
+ c = s->mute_control();
break;
case ControllableDescriptor::Recenable:
- {
- boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(r);
-
- if (t) {
- c = t->rec_enable_control ();
- }
+ c = s->rec_enable_control ();
break;
- }
case ControllableDescriptor::PanDirection:
- c = r->pan_azimuth_control();
+ c = s->pan_azimuth_control();
break;
case ControllableDescriptor::PanWidth:
- c = r->pan_width_control();
+ c = s->pan_width_control();
break;
case ControllableDescriptor::PanElevation:
- c = r->pan_elevation_control();
+ c = s->pan_elevation_control();
break;
case ControllableDescriptor::Balance:
--parameter_index;
}
+ if (!r) {
+ return c;
+ }
+
boost::shared_ptr<Processor> p = r->nth_plugin (plugin);
if (p) {
if (send > 0) {
--send;
}
+ if (!r) {
+ return c;
+ }
c = r->send_level_controllable (send);
break;
}
} else if (p == "solo-control-is-listen-control") {
solo_control_mode_changed ();
} else if (p == "solo-mute-gain") {
- _solo_cut_control->Changed();
+ _solo_cut_control->Changed (true, Controllable::NoGroup);
} else if (p == "timecode-offset" || p == "timecode-offset-negative") {
last_timecode_valid = false;
} else if (p == "playback-buffer-seconds") {
/* sample rate */
- const XMLProperty* prop;
- if ((prop = tree.root()->property (X_("sample-rate"))) != 0) {
+ XMLProperty const * prop;
+ XMLNode const * root (tree.root());
+
+ if ((prop = root->property (X_("sample-rate"))) != 0) {
sample_rate = atoi (prop->value());
found_sr = true;
}
- const XMLNodeList& children (tree.root()->children());
+ const XMLNodeList& children (root->children());
for (XMLNodeList::const_iterator c = children.begin(); c != children.end(); ++c) {
const XMLNode* child = *c;
if (child->name() == "Config") {
const XMLNodeList& options (child->children());
for (XMLNodeList::const_iterator oc = options.begin(); oc != options.end(); ++oc) {
- const XMLNode* option = *oc;
- const XMLProperty* name = option->property("name");
+ XMLNode const * option = *oc;
+ XMLProperty const * name = option->property("name");
if (!name) {
continue;
}
if (name->value() == "native-file-data-format") {
- const XMLProperty* value = option->property ("value");
+ XMLProperty const * value = option->property ("value");
if (value) {
SampleFormat fmt = (SampleFormat) string_2_enum (option->property ("value")->value(), fmt);
data_format = fmt;
return "";
}
- const XMLProperty* prop;
+ XMLProperty const * prop;
XMLNode *last_used_snapshot = tree.root()->child("LastUsedSnapshot");
if (last_used_snapshot && (prop = last_used_snapshot->property ("name")) != 0) {
return prop->value();