From c0366a5f138d489357408c981d289cde12bdb2c0 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 25 Aug 2023 18:08:56 +0200 Subject: [PATCH] MCU/UF8: Continued work to special case Mackie surface * Use dedicated port-names for UFx * Do not show SSL-UFx device-info files in MCU * Fix Window namespacing/missing symbols * Address Windows ambiguous symbols (Button, Surface) Those used to have a Mackie:: prefix, now they need MACKIE_NAMESPACE When re-opening the GUI, there is still a somewha mysterious warning: ``` glibmm-WARNING **: file value_custom.cc: (Glib::custom_boxed_type_register): The type name `glibmm__CustomBoxed_N13ArdourSurface6NS_UF86Button2IDE' has been registered already. ``` --- libs/surfaces/mackie/device_info.cc | 9 ++- libs/surfaces/mackie/device_profile.cc | 7 +- libs/surfaces/mackie/gui.cc | 12 +-- libs/surfaces/mackie/gui.h | 16 ++-- .../mackie/mackie_control_protocol.cc | 78 ++++++++++--------- .../surfaces/mackie/mackie_control_protocol.h | 2 +- libs/surfaces/mackie/surface_port.cc | 22 +++--- 7 files changed, 82 insertions(+), 64 deletions(-) diff --git a/libs/surfaces/mackie/device_info.cc b/libs/surfaces/mackie/device_info.cc index 8f9228ef13..bc7627d430 100644 --- a/libs/surfaces/mackie/device_info.cc +++ b/libs/surfaces/mackie/device_info.cc @@ -30,6 +30,7 @@ #include "pbd/convert.h" #include "pbd/stl_delete.h" +#include "ardour/debug.h" #include "ardour/filesystem_paths.h" #include "device_info.h" @@ -44,7 +45,7 @@ using namespace ArdourSurface::MACKIE_NAMESPACE; using std::string; using std::vector; -std::map DeviceInfo::device_info; +std::map MACKIE_NAMESPACE::DeviceInfo::device_info; DeviceInfo::DeviceInfo() : _strip_cnt (8) @@ -582,11 +583,12 @@ devinfo_filter (const string &str, void* /*arg*/) { #ifdef UF8 return (str.length() > strlen(devinfo_suffix) && - str.find ("uf8") != string::npos && + str.find ("ssl-uf") != string::npos && str.find (devinfo_suffix) == (str.length() - strlen (devinfo_suffix)) ); #else return (str.length() > strlen(devinfo_suffix) && + str.find ("ssl-uf") == string::npos && str.find (devinfo_suffix) == (str.length() - strlen (devinfo_suffix))); #endif } @@ -601,6 +603,8 @@ DeviceInfo::reload_device_info () find_files_matching_filter (devinfos, spath, devinfo_filter, 0, false, true); device_info.clear (); + DEBUG_TRACE (DEBUG::MackieControl, "DeviceProfile::reload_device_info\n"); + if (devinfos.empty()) { error << "No MCP device info files found using " << spath.to_string() << endmsg; std::cerr << "No MCP device info files found using " << spath.to_string() << std::endl; @@ -623,6 +627,7 @@ DeviceInfo::reload_device_info () } if (di.set_state (*root, 3000) == 0) { /* version is ignored for now */ + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Found profile '%1'\n", di.name ())); device_info[di.name()] = di; } } diff --git a/libs/surfaces/mackie/device_profile.cc b/libs/surfaces/mackie/device_profile.cc index 7ef6c8e364..ab4e065b31 100644 --- a/libs/surfaces/mackie/device_profile.cc +++ b/libs/surfaces/mackie/device_profile.cc @@ -30,6 +30,7 @@ #include "pbd/stl_delete.h" #include "pbd/replace_all.h" +#include "ardour/debug.h" #include "ardour/filesystem_paths.h" #include "mackie_control_protocol.h" @@ -45,7 +46,8 @@ using namespace ArdourSurface::MACKIE_NAMESPACE; using std::string; using std::vector; -std::map DeviceProfile::device_profiles; +std::map MACKIE_NAMESPACE::DeviceProfile::device_profiles; + const std::string DeviceProfile::edited_indicator (" (edited)"); const std::string DeviceProfile::default_profile_name ("User"); @@ -102,6 +104,8 @@ DeviceProfile::reload_device_profiles () find_files_matching_filter (devprofiles, spath, devprofile_filter, 0, false, true); device_profiles.clear (); + DEBUG_TRACE (DEBUG::MackieControl, "DeviceProfile::reload_device_profiles\n"); + if (devprofiles.empty()) { error << "No MCP device info files found using " << spath.to_string() << endmsg; return; @@ -123,6 +127,7 @@ DeviceProfile::reload_device_profiles () } if (dp.set_state (*root, 3000) == 0) { /* version is ignored for now */ + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Found profile '%1'\n", dp.name ())); dp.set_path (fullpath); device_profiles[dp.name()] = dp; } diff --git a/libs/surfaces/mackie/gui.cc b/libs/surfaces/mackie/gui.cc index 2c0dadafbc..b662980178 100644 --- a/libs/surfaces/mackie/gui.cc +++ b/libs/surfaces/mackie/gui.cc @@ -293,7 +293,7 @@ MackieControlProtocolGUI::connection_handler () for (ic = input_combos.begin(), oc = output_combos.begin(); ic != input_combos.end() && oc != output_combos.end(); ++ic, ++oc) { - std::shared_ptr surface = _cp.get_surface_by_raw_pointer ((*ic)->get_data ("surface")); + std::shared_ptr surface = _cp.get_surface_by_raw_pointer ((*ic)->get_data ("surface")); if (surface) { update_port_combos (midi_inputs, midi_outputs, *ic, *oc, surface); @@ -305,7 +305,7 @@ void MackieControlProtocolGUI::update_port_combos (vector const& midi_inputs, vector const& midi_outputs, Gtk::ComboBox* input_combo, Gtk::ComboBox* output_combo, - std::shared_ptr surface) + std::shared_ptr surface) { Glib::RefPtr input = build_midi_port_list (midi_inputs, true); Glib::RefPtr output = build_midi_port_list (midi_outputs, false); @@ -389,7 +389,7 @@ MackieControlProtocolGUI::device_dependent_widget () for (uint32_t n = 0; n < n_surfaces; ++n) { - std::shared_ptr surface = _cp.nth_surface (n); + std::shared_ptr surface = _cp.nth_surface (n); if (!surface) { PBD::fatal << string_compose (_("programming error: %1\n"), string_compose ("n=%1 surface not found!", n)) << endmsg; @@ -408,7 +408,7 @@ MackieControlProtocolGUI::device_dependent_widget () output_combo->set_data ("surface", surface.get()); output_combos.push_back (output_combo); - std::weak_ptr ws (surface); + std::weak_ptr ws (surface); input_combo->signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &MackieControlProtocolGUI::active_port_changed), input_combo, ws, true)); output_combo->signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &MackieControlProtocolGUI::active_port_changed), output_combo, ws, false)); @@ -825,13 +825,13 @@ MackieControlProtocolGUI::build_midi_port_list (vector const & ports, bo } void -MackieControlProtocolGUI::active_port_changed (Gtk::ComboBox* combo, std::weak_ptr ws, bool for_input) +MackieControlProtocolGUI::active_port_changed (Gtk::ComboBox* combo, std::weak_ptr ws, bool for_input) { if (ignore_active_change) { return; } - std::shared_ptr surface = ws.lock(); + std::shared_ptr surface = ws.lock(); if (!surface) { return; diff --git a/libs/surfaces/mackie/gui.h b/libs/surfaces/mackie/gui.h index c337164f85..3cb06c779f 100644 --- a/libs/surfaces/mackie/gui.h +++ b/libs/surfaces/mackie/gui.h @@ -84,14 +84,14 @@ class MackieControlProtocolGUI : public Gtk::Notebook add (cmdalt); add (shiftcontrol); }; - Gtk::TreeModelColumn name; - Gtk::TreeModelColumn id; - Gtk::TreeModelColumn plain; - Gtk::TreeModelColumn shift; - Gtk::TreeModelColumn control; - Gtk::TreeModelColumn option; - Gtk::TreeModelColumn cmdalt; - Gtk::TreeModelColumn shiftcontrol; + Gtk::TreeModelColumn name; + Gtk::TreeModelColumn id; + Gtk::TreeModelColumn plain; + Gtk::TreeModelColumn shift; + Gtk::TreeModelColumn control; + Gtk::TreeModelColumn option; + Gtk::TreeModelColumn cmdalt; + Gtk::TreeModelColumn shiftcontrol; }; FunctionKeyColumns function_key_columns; diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 00d49d4a99..6d4ffb69ab 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -100,20 +100,20 @@ using namespace ArdourSurface::MACKIE_NAMESPACE; #include "pbd/abstract_ui.cc" // instantiate template -const int MackieControlProtocol::MODIFIER_OPTION = 0x1; -const int MackieControlProtocol::MODIFIER_CONTROL = 0x2; -const int MackieControlProtocol::MODIFIER_SHIFT = 0x4; -const int MackieControlProtocol::MODIFIER_CMDALT = 0x8; -const int MackieControlProtocol::MODIFIER_ZOOM = 0x10; -const int MackieControlProtocol::MODIFIER_SCRUB = 0x20; -const int MackieControlProtocol::MODIFIER_MARKER = 0x40; -const int MackieControlProtocol::MODIFIER_NUDGE = 0x80; -const int MackieControlProtocol::MAIN_MODIFIER_MASK = (MackieControlProtocol::MODIFIER_OPTION| +const int MACKIE_NAMESPACE::MackieControlProtocol::MODIFIER_OPTION = 0x1; +const int MACKIE_NAMESPACE::MackieControlProtocol::MODIFIER_CONTROL = 0x2; +const int MACKIE_NAMESPACE::MackieControlProtocol::MODIFIER_SHIFT = 0x4; +const int MACKIE_NAMESPACE::MackieControlProtocol::MODIFIER_CMDALT = 0x8; +const int MACKIE_NAMESPACE::MackieControlProtocol::MODIFIER_ZOOM = 0x10; +const int MACKIE_NAMESPACE::MackieControlProtocol::MODIFIER_SCRUB = 0x20; +const int MACKIE_NAMESPACE::MackieControlProtocol::MODIFIER_MARKER = 0x40; +const int MACKIE_NAMESPACE::MackieControlProtocol::MODIFIER_NUDGE = 0x80; +const int MACKIE_NAMESPACE::MackieControlProtocol::MAIN_MODIFIER_MASK = (MackieControlProtocol::MODIFIER_OPTION| MackieControlProtocol::MODIFIER_CONTROL| MackieControlProtocol::MODIFIER_SHIFT| MackieControlProtocol::MODIFIER_CMDALT); -MackieControlProtocol* MackieControlProtocol::_instance = 0; +MACKIE_NAMESPACE::MackieControlProtocol* MACKIE_NAMESPACE::MackieControlProtocol::_instance = 0; MackieControlProtocol::MackieControlProtocol (Session& session) : ControlProtocol (session, X_("Mackie")) @@ -211,8 +211,8 @@ MackieControlProtocol::ping_devices () { Glib::Threads::Mutex::Lock lm (surfaces_lock); - for (Surfaces::const_iterator si = surfaces.begin(); si != surfaces.end(); ++si) { - (*si)->connected (); + for (auto const& si : surfaces) { + si->connected (); } } } @@ -624,9 +624,9 @@ MackieControlProtocol::update_timecode_beats_led() } void -MackieControlProtocol::update_global_button (int id, LedState ls) +MackieControlProtocol::update_global_button (int id, MACKIE_NAMESPACE::LedState ls) { - std::shared_ptr surface; + std::shared_ptr surface; { Glib::Threads::Mutex::Lock lm (surfaces_lock); @@ -652,7 +652,7 @@ MackieControlProtocol::update_global_button (int id, LedState ls) } void -MackieControlProtocol::update_global_led (int id, LedState ls) +MackieControlProtocol::update_global_led (int id, MACKIE_NAMESPACE::LedState ls) { Glib::Threads::Mutex::Lock lm (surfaces_lock); @@ -663,7 +663,7 @@ MackieControlProtocol::update_global_led (int id, LedState ls) if (!_device_info.has_global_controls()) { return; } - std::shared_ptr surface = _master_surface; + std::shared_ptr surface = _master_surface; map::iterator x = surface->controls_by_device_independent_id.find (id); @@ -879,7 +879,11 @@ MackieControlProtocol::create_surfaces () if (_device_info.extenders() == 0) { device_name = _device_info.name(); } else { +#ifdef UF8 + device_name = X_("SSL-UFx"); +#else device_name = X_("mackie control"); +#endif } } @@ -890,7 +894,7 @@ MackieControlProtocol::create_surfaces () DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Port Name for surface %1 is %2\n", n, device_name)); - std::shared_ptr surface; + std::shared_ptr surface; if (is_master) { stype = mcu; @@ -898,7 +902,7 @@ MackieControlProtocol::create_surfaces () stype = ext; } try { - surface.reset (new Surface (*this, device_name, n, stype)); + surface.reset (new MACKIE_NAMESPACE::Surface (*this, device_name, n, stype)); } catch (...) { return -1; } @@ -1213,7 +1217,7 @@ MackieControlProtocol::update_timecode_display() return; } - std::shared_ptr surface = _master_surface; + std::shared_ptr surface = _master_surface; if (surface->type() != mcu || !_device_info.has_timecode_display() || !surface->active ()) { return; @@ -1315,7 +1319,7 @@ MackieControlProtocol::notify_monitor_added_or_removed () void MackieControlProtocol::notify_solo_active_changed (bool active) { - std::shared_ptr surface; + std::shared_ptr surface; { Glib::Threads::Mutex::Lock lm (surfaces_lock); @@ -1407,7 +1411,7 @@ MackieControlProtocol::notify_record_state_changed () return; } - std::shared_ptr surface; + std::shared_ptr surface; { Glib::Threads::Mutex::Lock lm (surfaces_lock); @@ -1494,7 +1498,7 @@ MackieControlProtocol::stop () } void -MackieControlProtocol::update_led (Surface& surface, Button& button, MACKIE_NAMESPACE::LedState ls) +MackieControlProtocol::update_led (MACKIE_NAMESPACE::Surface& surface, MACKIE_NAMESPACE::Button& button, MACKIE_NAMESPACE::LedState ls) { if (ls != none) { surface.port().write (button.set_state (ls)); @@ -1615,7 +1619,7 @@ MackieControlProtocol::build_device_specific_button_map() } void -MackieControlProtocol::handle_button_event (Surface& surface, Button& button, ButtonState bs) +MackieControlProtocol::handle_button_event (MACKIE_NAMESPACE::Surface& surface, MACKIE_NAMESPACE::Button& button, MACKIE_NAMESPACE::ButtonState bs) { Button::ID button_id = button.bid(); @@ -1788,7 +1792,7 @@ MackieControlProtocol::redisplay_subview_mode () } bool -MackieControlProtocol::set_subview_mode (Subview::Mode sm, std::shared_ptr r) +MackieControlProtocol::set_subview_mode (MACKIE_NAMESPACE::Subview::Mode sm, std::shared_ptr r) { DEBUG_TRACE (DEBUG::MackieControl, string_compose ("set subview mode %1 with stripable %2, current flip mode %3\n", sm, (r ? r->name() : string ("null")), _flip_mode)); @@ -2282,8 +2286,8 @@ MackieControlProtocol::recalibrate_faders () { Glib::Threads::Mutex::Lock lm (surfaces_lock); - for (Surfaces::const_iterator s = surfaces.begin(); s != surfaces.end(); ++s) { - (*s)->recalibrate_faders (); + for (auto const& s : surfaces) { + s->recalibrate_faders (); } } @@ -2292,26 +2296,26 @@ MackieControlProtocol::toggle_backlight () { Glib::Threads::Mutex::Lock lm (surfaces_lock); - for (Surfaces::const_iterator s = surfaces.begin(); s != surfaces.end(); ++s) { - (*s)->toggle_backlight (); + for (auto const& s : surfaces) { + s->toggle_backlight (); } } -std::shared_ptr +std::shared_ptr MackieControlProtocol::get_surface_by_raw_pointer (void* ptr) const { Glib::Threads::Mutex::Lock lm (surfaces_lock); - for (Surfaces::const_iterator s = surfaces.begin(); s != surfaces.end(); ++s) { - if ((*s).get() == (Surface*) ptr) { - return *s; + for (auto const& s : surfaces) { + if (s.get() == (MACKIE_NAMESPACE::Surface*) ptr) { + return s; } } - return std::shared_ptr (); + return std::shared_ptr (); } -std::shared_ptr +std::shared_ptr MackieControlProtocol::nth_surface (uint32_t n) const { Glib::Threads::Mutex::Lock lm (surfaces_lock); @@ -2322,7 +2326,7 @@ MackieControlProtocol::nth_surface (uint32_t n) const } } - return std::shared_ptr (); + return std::shared_ptr (); } void @@ -2480,14 +2484,14 @@ MackieControlProtocol::first_selected_stripable () const } uint32_t -MackieControlProtocol::global_index (Strip& strip) +MackieControlProtocol::global_index (MACKIE_NAMESPACE::Strip& strip) { Glib::Threads::Mutex::Lock lm (surfaces_lock); return global_index_locked (strip); } uint32_t -MackieControlProtocol::global_index_locked (Strip& strip) +MackieControlProtocol::global_index_locked (MACKIE_NAMESPACE::Strip& strip) { uint32_t global = 0; diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index 76655ecd39..ddb5de3986 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -122,7 +122,7 @@ class MackieControlProtocol int set_active (bool yn); int set_device (const std::string&, bool force); - void set_profile (const std::string&); + void set_profile (const std::string&); FlipMode flip_mode () const { return _flip_mode; } ViewMode view_mode () const { return _view_mode; } diff --git a/libs/surfaces/mackie/surface_port.cc b/libs/surfaces/mackie/surface_port.cc index c24c3637cd..f268b6f55e 100644 --- a/libs/surfaces/mackie/surface_port.cc +++ b/libs/surfaces/mackie/surface_port.cc @@ -60,20 +60,24 @@ SurfacePort::SurfacePort (Surface& s) } else { - string in_name; - string out_name; +#ifdef UF8 + string in_name = X_("SSL-UFx control in"); + string out_name = X_("SSL-UFx control out"); +#else + string in_name = X_("mackie control in"); + string out_name = X_("mackie control out"); +#endif if (_surface->mcp().device_info().extenders() > 0) { - if (_surface->number() == _surface->mcp().device_info().master_position()) { - in_name = X_("mackie control in"); - out_name = X_("mackie control out"); - } else { + if (_surface->number() != _surface->mcp().device_info().master_position()) { +#ifdef UF8 + in_name = string_compose (X_("SSL-UFx control in ext %1"), (_surface->number() + 1)); + out_name = string_compose (X_("SSL-UFx control out ext %1"), _surface->number() + 1); +#else in_name = string_compose (X_("mackie control in ext %1"), (_surface->number() + 1)); out_name = string_compose (X_("mackie control out ext %1"), _surface->number() + 1); +#endif } - } else { - in_name = X_("mackie control in"); - out_name = X_("mackie control out"); } _async_in = AudioEngine::instance()->register_input_port (DataType::MIDI, in_name, true);