diff --git a/libs/ardour/ardour/cliprec.h b/libs/ardour/ardour/cliprec.h index 83fce5772e..3937a60425 100644 --- a/libs/ardour/ardour/cliprec.h +++ b/libs/ardour/ardour/cliprec.h @@ -24,6 +24,10 @@ #include "ardour/processor.h" +namespace PBD { +class Thread; +} + namespace ARDOUR { class AudioFileSource; @@ -71,6 +75,12 @@ class LIBARDOUR_API ClipRecProcessor : public Processor /* The MIDI stuff */ MidiRingBuffer* _midi_buf; + + /* private (to class) butler thread */ + + static PBD::Thread* _thread; + static bool thread_should_run; + static void thread_work (); }; } /* namespace */ diff --git a/libs/ardour/cliprec.cc b/libs/ardour/cliprec.cc index 9040213c55..cbd8fade8c 100644 --- a/libs/ardour/cliprec.cc +++ b/libs/ardour/cliprec.cc @@ -18,6 +18,7 @@ #include "pbd/compose.h" #include "pbd/debug.h" +#include "pbd/pthread_utils.h" #include "ardour/audio_buffer.h" #include "ardour/cliprec.h" @@ -27,11 +28,25 @@ using namespace ARDOUR; using namespace PBD; +PBD::Thread* ClipRecProcessor::_thread (0); +bool ClipRecProcessor::thread_should_run (false); + ClipRecProcessor::ClipRecProcessor (Session& s, Track& t, std::string const & name) : Processor (s, name, Temporal::BeatTime) , _track (t) , channels (new ChannelList) { + if (!_thread) { + thread_should_run = true; + _thread = PBD::Thread::create (&ClipRecProcessor::thread_work); + } +} + +void +ClipRecProcessor::thread_work () +{ + while (thread_should_run) { + } } bool @@ -110,7 +125,7 @@ ClipRecProcessor::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t en for (MidiBuffer::iterator i = buf.begin(); i != buf.end(); ++i) { Evoral::Event ev (*i, false); - if (ev.time() > nframes) { + if (ev.time() > nframes) { break; }