13
0

faderport (classic): fix a variety of SNAFUs since switch to MidiSurface (#9439)

This commit is contained in:
Paul Davis 2023-09-14 12:14:55 -06:00
parent 56772b8156
commit 09b919bb85
2 changed files with 57 additions and 21 deletions

View File

@ -157,6 +157,7 @@ FaderPort::FaderPort (Session& s)
get_button (Output).set_action (boost::bind (&FaderPort::use_master, this), true); get_button (Output).set_action (boost::bind (&FaderPort::use_master, this), true);
get_button (Output).set_action (boost::bind (&FaderPort::use_monitor, this), true, ShiftDown); get_button (Output).set_action (boost::bind (&FaderPort::use_monitor, this), true, ShiftDown);
run_event_loop ();
port_setup (); port_setup ();
} }
@ -420,7 +421,7 @@ FaderPort::handle_midi_sysex (MIDI::Parser &p, MIDI::byte *buf, size_t sz)
int int
FaderPort::set_active (bool yn) FaderPort::set_active (bool yn)
{ {
DEBUG_TRACE (DEBUG::FaderPort, string_compose("Faderport::set_active init with yn: '%1'\n", yn)); DEBUG_TRACE (DEBUG::FaderPort, string_compose("Faderport::set_active init with yn: '%1' while active = %2\n", yn, active()));
if (yn == active()) { if (yn == active()) {
return 0; return 0;
@ -428,19 +429,9 @@ FaderPort::set_active (bool yn)
if (yn) { if (yn) {
/* start event loop */ if (device_acquire ()) {
return -1;
BaseUI::run (); }
connect_session_signals ();
Glib::RefPtr<Glib::TimeoutSource> blink_timeout = Glib::TimeoutSource::create (200); // milliseconds
blink_connection = blink_timeout->connect (sigc::mem_fun (*this, &FaderPort::blink));
blink_timeout->attach (main_loop()->get_context());
Glib::RefPtr<Glib::TimeoutSource> periodic_timeout = Glib::TimeoutSource::create (100); // milliseconds
periodic_connection = periodic_timeout->connect (sigc::mem_fun (*this, &FaderPort::periodic));
periodic_timeout->attach (main_loop()->get_context());
} else { } else {
/* Control Protocol Manager never calls us with false, but /* Control Protocol Manager never calls us with false, but
@ -652,15 +643,41 @@ FaderPort::output_port_name () const
#endif #endif
} }
void
FaderPort::run_event_loop ()
{
DEBUG_TRACE (DEBUG::FaderPort, "start event loop\n");
BaseUI::run ();
}
void
FaderPort::stop_event_loop ()
{
DEBUG_TRACE (DEBUG::FaderPort, "stop event loop\n");
BaseUI::quit ();
}
int int
FaderPort::begin_using_device() FaderPort::begin_using_device()
{ {
DEBUG_TRACE (DEBUG::FaderPort, "sending device inquiry message...\n"); DEBUG_TRACE (DEBUG::FaderPort, "begin using device\n");
connect_session_signals ();
Glib::RefPtr<Glib::TimeoutSource> blink_timeout = Glib::TimeoutSource::create (200); // milliseconds
blink_connection = blink_timeout->connect (sigc::mem_fun (*this, &FaderPort::blink));
blink_timeout->attach (main_loop()->get_context());
Glib::RefPtr<Glib::TimeoutSource> periodic_timeout = Glib::TimeoutSource::create (100); // milliseconds
periodic_connection = periodic_timeout->connect (sigc::mem_fun (*this, &FaderPort::periodic));
periodic_timeout->attach (main_loop()->get_context());
if (MIDISurface::begin_using_device ()) { if (MIDISurface::begin_using_device ()) {
return -1; return -1;
} }
DEBUG_TRACE (DEBUG::FaderPort, "sending device inquiry message...\n");
/* send device inquiry */ /* send device inquiry */
MIDI::byte buf[6]; MIDI::byte buf[6];
@ -685,10 +702,6 @@ FaderPort::stop_using_device ()
stripable_connections.drop_connections (); stripable_connections.drop_connections ();
periodic_connection.disconnect (); periodic_connection.disconnect ();
#if 0
stripable_connections.drop_connections ();
#endif
return 0; return 0;
} }
@ -1114,3 +1127,21 @@ FaderPort::get_action (ButtonID id, bool press, ButtonState bs)
return get_button(id).get_action (press, bs); return get_button(id).get_action (press, bs);
} }
void
FaderPort::notify_record_state_changed ()
{
map_recenable_state ();
}
void
FaderPort::notify_transport_state_changed()
{
map_transport_state ();
}
void
FaderPort::notify_loop_state_changed ()
{
map_transport_state ();
}

View File

@ -138,6 +138,10 @@ class FaderPort : public MIDISurface {
void set_action (ButtonID, std::string const& action_name, bool on_press, FaderPort::ButtonState = ButtonState (0)); void set_action (ButtonID, std::string const& action_name, bool on_press, FaderPort::ButtonState = ButtonState (0));
std::string get_action (ButtonID, bool on_press, FaderPort::ButtonState = ButtonState (0)); std::string get_action (ButtonID, bool on_press, FaderPort::ButtonState = ButtonState (0));
void notify_record_state_changed ();
void notify_transport_state_changed ();
void notify_loop_state_changed ();
private: private:
std::shared_ptr<ARDOUR::Stripable> _current_stripable; std::shared_ptr<ARDOUR::Stripable> _current_stripable;
std::weak_ptr<ARDOUR::Stripable> pre_master_stripable; std::weak_ptr<ARDOUR::Stripable> pre_master_stripable;
@ -162,9 +166,10 @@ class FaderPort : public MIDISurface {
int begin_using_device (); int begin_using_device ();
int stop_using_device (); int stop_using_device ();
int device_acquire () { return 0; } int device_acquire () { return 0; }
void device_release () { } void device_release () { }
void run_event_loop ();
void stop_event_loop ();
ButtonState button_state; ButtonState button_state;