Merge libs/ardour and gtk2_ardour with 2.0-ongoing R2837.
[ardour.git] / libs / ardour / session_butler.cc
index 6c3fdea7e6846e903a95e21240834aa2cfa045cb..148ff9273993cf50fbf9dd7b6d358ccdc1c6d013 100644 (file)
@@ -103,10 +103,12 @@ Session::start_butler_thread ()
 void
 Session::terminate_butler_thread ()
 {
-       void* status;
-       char c = ButlerRequest::Quit;
-       ::write (butler_request_pipe[1], &c, 1);
-       pthread_join (butler_thread, &status);
+       if (butler_thread) {
+               void* status;
+               char c = ButlerRequest::Quit;
+               ::write (butler_request_pipe[1], &c, 1);
+               pthread_join (butler_thread, &status);
+       }
 }
 
 void
@@ -231,10 +233,6 @@ Session::butler_thread_work ()
                        }
                }
 
-               //for (i = diskstreams.begin(); i != diskstreams.end(); ++i) {
-                       // cerr << "BEFORE " << (*i)->name() << ": pb = " << (*i)->playback_buffer_load() << " cp = " << (*i)->capture_buffer_load() << endl;
-               //}
-
                if (transport_work_requested()) {
                        butler_transport_work ();
                }
@@ -246,11 +244,24 @@ Session::butler_thread_work ()
                gettimeofday (&begin, 0);
 
                boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader ();
-               
+
+//             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 = dsl->begin(); !transport_work_requested() && butler_should_run && i != dsl->end(); ++i) {
 
                        boost::shared_ptr<Diskstream> ds = *i;
 
+                       /* don't read inactive tracks */
+
+                       /*IO* io = ds->io();
+                       
+                       if (ds->io() && !ds->io()->active()) {
+                               cerr << "Skip inactive diskstream " << ds->io()->name() << endl;
+                               continue;
+                       }*/
+
                        switch (ds->do_refill ()) {
                        case 0:
                                bytes += ds->read_data_count();
@@ -292,6 +303,9 @@ Session::butler_thread_work ()
 
                for (i = dsl->begin(); !transport_work_requested() && butler_should_run && i != dsl->end(); ++i) {
                        // cerr << "write behind for " << (*i)->name () << endl;
+
+                       /* note that we still try to flush diskstreams attached to inactive routes
+                        */
                        
                        switch ((*i)->do_flush (Session::ButlerContext)) {
                        case 0: