#include <fcntl.h>
#include <unistd.h>
-#ifndef WIN32
+#ifndef PLATFORM_WINDOWS
#include <poll.h>
#endif
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)
}
}
-#ifndef WIN32
+#ifndef PLATFORM_WINDOWS
int
Butler::setup_request_pipe ()
{
should_run = false;
-#ifndef WIN32
+#ifndef PLATFORM_WINDOWS
if (setup_request_pipe() != 0) return -1;
#endif
}
//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 *
bool
Butler::wait_for_requests ()
{
-#ifndef WIN32
+#ifndef PLATFORM_WINDOWS
struct pollfd pfd[1];
pfd[0].fd = request_pipe[0];
bool
Butler::dequeue_request (Request::Type& r)
{
-#ifndef WIN32
+#ifndef PLATFORM_WINDOWS
char req;
size_t nread = ::read (request_pipe[0], &req, sizeof (req));
if (nread == 1) {
Request::Type req;
/* empty the pipe of all current requests */
-#ifdef WIN32
+#ifdef PLATFORM_WINDOWS
dequeue_request (req);
{
#else
break;
case Request::Quit:
- pthread_exit_pbd (0);
+ return 0;
/*NOTREACHED*/
break;
_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;
empty_pool_trash ();
}
- pthread_exit_pbd (0);
- /*NOTREACHED*/
return (0);
}
void
Butler::queue_request (Request::Type r)
{
-#ifndef WIN32
+#ifndef PLATFORM_WINDOWS
char c = r;
(void) ::write (request_pipe[1], &c, 1);
#else
void
Butler::drop_references ()
{
+ cerr << "Butler drops pool trash\n";
SessionEvent::pool->set_trash (0);
}