MidiControlUI::~MidiControlUI ()
{
+ /* stop the thread */
+ quit ();
+ /* drop all ports as GIO::Sources */
clear_ports ();
+ /* we no longer exist */
_instance = 0;
}
{
if (req->type == Quit) {
BaseUI::quit ();
+ } else if (req->type == CallSlot) {
+ req->the_slot ();
}
}
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();
void
MidiControlUI::clear_ports ()
{
- for (PortSources::iterator i = port_sources.begin(); i != port_sources.end(); ++i) {
- g_source_destroy (*i);
- g_source_unref (*i);
- }
-
- port_sources.clear ();
}
void
MidiControlUI::reset_ports ()
{
- if (!port_sources.empty()) {
- return;
- }
-
vector<AsyncMIDIPort*> ports;
AsyncMIDIPort* p;
if ((p = dynamic_cast<AsyncMIDIPort*> (_session.mmc_input_port()))) {
ports.push_back (p);
}
+
+ if ((p = dynamic_cast<AsyncMIDIPort*> (_session.scene_input_port()))) {
+ ports.push_back (p);
+ }
if (ports.empty()) {
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);
-
- psrc->connect (sigc::bind (sigc::mem_fun (this, &MidiControlUI::midi_input_handler), *pi));
- psrc->attach (_main_loop->get_context());
-
- // glibmm hack: for now, store only the GSource*
-
- port_sources.push_back (psrc->gobj());
- g_source_ref (psrc->gobj());
- }
+ (*pi)->xthread().set_receive_handler (sigc::bind (sigc::mem_fun (this, &MidiControlUI::midi_input_handler), *pi));
+ (*pi)->xthread().attach (_main_loop->get_context());
}
}