Fix some compilation warnings
[ardour.git] / libs / ardour / butler.cc
index ad31c71e1527f85864bd8e6b4c93a26c926df0e1..db1b316368e7d1b0fc3f4cb5e6ba72a48cefc33f 100644 (file)
@@ -24,7 +24,6 @@
 #include "pbd/error.h"
 #include "pbd/pthread_utils.h"
 #include "ardour/butler.h"
-#include "ardour/crossfade.h"
 #include "ardour/io.h"
 #include "ardour/midi_diskstream.h"
 #include "ardour/session.h"
@@ -35,9 +34,6 @@
 
 using namespace PBD;
 
-static float _read_data_rate;
-static float _write_data_rate;
-
 namespace ARDOUR {
 
 Butler::Butler(Session& s)
@@ -89,8 +85,6 @@ Butler::start_thread()
 
        MidiDiskstream::set_readahead_frames ((framecnt_t) (Config->get_midi_readahead() * rate));
 
-       Crossfade::set_buffer_size (audio_dstream_playback_buffer_size);
-
        should_run = false;
 
        if (pipe (request_pipe)) {
@@ -144,9 +138,6 @@ void *
 Butler::thread_work ()
 {
        uint32_t err = 0;
-       int32_t bytes;
-       bool compute_io;
-       microseconds_t begin, end;
 
        struct pollfd pfd[1];
        bool disk_work_outstanding = false;
@@ -185,9 +176,6 @@ Butler::thread_work ()
 
                                        switch ((Request::Type) req) {
 
-                                       case Request::Wake:
-                                               break;
-
                                        case Request::Run:
                                                should_run = true;
                                                break;
@@ -217,9 +205,6 @@ Butler::thread_work ()
                }
 
 
-               bytes = 0;
-               compute_io = true;
-
 restart:
                disk_work_outstanding = false;
 
@@ -227,8 +212,6 @@ restart:
                        _session.butler_transport_work ();
                }
 
-               begin = get_microseconds();
-
                boost::shared_ptr<RouteList> rl = _session.get_routes();
 
                RouteList rl_with_auditioner = *rl;
@@ -241,29 +224,27 @@ restart:
                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) {
                                continue;
                        }
 
-                       /* don't read inactive tracks */
-
                        boost::shared_ptr<IO> io = tr->input ();
 
                        if (io && !io->active()) {
+                               /* don't read inactive tracks */
                                continue;
                        }
 
                        switch (tr->do_refill ()) {
                        case 0:
-                               bytes += tr->read_data_count();
                                break;
+                               
                        case 1:
-                               bytes += tr->read_data_count();
                                disk_work_outstanding = true;
                                break;
 
                        default:
-                               compute_io = false;
                                error << string_compose(_("Butler read ahead failure on dstream %1"), (*i)->name()) << endmsg;
                                break;
                        }
@@ -279,23 +260,11 @@ restart:
                        goto restart;
                }
 
-               if (compute_io) {
-                       end = get_microseconds();
-                       if (end - begin > 0) {
-                               _read_data_rate = (float) bytes / (float) (end - begin);
-                       } else {
-                               _read_data_rate = 0; // infinity better
-                       }
-               }
-
-               bytes = 0;
-               compute_io = true;
-               begin = get_microseconds();
-
                for (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) {
                                continue;
                        }
@@ -305,16 +274,14 @@ restart:
 
                        switch (tr->do_flush (ButlerContext)) {
                        case 0:
-                               bytes += tr->write_data_count();
                                break;
+                               
                        case 1:
-                               bytes += tr->write_data_count();
                                disk_work_outstanding = true;
                                break;
 
                        default:
                                err++;
-                               compute_io = false;
                                error << string_compose(_("Butler write-behind failure on dstream %1"), (*i)->name()) << endmsg;
                                /* don't break - try to flush all streams in case they
                                   are split across disks.
@@ -338,23 +305,13 @@ restart:
                        goto restart;
                }
 
-               if (compute_io) {
-                       // there are no apparent users for this calculation?
-                       end = get_microseconds();
-                       if (end - begin > 0) {
-                               _write_data_rate = (float) bytes / (float) (end - begin);
-                       } else {
-                               _write_data_rate = 0; // Well, infinity would be better
-                       }
-               }
-
                if (!disk_work_outstanding) {
                        _session.refresh_disk_space ();
                }
 
 
                {
-                       Glib::Mutex::Lock lm (request_lock);
+                       Glib::Threads::Mutex::Lock lm (request_lock);
 
                        if (should_run && (disk_work_outstanding || transport_work_requested())) {
 //                             for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) {
@@ -392,7 +349,7 @@ Butler::summon ()
 void
 Butler::stop ()
 {
-       Glib::Mutex::Lock lm (request_lock);
+       Glib::Threads::Mutex::Lock lm (request_lock);
        char c = Request::Pause;
        (void) ::write (request_pipe[1], &c, 1);
        paused.wait(request_lock);
@@ -401,8 +358,8 @@ Butler::stop ()
 void
 Butler::wait_until_finished ()
 {
-       Glib::Mutex::Lock lm (request_lock);
-       char c = Request::Wake;
+       Glib::Threads::Mutex::Lock lm (request_lock);
+       char c = Request::Pause;
        (void) ::write (request_pipe[1], &c, 1);
        paused.wait(request_lock);
 }
@@ -413,24 +370,6 @@ Butler::transport_work_requested () const
        return g_atomic_int_get(&should_do_transport_work);
 }
 
-float
-Butler::read_data_rate () const
-{
-       /* disk i/o in excess of 10000MB/sec indicate the buffer cache
-          in action. ignore it.
-       */
-       return _read_data_rate > 10485.7600000f ? 0.0f : _read_data_rate;
-}
-
-float
-Butler::write_data_rate () const
-{
-       /* disk i/o in excess of 10000MB/sec indicate the buffer cache
-          in action. ignore it.
-       */
-       return _write_data_rate > 10485.7600000f ? 0.0f : _write_data_rate;
-}
-
 void
 Butler::empty_pool_trash ()
 {