alter Async MIDI port implementation to use crossthreadchannel on all platforms

This commit is contained in:
Paul Davis 2014-12-03 20:53:49 -05:00
parent f72b87b448
commit d762ed8c22
2 changed files with 16 additions and 23 deletions

View file

@ -30,13 +30,13 @@
#include "pbd/ringbuffer.h" #include "pbd/ringbuffer.h"
#include "evoral/Event.hpp" #include "evoral/Event.hpp"
#include "evoral/EventRingBuffer.hpp"
#include "midi++/types.h" #include "midi++/types.h"
#include "midi++/parser.h" #include "midi++/parser.h"
#include "midi++/port.h" #include "midi++/port.h"
#include "ardour/libardour_visibility.h" #include "ardour/libardour_visibility.h"
#include "ardour/event_ring_buffer.h"
#include "ardour/midi_port.h" #include "ardour/midi_port.h"
namespace ARDOUR { namespace ARDOUR {
@ -62,20 +62,15 @@ class LIBARDOUR_API AsyncMIDIPort : public ARDOUR::MidiPort, public MIDI::Port {
/* clears async request communication channel */ /* clears async request communication channel */
void clear () { void clear () {
#ifndef PLATFORM_WINDOWS _xthread.drain ();
return xthread.drain ();
#endif
} }
CrossThreadChannel& xthread() {
return _xthread;
}
/* Not selectable; use ios() */ /* Not selectable; use ios() */
int selectable() const { return -1; } int selectable() const { return -1; }
Glib::RefPtr<Glib::IOSource> ios() {
#ifndef PLATFORM_WINDOWS
return xthread.ios();
#else
return Glib::RefPtr<Glib::IOSource>(0);
#endif
}
void set_timer (boost::function<framecnt_t (void)>&); void set_timer (boost::function<framecnt_t (void)>&);
static void set_process_thread (pthread_t); static void set_process_thread (pthread_t);
@ -88,11 +83,9 @@ class LIBARDOUR_API AsyncMIDIPort : public ARDOUR::MidiPort, public MIDI::Port {
bool have_timer; bool have_timer;
boost::function<framecnt_t (void)> timer; boost::function<framecnt_t (void)> timer;
RingBuffer< Evoral::Event<double> > output_fifo; RingBuffer< Evoral::Event<double> > output_fifo;
EventRingBuffer<MIDI::timestamp_t> input_fifo; Evoral::EventRingBuffer<MIDI::timestamp_t> input_fifo;
Glib::Threads::Mutex output_fifo_lock; Glib::Threads::Mutex output_fifo_lock;
#ifndef PLATFORM_WINDOWS CrossThreadChannel _xthread;
CrossThreadChannel xthread;
#endif
int create_port (); int create_port ();

View file

@ -37,6 +37,10 @@ using namespace ARDOUR;
using namespace std; using namespace std;
using namespace PBD; using namespace PBD;
namespace Evoral {
template class EventRingBuffer<MIDI::timestamp_t>;
}
pthread_t AsyncMIDIPort::_process_thread; pthread_t AsyncMIDIPort::_process_thread;
#define port_engine AudioEngine::instance()->port_engine() #define port_engine AudioEngine::instance()->port_engine()
@ -49,9 +53,7 @@ AsyncMIDIPort::AsyncMIDIPort (string const & name, PortFlags flags)
, have_timer (false) , have_timer (false)
, output_fifo (512) , output_fifo (512)
, input_fifo (1024) , input_fifo (1024)
#ifndef PLATFORM_WINDOWS , _xthread (true)
, xthread (true)
#endif
{ {
} }
@ -132,11 +134,9 @@ AsyncMIDIPort::cycle_start (MIDI::pframes_t nframes)
input_fifo.write (when, (Evoral::EventType) 0, (*b).size(), (*b).buffer()); input_fifo.write (when, (Evoral::EventType) 0, (*b).size(), (*b).buffer());
} }
#ifndef PLATFORM_WINDOWS
if (!mb.empty()) { if (!mb.empty()) {
xthread.wakeup (); _xthread.wakeup ();
} }
#endif
} }
} }