Introduce a macro for imprecise configurations
[ardour.git] / libs / ardour / midi_ui.cc
index 96304fa05174b588d30ef6b51ae68fed2dcb7260..eaacde2969f3cb5cc077f8d5ee383610154f8570 100644 (file)
@@ -37,7 +37,7 @@ using namespace ARDOUR;
 using namespace PBD;
 using namespace Glib;
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 MidiControlUI* MidiControlUI::_instance = 0;
 
@@ -60,6 +60,17 @@ MidiControlUI::~MidiControlUI ()
        _instance = 0;
 }
 
+void*
+MidiControlUI::request_factory (uint32_t num_requests)
+{
+       /* AbstractUI<T>::request_buffer_factory() is a template method only
+          instantiated in this source module. To provide something visible for
+          use when registering the factory, we have this static method that is
+          template-free.
+       */
+       return request_buffer_factory (num_requests);
+}
+
 void
 MidiControlUI::do_request (MidiUIRequest* req)
 {
@@ -71,8 +82,13 @@ MidiControlUI::do_request (MidiUIRequest* req)
 }
 
 bool
-MidiControlUI::midi_input_handler (IOCondition ioc, boost::shared_ptr<AsyncMIDIPort> port)
+MidiControlUI::midi_input_handler (IOCondition ioc, boost::weak_ptr<AsyncMIDIPort> wport)
 {
+       boost::shared_ptr<AsyncMIDIPort> port = wport.lock ();
+       if (!port) {
+               return false;
+       }
+
        DEBUG_TRACE (DEBUG::MidiIO, string_compose ("something happend on  %1\n", boost::shared_ptr<ARDOUR::Port> (port)->name()));
 
        if (ioc & ~IO_IN) {
@@ -119,7 +135,8 @@ MidiControlUI::reset_ports ()
        }
 
        for (vector<boost::shared_ptr<AsyncMIDIPort> >::const_iterator pi = ports.begin(); pi != ports.end(); ++pi) {
-               (*pi)->xthread().set_receive_handler (sigc::bind (sigc::mem_fun (this, &MidiControlUI::midi_input_handler), *pi));
+               (*pi)->xthread().set_receive_handler (sigc::bind (
+                                       sigc::mem_fun (this, &MidiControlUI::midi_input_handler), boost::weak_ptr<AsyncMIDIPort>(*pi)));
                (*pi)->xthread().attach (_main_loop->get_context());
        }
 }
@@ -131,7 +148,7 @@ MidiControlUI::thread_init ()
 
        pthread_set_name (X_("midiUI"));
 
-       PBD::notify_gui_about_thread_creation (X_("gui"), pthread_self(), X_("midiUI"), 2048);
+       PBD::notify_event_loops_about_thread_creation (pthread_self(), X_("midiUI"), 2048);
        SessionEvent::create_per_thread_pool (X_("midiUI"), 128);
 
        memset (&rtparam, 0, sizeof (rtparam));