alter Async MIDI port implementation to use crossthreadchannel on all platforms
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 4 Dec 2014 01:53:49 +0000 (20:53 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 4 Dec 2014 01:53:49 +0000 (20:53 -0500)
libs/ardour/ardour/async_midi_port.h
libs/ardour/async_midi_port.cc

index 7fab9e4186dfa3df045581300d142e6440d98912..fde8110c19e2dc1926e38135a9678b689a09c343 100644 (file)
 #include "pbd/ringbuffer.h"
 
 #include "evoral/Event.hpp"
+#include "evoral/EventRingBuffer.hpp"
 
 #include "midi++/types.h"
 #include "midi++/parser.h"
 #include "midi++/port.h"
 
 #include "ardour/libardour_visibility.h"
-#include "ardour/event_ring_buffer.h"
 #include "ardour/midi_port.h"
 
 namespace ARDOUR {
@@ -62,20 +62,15 @@ class LIBARDOUR_API AsyncMIDIPort : public ARDOUR::MidiPort, public MIDI::Port {
 
        /* clears async request communication channel */
        void clear () {
-#ifndef PLATFORM_WINDOWS
-               return xthread.drain ();
-#endif
+               _xthread.drain ();
        }
+
+        CrossThreadChannel& xthread() {
+                return _xthread;
+        }
+
        /* Not selectable; use ios() */
        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)>&);
 
        static void set_process_thread (pthread_t);
@@ -88,11 +83,9 @@ class LIBARDOUR_API AsyncMIDIPort : public ARDOUR::MidiPort, public MIDI::Port {
        bool                    have_timer;
        boost::function<framecnt_t (void)> timer;
        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;
-#ifndef PLATFORM_WINDOWS
-       CrossThreadChannel xthread;
-#endif
+       CrossThreadChannel _xthread;
 
        int create_port ();
 
@@ -106,7 +99,7 @@ class LIBARDOUR_API AsyncMIDIPort : public ARDOUR::MidiPort, public MIDI::Port {
        void make_connections ();
        void init (std::string const &, Flags);
 
-        void flush_output_fifo (pframes_t);
+    void flush_output_fifo (pframes_t);
 
        static pthread_t _process_thread;
 };
index 4ce1bfefbed3cfbeed818ff4f70d2aba8f99ac1c..f0a92b9594cf636a260f1b0a45ec93d90d2cf5ff 100644 (file)
@@ -37,6 +37,10 @@ using namespace ARDOUR;
 using namespace std;
 using namespace PBD;
 
+namespace Evoral {
+       template class EventRingBuffer<MIDI::timestamp_t>;
+}
+
 pthread_t AsyncMIDIPort::_process_thread;
 
 #define port_engine AudioEngine::instance()->port_engine()
@@ -49,9 +53,7 @@ AsyncMIDIPort::AsyncMIDIPort (string const & name, PortFlags flags)
        , have_timer (false)
        , output_fifo (512)
        , input_fifo (1024)
-#ifndef PLATFORM_WINDOWS
-       , xthread (true)
-#endif
+       , _xthread (true)
 {
 }
 
@@ -132,11 +134,9 @@ AsyncMIDIPort::cycle_start (MIDI::pframes_t nframes)
                        input_fifo.write (when, (Evoral::EventType) 0, (*b).size(), (*b).buffer());
                }
 
-#ifndef PLATFORM_WINDOWS
                if (!mb.empty()) {
-                       xthread.wakeup ();
+                       _xthread.wakeup ();
                }
-#endif
        }
 }