summaryrefslogtreecommitdiff
path: root/libs/ardour/audio_track.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour/audio_track.cc')
-rw-r--r--libs/ardour/audio_track.cc58
1 files changed, 41 insertions, 17 deletions
diff --git a/libs/ardour/audio_track.cc b/libs/ardour/audio_track.cc
index 0fdd523f8f..920367ae94 100644
--- a/libs/ardour/audio_track.cc
+++ b/libs/ardour/audio_track.cc
@@ -47,6 +47,22 @@ using namespace PBD;
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);
if (_flags & Hidden) {
@@ -55,27 +71,17 @@ AudioTrack::AudioTrack (Session& sess, string name, Route::Flag flag, TrackMode
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)
{
@@ -269,8 +275,19 @@ AudioTrack::_set_state (const XMLNode& node, bool call_base)
} 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;
}
}
@@ -292,7 +309,11 @@ AudioTrack::_set_state (const XMLNode& node, bool call_base)
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;
}
@@ -353,8 +374,11 @@ AudioTrack::set_state_part_two ()
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) {