fix DSP load bounds 0..1 and add unbound API
[ardour.git] / libs / ardour / midi_ui.cc
index e00ec587ec4da2f6180b397ee7c3ecb09ce0b92e..0f2392108f25fcbe37b97d45ad430c48f60f8da7 100644 (file)
@@ -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();
@@ -96,21 +97,11 @@ MidiControlUI::midi_input_handler (IOCondition ioc, AsyncMIDIPort* port)
 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;
        
@@ -131,20 +122,9 @@ 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);
-                       
-                       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());
        }
 }