add left/right side trim cursors and use them for region trimming, as appropriate
[ardour.git] / libs / ardour / butler.cc
index 35fb6bcc035c9f70bce30a47855fd4824ceea76e..1efca35196b1072615ada74ebc51dd2d97c37909 100644 (file)
@@ -29,6 +29,7 @@
 #include "ardour/midi_diskstream.h"
 #include "ardour/session.h"
 #include "ardour/track.h"
+#include "ardour/auditioner.h"
 
 #include "i18n.h"
 
@@ -42,12 +43,15 @@ namespace ARDOUR {
 Butler::Butler(Session& s)
        : SessionHandleRef (s)
        , thread(0)
-       , audio_dstream_buffer_size(0)
+       , audio_dstream_capture_buffer_size(0)
+       , audio_dstream_playback_buffer_size(0)
        , midi_dstream_buffer_size(0)
        , pool_trash(16)
 {
        g_atomic_int_set(&should_do_transport_work, 0);
        SessionEvent::pool->set_trash (&pool_trash);
+
+        Config->ParameterChanged.connect_same_thread (*this, boost::bind (&Butler::config_changed, this, _1));
 }
 
 Butler::~Butler()
@@ -55,13 +59,27 @@ Butler::~Butler()
        terminate_thread ();
 }
 
+void
+Butler::config_changed (std::string p)
+{
+        if (p == "playback-buffer-seconds") {
+                /* size is in Samples, not bytes */
+                audio_dstream_playback_buffer_size = (uint32_t) floor (Config->get_audio_playback_buffer_seconds() * _session.frame_rate());
+                _session.adjust_playback_buffering ();
+        } else if (p == "capture-buffer-seconds") {
+                audio_dstream_capture_buffer_size = (uint32_t) floor (Config->get_audio_capture_buffer_seconds() * _session.frame_rate());
+                _session.adjust_capture_buffering ();
+        }
+}
+
 int
 Butler::start_thread()
 {
        const float rate = (float)_session.frame_rate();
 
        /* size is in Samples, not bytes */
-       audio_dstream_buffer_size = (uint32_t) floor (Config->get_audio_track_buffer_seconds() * rate);
+       audio_dstream_capture_buffer_size = (uint32_t) floor (Config->get_audio_capture_buffer_seconds() * rate);
+       audio_dstream_playback_buffer_size = (uint32_t) floor (Config->get_audio_playback_buffer_seconds() * rate);
 
        /* size is in bytes
         * XXX: Jack needs to tell us the MIDI buffer size
@@ -71,7 +89,7 @@ Butler::start_thread()
 
        MidiDiskstream::set_readahead_frames ((nframes_t)(Config->get_midi_readahead() * rate));
 
-       Crossfade::set_buffer_size (audio_dstream_buffer_size);
+       Crossfade::set_buffer_size (audio_dstream_playback_buffer_size);
 
        should_run = false;
 
@@ -210,11 +228,14 @@ Butler::thread_work ()
 
                boost::shared_ptr<RouteList> rl = _session.get_routes();
 
+               RouteList rl_with_auditioner = *rl;
+               rl_with_auditioner.push_back (_session.the_auditioner());
+
 //             for (i = dsl->begin(); i != dsl->end(); ++i) {
 //                     cerr << "BEFORE " << (*i)->name() << ": pb = " << (*i)->playback_buffer_load() << " cp = " << (*i)->capture_buffer_load() << endl;
 //             }
 
-               for (i = rl->begin(); !transport_work_requested() && should_run && i != rl->end(); ++i) {
+               for (i = rl_with_auditioner.begin(); !transport_work_requested() && should_run && i != rl_with_auditioner.end(); ++i) {
 
                        boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
                        if (!tr) {
@@ -246,7 +267,7 @@ Butler::thread_work ()
 
                }
 
-               if (i != rl->begin() && i != rl->end()) {
+               if (i != rl_with_auditioner.begin() && i != rl_with_auditioner.end()) {
                        /* we didn't get to all the streams */
                        disk_work_outstanding = true;
                }