diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-11-23 17:37:13 +0200 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-11-23 17:37:13 +0200 |
commit | bfe49540b94b6ac451e2978fd45a47656fecd92e (patch) | |
tree | 5db3eef1625b41129974ff43618a53bc8df53db1 /libs/ardour | |
parent | dcf632d99f38a581c7b54d34abc421e0acec24e9 (diff) |
remove use of CrossThreadChannel::selectable() to allow cross-platform implementation of CrossThreadChannel via Glib::IOSource
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/async_midi_port.h | 18 | ||||
-rw-r--r-- | libs/ardour/midi_ui.cc | 14 |
2 files changed, 17 insertions, 15 deletions
diff --git a/libs/ardour/ardour/async_midi_port.h b/libs/ardour/ardour/async_midi_port.h index 26946e3016..373d6b7668 100644 --- a/libs/ardour/ardour/async_midi_port.h +++ b/libs/ardour/ardour/async_midi_port.h @@ -57,15 +57,19 @@ class LIBARDOUR_API AsyncMIDIPort : public ARDOUR::MidiPort, public MIDI::Port { void parse (framecnt_t timestamp); int write (const MIDI::byte *msg, size_t msglen, MIDI::timestamp_t timestamp); int read (MIDI::byte *buf, size_t bufsize); + /* waits for output to be cleared */ void drain (int check_interval_usecs); - int selectable () const { -#ifdef PLATFORM_WINDOWS - return false; -#else - return xthread.selectable(); -#endif + + /* clears async request communication channel */ + void clear () { + return xthread.drain (); } + /* Not selectable; use ios() */ + int selectable() const { return -1; } + Glib::RefPtr<Glib::IOSource> ios() { + return xthread.ios(); + } void set_timer (boost::function<framecnt_t (void)>&); static void set_process_thread (pthread_t); @@ -80,9 +84,7 @@ class LIBARDOUR_API AsyncMIDIPort : public ARDOUR::MidiPort, public MIDI::Port { RingBuffer< Evoral::Event<double> > output_fifo; Evoral::EventRingBuffer<MIDI::timestamp_t> input_fifo; Glib::Threads::Mutex output_fifo_lock; -#ifndef PLATFORM_WINDOWS CrossThreadChannel xthread; -#endif int create_port (); diff --git a/libs/ardour/midi_ui.cc b/libs/ardour/midi_ui.cc index e00ec587ec..d5a0b2b444 100644 --- a/libs/ardour/midi_ui.cc +++ b/libs/ardour/midi_ui.cc @@ -81,9 +81,10 @@ MidiControlUI::midi_input_handler (IOCondition ioc, AsyncMIDIPort* port) if (ioc & IO_IN) { -#ifndef PLATFORM_WINDOWS - CrossThreadChannel::drain (port->selectable()); -#endif + AsyncMIDIPort* asp = dynamic_cast<AsyncMIDIPort*> (port); + if (asp) { + asp->clear (); + } DEBUG_TRACE (DEBUG::MidiIO, string_compose ("data available on %1\n", ((ARDOUR::Port*)port)->name())); framepos_t now = _session.engine().sample_time(); @@ -131,12 +132,11 @@ MidiControlUI::reset_ports () return; } - int fd; for (vector<AsyncMIDIPort*>::const_iterator pi = ports.begin(); pi != ports.end(); ++pi) { - if ((fd = (*pi)->selectable ()) >= 0) { - Glib::RefPtr<IOSource> psrc = IOSource::create (fd, IO_IN|IO_HUP|IO_ERR); - + Glib::RefPtr<IOSource> psrc = (*pi)->ios(); + + if (psrc) { psrc->connect (sigc::bind (sigc::mem_fun (this, &MidiControlUI::midi_input_handler), *pi)); psrc->attach (_main_loop->get_context()); |