AudioTrack::AudioTrack (Session& sess, string name, Route::Flag flag, TrackMode mode)
: Track (sess, name, flag, mode)
+{
+ use_new_diskstream ();
+}
+
+AudioTrack::AudioTrack (Session& sess, const XMLNode& node)
+ : Track (sess, node)
+{
+ _set_state (node, false);
+}
+
+AudioTrack::~AudioTrack ()
+{
+}
+
+void
+AudioTrack::use_new_diskstream ()
{
AudioDiskstream::Flag dflags = AudioDiskstream::Flag (0);
dflags = AudioDiskstream::Flag (dflags | AudioDiskstream::Recordable);
}
- if (mode == Destructive) {
+ if (_mode == Destructive) {
dflags = AudioDiskstream::Flag (dflags | AudioDiskstream::Destructive);
}
- boost::shared_ptr<AudioDiskstream> ds (new AudioDiskstream (_session, name, dflags));
+ boost::shared_ptr<AudioDiskstream> ds (new AudioDiskstream (_session, name(), dflags));
_session.add_diskstream (ds);
set_diskstream (boost::dynamic_pointer_cast<AudioDiskstream> (ds), this);
}
-AudioTrack::AudioTrack (Session& sess, const XMLNode& node)
- : Track (sess, node)
-{
- _set_state (node, false);
-}
-
-AudioTrack::~AudioTrack ()
-{
-}
-
int
AudioTrack::set_mode (TrackMode m)
{
} else {
PBD::ID id (prop->value());
-
- if (use_diskstream (id)) {
+ PBD::ID zero ("0");
+
+ /* this wierd hack is used when creating tracks from a template. there isn't
+ a particularly good time to interpose between setting the first part of
+ the track state (notably Route::set_state() and the track mode), and the
+ second part (diskstream stuff). So, we have a special ID for the diskstream
+ that means "you should create a new diskstream here, not look for
+ an old one.
+ */
+
+ if (id == zero) {
+ use_new_diskstream ();
+ } else if (use_diskstream (id)) {
return -1;
}
}
pending_state = const_cast<XMLNode*> (&node);
- _session.StateReady.connect (mem_fun (*this, &AudioTrack::set_state_part_two));
+ if (_session.state_of_the_state() & Session::Loading) {
+ _session.StateReady.connect (mem_fun (*this, &AudioTrack::set_state_part_two));
+ } else {
+ set_state_part_two ();
+ }
return 0;
}
XMLProperty* prop;
LocaleGuard lg (X_("POSIX"));
- /* This is called after all session state has been restored but before
- have been made ports and connections are established.
+ /* During session loading: this is called after all session state has been restored but before
+ ports have been created and connections are established.
+
+ During creation from templates: this is called after ports have been created, and connections
+ are established.
*/
if (pending_state == 0) {
/*NOTREACHED*/
}
- IO::set_name_in_state (node_copy, name);
+ IO::set_name_in_state (*node_copy.children().front(), name);
}
+ Track::zero_diskstream_id_in_xml (node_copy);
+
try {
shared_ptr<Route> route (XMLRouteFactory (node_copy));
goto out;
}
+ if (boost::dynamic_pointer_cast<Track>(route)) {
+ /* force input/output change signals so that the new diskstream
+ picks up the configuration of the route. During session
+ loading this normally happens in a different way.
+ */
+ route->input_changed (IOChange (ConfigurationChanged|ConnectionsChanged), this);
+ route->output_changed (IOChange (ConfigurationChanged|ConnectionsChanged), this);
+ }
+
route->set_remote_control_id (control_id);
++control_id;