DummyBackend: fix midi event mux+sorting
[ardour.git] / libs / ardour / butler.cc
index 1fe15246183c89575782e5e4f505c562bcbf6bb7..327665441ea0c127ddaa02d44753b9b0a90da520 100644 (file)
@@ -43,6 +43,7 @@ namespace ARDOUR {
 Butler::Butler(Session& s)
        : SessionHandleRef (s)
        , thread()
+       , have_thread (false)
        , audio_dstream_capture_buffer_size(0)
        , audio_dstream_playback_buffer_size(0)
        , midi_dstream_buffer_size(0)
@@ -126,16 +127,18 @@ Butler::start_thread()
        }
 
        //pthread_detach (thread);
-
+       have_thread = true;
        return 0;
 }
 
 void
 Butler::terminate_thread ()
 {
-       void* status;
-       queue_request (Request::Quit);
-       pthread_join (thread, &status);
+       if (have_thread) {
+               void* status;
+               queue_request (Request::Quit);
+               pthread_join (thread, &status);
+       }
 }
 
 void *
@@ -257,6 +260,14 @@ restart:
                        _session.butler_transport_work ();
                }
 
+               frameoffset_t audition_seek;
+               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());
+                       tr->seek(audition_seek);
+                       _session.the_auditioner()->seek_response(audition_seek);
+               }
+
                boost::shared_ptr<RouteList> rl = _session.get_routes();
 
                RouteList rl_with_auditioner = *rl;