allow auditioning via the monitor section to work.
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 16 Jan 2014 22:22:19 +0000 (17:22 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 16 Jan 2014 22:22:19 +0000 (17:22 -0500)
Ideally, we would feed the monitor section via an internal (aux) send/return, but this is an improvement over what we had before

libs/ardour/ardour/auditioner.h
libs/ardour/audio_buffer.cc
libs/ardour/auditioner.cc
libs/ardour/route.cc
libs/ardour/session.cc
libs/ardour/session_process.cc

index bdd04fcc66d72f02bb4df3f62d038af00a797968..5ce3ddaddf423bf66a37e095cb0bd6cde9ff1c60 100644 (file)
@@ -40,6 +40,7 @@ class Auditioner : public AudioTrack
        ~Auditioner ();
 
        int init ();
+        int connect ();
 
        void audition_region (boost::shared_ptr<Region>);
 
index b4e2a55ac2e7d38452e4dda3a7517dbaf03880fa..aa4f64755aeb9399d31e402b8703eae2dd1a4d1d 100644 (file)
@@ -88,7 +88,7 @@ AudioBuffer::check_silence (pframes_t nframes, bool wholebuffer, pframes_t& n) c
 
 void
 AudioBuffer::silence (framecnt_t len, framecnt_t offset) {
-       pframes_t n = 0;
+
        if (!_silent) {
                assert(_capacity > 0);
                assert(offset + len <= _capacity);
index 9f7dd85b52ad24513323712519e65cd33c6bcd88..73670798d8adf2963d6a786e16f80f936a014cc7 100644 (file)
@@ -54,13 +54,31 @@ Auditioner::init ()
         if (Track::init ()) {
                 return -1;
         }
+       
+       if (connect ()) {
+               return -1;
+       }
+
+       _output->changed.connect_same_thread (*this, boost::bind (&Auditioner::output_changed, this, _1, _2));
+
+        return 0;
+}
+
+Auditioner::~Auditioner ()
+{
+}
 
+int
+Auditioner::connect ()
+{
        string left = Config->get_auditioner_output_left();
        string right = Config->get_auditioner_output_right();
 
        vector<string> outputs;
        _session.engine().get_physical_outputs (DataType::AUDIO, outputs);
 
+       via_monitor = false;
+
        if (left.empty() || left == "default") {
                 if (_session.monitor_out()) {
                         left = _session.monitor_out()->input()->audio (0)->name();
@@ -83,31 +101,49 @@ Auditioner::init ()
                 }
        }
 
+       _output->disconnect (this);
+
        if (left.empty() && right.empty()) {
-               warning << _("no outputs available for auditioner - manual connection required") << endmsg;
+               if (_output->n_ports().n_audio() == 0) {
+                       /* ports not set up, so must be during startup */
+                       warning << _("no outputs available for auditioner - manual connection required") << endmsg;
+               }
        } else {
 
-               _main_outs->defer_pan_reset ();
-               
-               if (left.length()) {
-                       _output->add_port (left, this, DataType::AUDIO);
-               }
-               
-               if (right.length()) {
-                       _output->add_port (right, this, DataType::AUDIO);
-               }
-               
-               _main_outs->allow_pan_reset ();
-               _main_outs->reset_panner ();
-       }
+               if (_output->n_ports().n_audio() == 0) {
 
-       _output->changed.connect_same_thread (*this, boost::bind (&Auditioner::output_changed, this, _1, _2));
+                       /* create (and connect) new ports */
 
-        return 0;
-}
+                       _main_outs->defer_pan_reset ();
+                       
+                       if (left.length()) {
+                               _output->add_port (left, this, DataType::AUDIO);
+                       }
+                       
+                       if (right.length()) {
+                               _output->add_port (right, this, DataType::AUDIO);
+                       }
+                       
+                       _main_outs->allow_pan_reset ();
+                       _main_outs->reset_panner ();
 
-Auditioner::~Auditioner ()
-{
+               } else {
+                       
+                       /* reconnect existing ports */
+
+                       boost::shared_ptr<Port> oleft (_output->nth (0));
+                       boost::shared_ptr<Port> oright (_output->nth (1));
+                       if (oleft) {
+                               oleft->connect (left);
+                       }
+                       if (oright) {
+                               oright->connect (right);
+                       }
+               }
+                       
+       }
+
+       return 0;
 }
 
 AudioPlaylist&
index f994fe3d6948a8384e14bcc39cc3810fa3a38ad3..046bf7998e520ca0e557227301e4ac1bb2527431 100644 (file)
@@ -544,6 +544,7 @@ Route::monitor_run (framepos_t start_frame, framepos_t end_frame, pframes_t nfra
 {
        assert (is_monitor());
        BufferSet& bufs (_session.get_route_buffers (n_process_buffers()));
+       fill_buffers_with_input (bufs, _input, nframes);
        passthru (bufs, start_frame, end_frame, nframes, declick);
 }
 
index 115fcd750ad970b33d9713a0dba6af2ca741c347..53d670a1f41bfa881abe8d1c26f3e00893de689c 100644 (file)
@@ -805,6 +805,12 @@ Session::remove_monitor_section ()
        /* force reversion to Solo-In-Place */
        Config->set_solo_control_is_listen_control (false);
 
+       /* if we are auditioning, cancel it ... this is a workaround
+          to a problem (auditioning does not execute the process graph,
+          which is needed to remove routes when using >1 core for processing)
+       */
+       cancel_audition ();
+
        {
                /* Hold process lock while doing this so that we don't hear bits and
                 * pieces of audio as we work on each route.
@@ -835,6 +841,10 @@ Session::remove_monitor_section ()
 
        remove_route (_monitor_out);
        auto_connect_master_bus ();
+
+       if (auditioner) {
+               auditioner->connect ();
+       }
 }
 
 void
@@ -979,6 +989,10 @@ Session::add_monitor_section ()
                        (*x)->enable_monitor_send ();
                }
        }
+
+       if (auditioner) {
+               auditioner->connect ();
+       }
 }
 
 void
index 6d8c0f9f70323ddd56f92fcc2a41a92e83b8b368..6bfb250aecbc4851aae2a8bf0d1578089f5ec98f 100644 (file)
@@ -875,7 +875,7 @@ Session::process_audition (pframes_t nframes)
 
        /* if using a monitor section, run it because otherwise we don't hear anything */
 
-       if (auditioner->needs_monitor()) {
+       if (_monitor_out && auditioner->needs_monitor()) {
                _monitor_out->monitor_run (_transport_frame, _transport_frame + nframes, nframes, false);
        }