add in more Tracks-related auto-(re)connect changes
authorPaul Davis <paul@linuxaudiosystems.com>
Sat, 9 May 2015 00:56:10 +0000 (20:56 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 29 Jun 2015 18:18:11 +0000 (14:18 -0400)
libs/ardour/ardour/session.h
libs/ardour/session.cc
libs/ardour/session_state.cc

index f6837a6e475cbc5a04b1fc669599d7dcb2d2509c..9f560524f4124083f008852471f13327b057c24e 100644 (file)
@@ -305,6 +305,9 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        */
        PBD::Signal0<void> RecordArmStateChanged; /* signals changes in recording arming */
 
+       /* Emited when session is loaded */
+       PBD::Signal0<void> 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 *);
index c6b15307c017d64b291c53a73541cb56a67d330b..39ddbce1ad6537b0e5088cebdd02c6a7b3ec66a2 100644 (file)
@@ -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<std::string> inputs;
+                       EngineStateController::instance()->get_physical_audio_inputs(inputs);
+                       
+                       how_many = inputs.size();
+                       
+                       list<boost::shared_ptr<AudioTrack> > tracks;
+                       
+                       // Track names after driver 
+                       if (Config->get_tracks_auto_naming() == NameAfterDriver) {
+                               string track_name = "";
+                               for (std::vector<string>::size_type i = 0; i < inputs.size(); ++i) {
+                                       string track_name;
+                                       remove_pattern_from_string(inputs[i], "system:capture:", track_name);
+                                       
+                                       list<boost::shared_ptr<AudioTrack> > 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.
         */
index 267eaa092869d8fe24ad225070ce8a5c25601da7..eca01cbe9995313436d7cdf069217503fb87c3c0 100644 (file)
@@ -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<RouteList> rl = routes.reader();
+       for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) {
+               boost::shared_ptr<Track> trk = boost::dynamic_pointer_cast<Track> (*r);
+               if (trk && !trk->hidden()) {
+                       trk->seek (_transport_frame, true);
+               }
+       }
+}
+
 string
 Session::raid_path () const
 {