From 5ad707161447be9ea8ea0010d78cdacc6ca601c7 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 25 Nov 2025 17:59:12 -0700 Subject: [PATCH] OSC: use namespaces and deletion to avoid conflicts over LocationMarker type note that this type is also declared by the GTK2 GUI, and at runtime that was the definition being used, which leads to crashes due to differences in the type definition. --- libs/surfaces/osc/osc.cc | 21 ++++------------ libs/surfaces/osc/osc.h | 3 ++- libs/surfaces/osc/osc_global_observer.h | 32 +++++++++++++++---------- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 2bd3b198f8..9347486dd1 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -3181,20 +3181,6 @@ OSC::mixer_scene_state (lo_address addr, bool zero_it) return 0; } -// two structs to help with going to markers -struct LocationMarker { - LocationMarker (const std::string& l, samplepos_t w) - : label (l), when (w) {} - std::string label; - samplepos_t when; -}; - -struct LocationMarkerSort { - bool operator() (const LocationMarker& a, const LocationMarker& b) { - return (a.when < b.when); - } -}; - int OSC::set_marker (const char* types, lo_arg **argv, int argc, lo_message msg) { @@ -3202,6 +3188,7 @@ OSC::set_marker (const char* types, lo_arg **argv, int argc, lo_message msg) PBD::warning << "Wrong number of parameters, one only." << endmsg; return -1; } + const Locations::LocationList& ll (session->locations ()->list ()); uint32_t marker = 0; @@ -3237,15 +3224,15 @@ OSC::set_marker (const char* types, lo_arg **argv, int argc, lo_message msg) return -1; break; } - std::vector lm; + std::vector lm; // get Locations that are marks for (Locations::LocationList::const_iterator l = ll.begin(); l != ll.end(); ++l) { if ((*l)->is_mark ()) { - lm.push_back (LocationMarker((*l)->name(), (*l)->start_sample ())); + lm.push_back (ArdourSurface::LocationMarker((*l)->name(), (*l)->start_sample ())); } } // sort them by position - LocationMarkerSort location_marker_sort; + ArdourSurface::LocationMarkerSort location_marker_sort; std::sort (lm.begin(), lm.end(), location_marker_sort); // go there if (marker < lm.size()) { diff --git a/libs/surfaces/osc/osc.h b/libs/surfaces/osc/osc.h index 899a0fc62e..88749e32d8 100644 --- a/libs/surfaces/osc/osc.h +++ b/libs/surfaces/osc/osc.h @@ -51,7 +51,6 @@ class OSCControllable; class OSCRouteObserver; -class OSCGlobalObserver; class OSCSelectObserver; class OSCCueObserver; @@ -68,6 +67,8 @@ class ZeroConf; namespace ArdourSurface { +class OSCGlobalObserver; + struct OSCUIRequest : public BaseUI::BaseRequestObject { public: OSCUIRequest () {} diff --git a/libs/surfaces/osc/osc_global_observer.h b/libs/surfaces/osc/osc_global_observer.h index 4c08ae6e0c..2e205eb572 100644 --- a/libs/surfaces/osc/osc_global_observer.h +++ b/libs/surfaces/osc/osc_global_observer.h @@ -34,6 +34,22 @@ #include "ardour/session.h" #include "ardour/types.h" +namespace ArdourSurface { + + +struct LocationMarker { + LocationMarker (const std::string& l, samplepos_t w) + : label (l), when (w) {} + std::string label; + samplepos_t when; +}; + +struct LocationMarkerSort { + bool operator() (const LocationMarker& a, const LocationMarker& b) { + return (a.when < b.when); + } +}; + class OSCGlobalObserver { @@ -47,6 +63,8 @@ class OSCGlobalObserver void jog_mode (uint32_t jogmode); private: + friend ArdourSurface::OSC; + ArdourSurface::OSC& _osc; PBD::ScopedConnectionList strip_connections; @@ -79,20 +97,8 @@ class OSCGlobalObserver uint32_t last_click; samplepos_t prev_mark; samplepos_t next_mark; - struct LocationMarker { - LocationMarker (const std::string& l, samplepos_t w) - : label (l), when (w) {} - std::string label; - samplepos_t when; - }; std::vector lm; - struct LocationMarkerSort { - bool operator() (const LocationMarker& a, const LocationMarker& b) { - return (a.when < b.when); - } - }; - void update_mixer_scene_state(); void send_change_message (std::string path, std::shared_ptr controllable); void send_gain_message (std::string path, std::shared_ptr controllable); @@ -108,4 +114,6 @@ class OSCGlobalObserver void group_changed (void); }; +} /* namespace */ + #endif /* __osc_oscglobalobserver_h__ */