comment out debug trace output
[ardour.git] / libs / ardour / butler.cc
index f97a99fed26795d6196eca91dbcc423519668d75..3c4af592acfeeb6b78e98c7ca78d942a2ae1c6c5 100644 (file)
 
 #include "pbd/error.h"
 #include "pbd/pthread_utils.h"
-#include "ardour/debug.h"
+
 #include "ardour/butler.h"
+#include "ardour/debug.h"
+#include "ardour/disk_io.h"
+#include "ardour/disk_reader.h"
 #include "ardour/io.h"
-#include "ardour/midi_diskstream.h"
 #include "ardour/session.h"
 #include "ardour/track.h"
 #include "ardour/auditioner.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace PBD;
 
@@ -81,23 +83,27 @@ Butler::config_changed (std::string p)
                        audio_dstream_playback_buffer_size = (uint32_t) floor (Config->get_audio_playback_buffer_seconds() * _session.frame_rate());
                        _session.adjust_playback_buffering ();
                } else {
+#ifndef NDEBUG
                        std::cerr << "Skip explicit buffer seconds, preset in use\n";
+#endif
                }
        } else if (p == "capture-buffer-seconds") {
                if (Config->get_buffering_preset() == Custom) {
                        audio_dstream_capture_buffer_size = (uint32_t) floor (Config->get_audio_capture_buffer_seconds() * _session.frame_rate());
                        _session.adjust_capture_buffering ();
                } else {
+#ifndef NDEBUG
                        std::cerr << "Skip explicit buffer seconds, preset in use\n";
+#endif
                }
        } else if (p == "buffering-preset") {
-               Diskstream::set_buffering_parameters (Config->get_buffering_preset());
+               DiskIOProcessor::set_buffering_parameters (Config->get_buffering_preset());
                audio_dstream_capture_buffer_size = (uint32_t) floor (Config->get_audio_capture_buffer_seconds() * _session.frame_rate());
                audio_dstream_playback_buffer_size = (uint32_t) floor (Config->get_audio_playback_buffer_seconds() * _session.frame_rate());
                _session.adjust_capture_buffering ();
                _session.adjust_playback_buffering ();
        } else if (p == "midi-readahead") {
-               MidiDiskstream::set_readahead_frames ((framecnt_t) (Config->get_midi_readahead() * _session.frame_rate()));
+               DiskReader::set_midi_readahead_frames ((framecnt_t) (Config->get_midi_readahead() * _session.frame_rate()));
        }
 }
 
@@ -105,20 +111,20 @@ int
 Butler::start_thread()
 {
        // set up capture and playback buffering
-       Diskstream::set_buffering_parameters (Config->get_buffering_preset());
-       
+       DiskIOProcessor::set_buffering_parameters (Config->get_buffering_preset());
+
        /* size is in Samples, not bytes */
        const float rate = (float)_session.frame_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: AudioEngine needs to tell us the MIDI buffer size
         * (i.e. how many MIDI bytes we might see in a cycle)
         */
        midi_dstream_buffer_size = (uint32_t) floor (Config->get_midi_track_buffer_seconds() * rate);
 
-       MidiDiskstream::set_readahead_frames ((framecnt_t) (Config->get_midi_readahead() * rate));
+       DiskReader::set_midi_readahead_frames ((framecnt_t) (Config->get_midi_readahead() * rate));
 
        should_run = false;
 
@@ -129,11 +135,11 @@ Butler::start_thread()
 
        //pthread_detach (thread);
        have_thread = true;
-    
+
        // we are ready to request buffer adjustments
        _session.adjust_capture_buffering ();
        _session.adjust_playback_buffering ();
-       
+
        return 0;
 }
 
@@ -198,7 +204,7 @@ Butler::thread_work ()
                        }
                }
 
-               
+
          restart:
                DEBUG_TRACE (DEBUG::Butler, "at restart for disk work\n");
                disk_work_outstanding = false;
