From 893b468858a05f7ad9c344786e89d1414677c169 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 10 Apr 2012 16:27:01 +0000 Subject: [PATCH] add "centrally-parsed" property to MIDI::Port so that we can avoid the MidiUI loop from handling input for *all* MIDI ports created git-svn-id: svn://localhost/ardour2/branches/3.0@11871 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/midi_ui.cc | 5 +++++ libs/midi++2/midi++/port.h | 40 ++++++++++++++++++++------------------ libs/midi++2/port.cc | 6 ++++-- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/libs/ardour/midi_ui.cc b/libs/ardour/midi_ui.cc index b9271ccd49..770a371457 100644 --- a/libs/ardour/midi_ui.cc +++ b/libs/ardour/midi_ui.cc @@ -133,6 +133,11 @@ MidiControlUI::reset_ports () boost::shared_ptr 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; + } + int fd; if ((fd = (*i)->selectable ()) >= 0) { diff --git a/libs/midi++2/midi++/port.h b/libs/midi++2/midi++/port.h index f7bef36b1f..6b4381d496 100644 --- a/libs/midi++2/midi++/port.h +++ b/libs/midi++2/midi++/port.h @@ -108,6 +108,9 @@ class Port { const char *name () const { return _tagname.c_str(); } bool ok () const { return _ok; } + bool centrally_parsed() const { return _centrally_parsed; } + void set_centrally_parsed(bool yn) { _centrally_parsed = yn; } + bool receives_input () const { return _flags == IsInput; } @@ -139,23 +142,28 @@ class Port { static PBD::Signal0 JackHalted; private: - bool _ok; - bool _currently_in_cycle; - pframes_t _nframes_this_cycle; - std::string _tagname; - size_t _number; - Channel *_channel[16]; - Parser *_parser; + bool _ok; + bool _currently_in_cycle; + pframes_t _nframes_this_cycle; + std::string _tagname; + size_t _number; + Channel* _channel[16]; + Parser* _parser; + jack_client_t* _jack_client; + jack_port_t* _jack_port; + framecnt_t _last_read_index; + timestamp_t _last_write_timestamp; + RingBuffer< Evoral::Event > output_fifo; + Evoral::EventRingBuffer input_fifo; + Glib::Mutex output_fifo_lock; + CrossThreadChannel xthread; + Flags _flags; + bool _centrally_parsed; + int create_port (); - jack_client_t* _jack_client; - jack_port_t* _jack_port; - framecnt_t _last_read_index; - timestamp_t _last_write_timestamp; - /** Channel used to signal to the MidiControlUI that input has arrived */ - CrossThreadChannel xthread; std::string _connections; PBD::ScopedConnection connect_connection; @@ -167,12 +175,6 @@ private: static pthread_t _process_thread; - RingBuffer< Evoral::Event > output_fifo; - Evoral::EventRingBuffer input_fifo; - - Glib::Mutex output_fifo_lock; - - Flags _flags; }; struct PortSet { diff --git a/libs/midi++2/port.cc b/libs/midi++2/port.cc index 378548ca03..b5a16eef01 100644 --- a/libs/midi++2/port.cc +++ b/libs/midi++2/port.cc @@ -51,10 +51,11 @@ Port::Port (string const & name, Flags flags, jack_client_t* jack_client) , _jack_client (jack_client) , _jack_port (0) , _last_read_index (0) - , xthread (true) , output_fifo (512) , input_fifo (1024) + , xthread (true) , _flags (flags) + , _centrally_parsed (true) { assert (jack_client); init (name, flags); @@ -66,9 +67,10 @@ Port::Port (const XMLNode& node, jack_client_t* jack_client) , _jack_client (jack_client) , _jack_port (0) , _last_read_index (0) - , xthread (true) , output_fifo (512) , input_fifo (1024) + , xthread (true) + , _centrally_parsed (true) { assert (jack_client);