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.
This commit is contained in:
Paul Davis 2025-11-25 17:59:12 -07:00
parent f85ead942b
commit 5ad7071614
3 changed files with 26 additions and 30 deletions

View file

@ -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<LocationMarker> lm;
std::vector<ArdourSurface::LocationMarker> 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()) {

View file

@ -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 () {}

View file

@ -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<LocationMarker> 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<PBD::Controllable> controllable);
void send_gain_message (std::string path, std::shared_ptr<PBD::Controllable> controllable);
@ -108,4 +114,6 @@ class OSCGlobalObserver
void group_changed (void);
};
} /* namespace */
#endif /* __osc_oscglobalobserver_h__ */