@@ -206,12 +212,11 @@ Butler::thread_work ()
                if (transport_work_requested()) {
                        DEBUG_TRACE (DEBUG::Butler, string_compose ("do transport work @ %1\n", g_get_monotonic_time()));
                        _session.butler_transport_work ();
-                       DEBUG_TRACE (DEBUG::Butler, string_compose ("\ttransport work complete @ %1\n", g_get_monotonic_time()));
+                       DEBUG_TRACE (DEBUG::Butler, string_compose ("\ttransport work complete @ %1, twr = %2\n", g_get_monotonic_time(), transport_work_requested()));
                }
 
                frameoffset_t audition_seek;
-               if (should_run && _session.is_auditioning()
-                               && (audition_seek = _session.the_auditioner()->seek_frame()) >= 0) {
+               if (should_run && _session.is_auditioning() && (audition_seek = _session.the_auditioner()->seek_frame()) >= 0) {
                        boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (_session.the_auditioner());
                        DEBUG_TRACE (DEBUG::Butler, "seek the auditioner\n");
                        tr->seek(audition_seek);
@@ -224,6 +229,8 @@ Butler::thread_work ()
                RouteList rl_with_auditioner = *rl;
                rl_with_auditioner.push_back (_session.the_auditioner());
 
+               DEBUG_TRACE (DEBUG::Butler, string_compose ("butler starts refill loop, twr = %1\n", transport_work_requested()));
+
                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);
@@ -236,15 +243,15 @@ Butler::thread_work ()
 
                        if (io && !io->active()) {
                                /* don't read inactive tracks */
-                               DEBUG_TRACE (DEBUG::Butler, string_compose ("butler skips inactive track %1\n", tr->name()));
+                               // DEBUG_TRACE (DEBUG::Butler, string_compose ("butler skips inactive track %1\n", tr->name()));
                                continue;
                        }
-                       DEBUG_TRACE (DEBUG::Butler, string_compose ("butler refills %1, playback load = %2\n", tr->name(), tr->playback_buffer_load()));
+                       // DEBUG_TRACE (DEBUG::Butler, string_compose ("butler refills %1, playback load = %2\n", tr->name(), tr->playback_buffer_load()));
                        switch (tr->do_refill ()) {
                        case 0:
-                               DEBUG_TRACE (DEBUG::Butler, string_compose ("\ttrack refill done %1\n", tr->name()));
+                               //DEBUG_TRACE (DEBUG::Butler, string_compose ("\ttrack refill done %1\n", tr->name()));
                                break;
-                               
+
                        case 1:
                                DEBUG_TRACE (DEBUG::Butler, string_compose ("\ttrack refill unfinished %1\n", tr->name()));
                                disk_work_outstanding = true;
@@ -315,7 +322,7 @@ Butler::flush_tracks_to_disk_normal (boost::shared_ptr<RouteList> rl, uint32_t&
        for (RouteList::iterator i = rl->begin(); !transport_work_requested() && should_run && i != rl->end(); ++i) {
 
                // cerr << "write behind for " << (*i)->name () << endl;
-               
+
                boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
 
                if (!tr) {
@@ -350,7 +357,7 @@ Butler::flush_tracks_to_disk_normal (boost::shared_ptr<RouteList> rl, uint32_t&
        }
 
        return disk_work_outstanding;
-}      
+}
 
 bool
 Butler::flush_tracks_to_disk_after_locate (boost::shared_ptr<RouteList> rl, uint32_t& errors)
@@ -360,7 +367,7 @@ Butler::flush_tracks_to_disk_after_locate (boost::shared_ptr<RouteList> rl, uint
        /* almost the same as the "normal" version except that we do not test
         * for transport_work_requested() and we force flushes.
         */
-       
+
        for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
 
                // cerr << "write behind for " << (*i)->name () << endl;
@@ -399,7 +406,7 @@ Butler::flush_tracks_to_disk_after_locate (boost::shared_ptr<RouteList> rl, uint
        }
 
        return disk_work_outstanding;
-}      
+}
 
 void
 Butler::schedule_transport_work ()