From 32224ee60800a86fb53cef05e157a9246be21018 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 8 May 2015 20:56:10 -0400 Subject: add in more Tracks-related auto-(re)connect changes --- libs/ardour/ardour/session.h | 5 +++++ libs/ardour/session.cc | 49 +++++++++++++++++++++++++++++++++++++++++++- libs/ardour/session_state.cc | 30 +++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index f6837a6e47..9f560524f4 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -305,6 +305,9 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop */ PBD::Signal0 RecordArmStateChanged; /* signals changes in recording arming */ + /* Emited when session is loaded */ + PBD::Signal0 SessionLoaded; + /* Transport mechanism signals */ /** Emitted on the following changes in transport state: @@ -1266,6 +1269,8 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop int post_engine_init (); int immediately_post_engine (); void remove_empty_sounds (); + + void session_loaded (); void setup_midi_control (); int midi_read (MIDI::Port *); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index c6b15307c0..39ddbce1ad 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -376,8 +376,51 @@ Session::Session (AudioEngine &eng, _engine.set_session (this); _engine.reset_timebase (); - BootMessage (_("Session loading complete")); +#ifdef USE_TRACKS_CODE_FEATURES + + EngineStateController::instance()->set_session(this); + + if (_is_new ) { + if ( ARDOUR::Profile->get_trx () ) { + /* Waves Tracks: fill session with tracks basing on the amount of inputs. + * each available input must have corresponding track when session starts. + */ + + uint32_t how_many (0); + + std::vector inputs; + EngineStateController::instance()->get_physical_audio_inputs(inputs); + + how_many = inputs.size(); + + list > tracks; + + // Track names after driver + if (Config->get_tracks_auto_naming() == NameAfterDriver) { + string track_name = ""; + for (std::vector::size_type i = 0; i < inputs.size(); ++i) { + string track_name; + remove_pattern_from_string(inputs[i], "system:capture:", track_name); + + list > single_track = new_audio_track (1, 1, Normal, 0, 1, track_name); + tracks.insert(tracks.begin(), single_track.front()); + } + } else { // Default track names + tracks = new_audio_track (1, 1, Normal, 0, how_many, string()); + } + + if (tracks.size() != how_many) { + destroy (); + throw failed_constructor (); + } + } + } +#endif + + _is_new = false; + session_loaded (); + BootMessage (_("Session loading complete")); } Session::~Session () @@ -486,6 +529,10 @@ Session::destroy () _engine.remove_session (); +#ifdef USE_TRACKS_CODE_FEATURES + EngineStateController::instance()->remove_session(); +#endif + /* deregister all ports - there will be no process or any other * callbacks from the engine any more. */ diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 267eaa0928..eca01cbe99 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -355,6 +355,36 @@ Session::post_engine_init () return 0; } +void +Session::session_loaded () +{ + SessionLoaded(); + + _state_of_the_state = Clean; + + DirtyChanged (); /* EMIT SIGNAL */ + + if (_is_new) { + save_state (""); + } else if (state_was_pending) { + save_state (""); + remove_pending_capture_state (); + state_was_pending = false; + } + + /* Now, finally, we can fill the playback buffers */ + + BootMessage (_("Filling playback buffers")); + + boost::shared_ptr rl = routes.reader(); + for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) { + boost::shared_ptr trk = boost::dynamic_pointer_cast (*r); + if (trk && !trk->hidden()) { + trk->seek (_transport_frame, true); + } + } +} + string Session::raid_path () const { -- cgit v1.2.3