using namespace std;
using namespace ARDOUR;
+using namespace PBD;
using namespace Glib;
#include "i18n.h"
BaseUI::RequestType MidiControlUI::PortChange = BaseUI::new_request_type();
+MidiControlUI* MidiControlUI::_instance = 0;
#include "pbd/abstract_ui.cc" /* instantiate the template */
MidiControlUI::MidiControlUI (Session& s)
- : AbstractUI<MidiUIRequest> (_("midiui"))
- , _session (s)
+ : AbstractUI<MidiUIRequest> (X_("midiui"))
+ , _session (s)
{
- MIDI::Manager::instance()->PortsChanged.connect (rebind_connection, boost::bind (&MidiControlUI::change_midi_ports, this));
+ MIDI::Manager::instance()->PortsChanged.connect_same_thread (rebind_connection, boost::bind (&MidiControlUI::change_midi_ports, this));
+ _instance = this;
}
MidiControlUI::~MidiControlUI ()
{
clear_ports ();
+ _instance = 0;
}
void
} else if (req->type == CallSlot) {
+#ifndef NDEBUG
+ if (getenv ("DEBUG_THREADED_SIGNALS")) {
+ cerr << "MIDI UI calls a slot\n";
+ }
+#endif
+
req->the_slot ();
} else if (req->type == Quit) {
bool
MidiControlUI::midi_input_handler (IOCondition ioc, MIDI::Port* port)
{
+ DEBUG_TRACE (DEBUG::MidiIO, string_compose ("something happend on %1\n", port->name()));
+
if (ioc & ~IO_IN) {
return false;
}
if (ioc & IO_IN) {
- if (port->must_drain_selectable()) {
- CrossThreadChannel::drain (port->selectable());
- }
+ CrossThreadChannel::drain (port->selectable());
DEBUG_TRACE (DEBUG::MidiIO, string_compose ("data available on %1\n", port->name()));
- nframes64_t now = _session.engine().frame_time();
+ framepos_t now = _session.engine().frame_time();
port->parse (now);
}
{
clear_ports ();
- MIDI::Manager::PortList plist = MIDI::Manager::instance()->get_midi_ports ();
+ boost::shared_ptr<const MIDI::Manager::PortList> plist = MIDI::Manager::instance()->get_midi_ports ();
+
+ for (MIDI::Manager::PortList::const_iterator i = plist->begin(); i != plist->end(); ++i) {
+
+ if (!(*i)->centrally_parsed()) {
+ continue;
+ }
- for (MIDI::Manager::PortList::iterator i = plist.begin(); i != plist.end(); ++i) {
int fd;
+
if ((fd = (*i)->selectable ()) >= 0) {
Glib::RefPtr<IOSource> psrc = IOSource::create (fd, IO_IN|IO_HUP|IO_ERR);
port_sources.push_back (psrc->gobj());
g_source_ref (psrc->gobj());
- }
+ }
}
}
void
MidiControlUI::thread_init ()
-{
+{
struct sched_param rtparam;
+ pthread_set_name (X_("midiUI"));
+
PBD::notify_gui_about_thread_creation (X_("gui"), pthread_self(), X_("MIDI"), 2048);
SessionEvent::create_per_thread_pool (X_("MIDI I/O"), 128);