Refactor Ctrl Surface API

* reserve "probe" to actually probe for devices
* use separate probe for libusb and MIDI port devices
* use "available" to check if surface can be used
* allow both methods to be NULL
* remove unused ControlProtocolDescriptor* argument

Most surface just return `true` for available.
This commit is contained in:
Robin Gareus 2023-05-01 03:32:00 +02:00
parent 7c02ab9937
commit 65346496f5
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
38 changed files with 203 additions and 321 deletions

View file

@ -52,7 +52,7 @@ PBD::Signal1<void,StripableNotificationListPtr> ControlProtocolManager::Stripabl
ControlProtocolInfo::~ControlProtocolInfo ()
{
if (protocol && descriptor) {
descriptor->destroy (descriptor, protocol);
descriptor->destroy (protocol);
protocol = 0;
}
@ -226,7 +226,7 @@ ControlProtocolManager::instantiate (ControlProtocolInfo& cpi)
DEBUG_TRACE (DEBUG::ControlProtocols, string_compose ("initializing %1\n", cpi.name));
if ((cpi.protocol = cpi.descriptor->initialize (cpi.descriptor, _session)) == 0) {
if ((cpi.protocol = cpi.descriptor->initialize (_session)) == 0) {
error << string_compose (_("control protocol name \"%1\" could not be initialized"), cpi.name) << endmsg;
return 0;
}
@ -267,7 +267,7 @@ ControlProtocolManager::teardown (ControlProtocolInfo& cpi, bool lock_required)
cpi.state = new XMLNode (cpi.protocol->get_state());
cpi.state->set_property (X_("active"), false);
cpi.descriptor->destroy (cpi.descriptor, cpi.protocol);
cpi.descriptor->destroy (cpi.protocol);
Glib::Threads::RWLock::WriterLock lm (protocols_lock, Glib::Threads::NOT_LOCK);
if (lock_required) {
@ -370,7 +370,7 @@ ControlProtocolManager::control_protocol_discover (string path)
if ((descriptor = get_descriptor (path)) != 0) {
if (!descriptor->probe (descriptor)) {
if (descriptor->available && !descriptor->available ()) {
warning << string_compose (_("Control protocol %1 not usable"), descriptor->name) << endmsg;
delete (Glib::Module*) descriptor->module;
} else {

View file

@ -171,12 +171,14 @@ extern "C" {
class ControlProtocolDescriptor
{
public:
const char* name; /* descriptive */
const char* id; /* unique and version-specific */
void* module; /* not for public access */
bool (*probe) (ControlProtocolDescriptor*);
ControlProtocol* (*initialize) (ControlProtocolDescriptor*, Session*);
void (*destroy) (ControlProtocolDescriptor*, ControlProtocol*);
const char* name; /* descriptive */
const char* id; /* unique and version-specific */
void* module; /* not for public access */
bool (*available) (); /* called directly after loading module */
bool (*probe_port) (); /* called when ports change (PortRegisteredOrUnregistered) */
bool (*match_usb) (uint16_t, uint16_t); /* called when USB devices are hotplugged (libusb) */
ControlProtocol* (*initialize) (Session*);
void (*destroy) (ControlProtocol*);
};
}
}

View file

@ -83,11 +83,6 @@ class CC121 : public ARDOUR::ControlProtocol, public AbstractUI<CC121Request> {
int set_active (bool yn);
/* we probe for a device when our ports are connected. Before that,
there's no way to know if the device exists or not.
*/
static bool probe() { return true; }
XMLNode& get_state () const;
int set_state (const XMLNode&, int version);

View file

@ -26,7 +26,7 @@ using namespace ARDOUR;
using namespace ArdourSurface;
static ControlProtocol*
new_cc121_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, Session* s)
new_cc121_midi_protocol (Session* s)
{
CC121* fp;
@ -45,24 +45,21 @@ new_cc121_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, Session* s)
}
static void
delete_cc121_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, ControlProtocol* cp)
delete_cc121_midi_protocol (ControlProtocol* cp)
{
delete cp;
}
static bool
probe_cc121_midi_protocol (ControlProtocolDescriptor* /*descriptor*/)
{
return CC121::probe ();
}
static ControlProtocolDescriptor cc121_midi_descriptor = {
/*name : */ "Steinberg CC121",
/*id : */ "uri://ardour.org/surfaces/cc121:0",
/*module : */ 0,
/*probe : */ probe_cc121_midi_protocol,
/*initialize : */ new_cc121_midi_protocol,
/*destroy : */ delete_cc121_midi_protocol,
/* name */ "Steinberg CC121",
/* id */ "uri://ardour.org/surfaces/cc121:0",
/* module */ 0,
/* probe port */ 0,
/* match usb */ 0,
/* available */ 0,
/* initialize */ new_cc121_midi_protocol,
/* destroy */ delete_cc121_midi_protocol,
};
extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () { return &cc121_midi_descriptor; }

View file

@ -88,7 +88,7 @@ ContourDesignControlProtocol::~ContourDesignControlProtocol ()
}
bool
ContourDesignControlProtocol::probe ()
ContourDesignControlProtocol::available ()
{
bool rv = LIBUSB_SUCCESS == libusb_init (0);
if (rv) {

View file

@ -84,7 +84,7 @@ public:
DeviceType device_type() const { return _device_type; }
static bool probe ();
static bool available ();
int set_active (bool yn);

View file

@ -30,7 +30,7 @@ using namespace PBD;
using namespace ArdourSurface;
static ControlProtocol*
new_contourdesign_protocol (ControlProtocolDescriptor*, Session* s)
new_contourdesign_protocol (Session* s)
{
ContourDesignControlProtocol* wmcp = new ContourDesignControlProtocol (*s);
wmcp->set_active (true);
@ -38,24 +38,21 @@ new_contourdesign_protocol (ControlProtocolDescriptor*, Session* s)
}
static void
delete_contourdesign_protocol (ControlProtocolDescriptor* /*descriptor*/, ControlProtocol* cp)
delete_contourdesign_protocol (ControlProtocol* cp)
{
delete cp;
}
static bool
probe_contourdesign_protocol (ControlProtocolDescriptor*)
{
return ContourDesignControlProtocol::probe ();
}
static ControlProtocolDescriptor contourdesign_descriptor = {
/* name : */ "ContourDesign",
/* id : */ "uri://ardour.org/surfaces/contourdesign:0",
/* module : */ 0,
/* probe : */ probe_contourdesign_protocol,
/* initialize : */ new_contourdesign_protocol,
/* destroy : */ delete_contourdesign_protocol,
/* name */ "ContourDesign",
/* id */ "uri://ardour.org/surfaces/contourdesign:0",
/* module */ 0,
/* available */ ContourDesignControlProtocol::available,
/* probe port */ 0,
/* match usb */ 0,
/* initialize */ new_contourdesign_protocol,
/* destroy */ delete_contourdesign_protocol,
};
extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () { return &contourdesign_descriptor; }

View file

@ -71,11 +71,6 @@ class FaderPort : public MIDISurface {
int set_active (bool yn);
/* we probe for a device when our ports are connected. Before that,
there's no way to know if the device exists or not.
*/
static bool probe() { return true; }
std::string input_port_name () const;
std::string output_port_name () const;

View file

@ -26,7 +26,7 @@ using namespace ARDOUR;
using namespace ArdourSurface;
static ControlProtocol*
new_faderport_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, Session* s)
new_faderport_midi_protocol (Session* s)
{
FaderPort* fp;
@ -45,24 +45,20 @@ new_faderport_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, Session*
}
static void
delete_faderport_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, ControlProtocol* cp)
delete_faderport_midi_protocol (ControlProtocol* cp)
{
delete cp;
}
static bool
probe_faderport_midi_protocol (ControlProtocolDescriptor* /*descriptor*/)
{
return FaderPort::probe ();
}
static ControlProtocolDescriptor faderport_midi_descriptor = {
/*name : */ "PreSonus FaderPort",
/*id : */ "uri://ardour.org/surfaces/faderport:0",
/*module : */ 0,
/*probe : */ probe_faderport_midi_protocol,
/*initialize : */ new_faderport_midi_protocol,
/*destroy : */ delete_faderport_midi_protocol,
/* name */ "PreSonus FaderPort",
/* id */ "uri://ardour.org/surfaces/faderport:0",
/* module */ 0,
/* available */ 0,
/* probe_port */ 0,
/* match usb */ 0,
/* initialize */ new_faderport_midi_protocol,
/* destroy */ delete_faderport_midi_protocol,
};
extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () { return &faderport_midi_descriptor; }

View file

@ -25,12 +25,12 @@ using namespace ARDOUR;
using namespace ArdourSurface::FP_NAMESPACE;
static ControlProtocol*
new_faderport16_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, Session* s)
new_faderport16_midi_protocol (Session* s)
{
FaderPort8* fp;
try {
fp = new FaderPort8 (*s);
fp = new FaderPort8 (*s);
} catch (failed_constructor& err) {
return 0;
}
@ -44,24 +44,20 @@ new_faderport16_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, Sessio
}
static void
delete_faderport16_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, ControlProtocol* cp)
delete_faderport16_midi_protocol (ControlProtocol* cp)
{
delete cp;
}
static bool
probe_faderport16_midi_protocol (ControlProtocolDescriptor* /*descriptor*/)
{
return FaderPort8::probe ();
}
static ControlProtocolDescriptor faderport16_midi_descriptor = {
/*name : */ "PreSonus FaderPort16",
/*id : */ "uri://ardour.org/surfaces/faderport16:0",
/*module : */ 0,
/*probe : */ probe_faderport16_midi_protocol,
/*initialize : */ new_faderport16_midi_protocol,
/*destroy : */ delete_faderport16_midi_protocol,
/* name */ "PreSonus FaderPort16",
/* id */ "uri://ardour.org/surfaces/faderport16:0",
/* module */ 0,
/* available: */ 0,
/* probe_port */ 0,
/* match usb */ 0,
/* initialize */ new_faderport16_midi_protocol,
/* destroy */ delete_faderport16_midi_protocol,
};
extern "C" ARDOURSURFACE_API

View file

@ -25,12 +25,12 @@ using namespace ARDOUR;
using namespace ArdourSurface::FP_NAMESPACE;
static ControlProtocol*
new_faderport2_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, Session* s)
new_faderport2_midi_protocol (Session* s)
{
FaderPort8* fp;
try {
fp = new FaderPort8 (*s);
fp = new FaderPort8 (*s);
} catch (failed_constructor& err) {
return 0;
}
@ -44,27 +44,24 @@ new_faderport2_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, Session
}
static void
delete_faderport2_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, ControlProtocol* cp)
delete_faderport2_midi_protocol (ControlProtocol* cp)
{
delete cp;
}
static bool
probe_faderport2_midi_protocol (ControlProtocolDescriptor* /*descriptor*/)
{
return FaderPort8::probe ();
}
static ControlProtocolDescriptor faderport2_midi_descriptor = {
/*name : */ "PreSonus FaderPort2",
/*id : */ "uri://ardour.org/surfaces/faderport2:0",
/*module : */ 0,
/*probe : */ probe_faderport2_midi_protocol,
/*initialize : */ new_faderport2_midi_protocol,
/*destroy : */ delete_faderport2_midi_protocol,
/* name */ "PreSonus FaderPort2",
/* id */ "uri://ardour.org/surfaces/faderport2:0",
/* module */ 0,
/* available */ 0,
/* probe_port */ 0,
/* match usb */ 0,
/* initialize */ new_faderport2_midi_protocol,
/* destroy */ delete_faderport2_midi_protocol,
};
extern "C" ARDOURSURFACE_API
ControlProtocolDescriptor* protocol_descriptor () {
ControlProtocolDescriptor* protocol_descriptor ()
{
return &faderport2_midi_descriptor;
}

View file

@ -69,11 +69,6 @@ public:
int set_active (bool yn);
/* we probe for a device when our ports are connected. Before that,
* there's no way to know if the device exists or not.
*/
static bool probe() { return true; }
XMLNode& get_state () const;
int set_state (const XMLNode&, int version);

View file

@ -25,12 +25,12 @@ using namespace ARDOUR;
using namespace ArdourSurface::FP_NAMESPACE;
static ControlProtocol*
new_faderport8_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, Session* s)
new_faderport8_midi_protocol (Session* s)
{
FaderPort8* fp;
try {
fp = new FaderPort8 (*s);
fp = new FaderPort8 (*s);
} catch (failed_constructor& err) {
return 0;
}
@ -44,24 +44,20 @@ new_faderport8_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, Session
}
static void
delete_faderport8_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, ControlProtocol* cp)
delete_faderport8_midi_protocol (ControlProtocol* cp)
{
delete cp;
}
static bool
probe_faderport8_midi_protocol (ControlProtocolDescriptor* /*descriptor*/)
{
return FaderPort8::probe ();
}
static ControlProtocolDescriptor faderport8_midi_descriptor = {
/*name : */ "PreSonus FaderPort8",
/*id : */ "uri://ardour.org/surfaces/faderport8:0",
/*module : */ 0,
/*probe : */ probe_faderport8_midi_protocol,
/*initialize : */ new_faderport8_midi_protocol,
/*destroy : */ delete_faderport8_midi_protocol,
/* name */ "PreSonus FaderPort8",
/* id */ "uri://ardour.org/surfaces/faderport8:0",
/* module */ 0,
/* available */ 0,
/* probe_port */ 0,
/* match usb */ 0,
/* initialize */ new_faderport8_midi_protocol,
/* destroy */ delete_faderport8_midi_protocol,
};
extern "C" ARDOURSURFACE_API

View file

@ -69,7 +69,6 @@ public:
void thread_init ();
int set_active (bool yn);
static bool probe() { return true; }
void stripable_selection_changed () {}

View file

@ -25,7 +25,7 @@
using namespace ARDOUR;
static ControlProtocol*
new_generic_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, Session* s)
new_generic_midi_protocol (Session* s)
{
GenericMidiControlProtocol* gmcp;
@ -44,25 +44,21 @@ new_generic_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, Session* s
}
static void
delete_generic_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, ControlProtocol* cp)
delete_generic_midi_protocol (ControlProtocol* cp)
{
delete cp;
}
static bool
probe_generic_midi_protocol (ControlProtocolDescriptor* /*descriptor*/)
{
return GenericMidiControlProtocol::probe ();
}
// Field names commented out by JE - 06-01-2010
static ControlProtocolDescriptor generic_midi_descriptor = {
/*name : */ "Generic MIDI",
/*id : */ "uri://ardour.org/surfaces/generic_midi:0",
/*module : */ 0,
/*probe : */ probe_generic_midi_protocol,
/*initialize : */ new_generic_midi_protocol,
/*destroy : */ delete_generic_midi_protocol,
/* name */ "Generic MIDI",
/* id */ "uri://ardour.org/surfaces/generic_midi:0",
/* module */ 0,
/* available */ 0,
/* probe_port */ 0,
/* match usb */ 0,
/* initialize */ new_generic_midi_protocol,
/* destroy */ delete_generic_midi_protocol,
};
extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () { return &generic_midi_descriptor; }

View file

@ -32,7 +32,7 @@ using namespace std;
using namespace ArdourSurface;
static ControlProtocol*
new_launch_control_xl (ControlProtocolDescriptor*, Session* s)
new_launch_control_xl (Session* s)
{
LaunchControlXL * lcxl = 0;
@ -50,7 +50,7 @@ new_launch_control_xl (ControlProtocolDescriptor*, Session* s)
}
static void
delete_launch_control_xl (ControlProtocolDescriptor*, ControlProtocol* cp)
delete_launch_control_xl (ControlProtocol* cp)
{
try
{
@ -62,25 +62,15 @@ delete_launch_control_xl (ControlProtocolDescriptor*, ControlProtocol* cp)
}
}
/**
This is called on startup to check whether the lib should be loaded.
So anything that can be changed in the UI should not be used here to
prevent loading of the lib.
*/
static bool
probe_launch_control_xl (ControlProtocolDescriptor*)
{
return LaunchControlXL::probe();
}
static ControlProtocolDescriptor launch_control_xl_descriptor = {
/*name : */ "Novation Launch Control XL",
/*id : */ "uri://ardour.org/surfaces/launch_control_xl:0",
/*module : */ 0,
/*probe : */ probe_launch_control_xl,
/*initialize : */ new_launch_control_xl,
/*destroy : */ delete_launch_control_xl,
/* name */ "Novation Launch Control XL",
/* id */ "uri://ardour.org/surfaces/launch_control_xl:0",
/* module */ 0,
/* available */ 0,
/* probe_port */ 0,
/* match usb */ 0,
/* initialize */ new_launch_control_xl,
/* destroy */ delete_launch_control_xl,
};
extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () { return &launch_control_xl_descriptor; }

View file

@ -421,12 +421,6 @@ LaunchControlXL::init_knobs ()
}
}
bool
LaunchControlXL::probe ()
{
return true;
}
void
LaunchControlXL::do_request (LaunchControlRequest * req)
{

View file

@ -356,9 +356,6 @@ public:
LaunchControlXL(ARDOUR::Session &);
~LaunchControlXL();
static bool probe();
std::list<std::shared_ptr<ARDOUR::Bundle> > bundles();
bool has_editor() const { return true; }

View file

@ -35,7 +35,7 @@ using namespace ArdourSurface;
using namespace Mackie;
static ControlProtocol*
new_mackie_protocol (ControlProtocolDescriptor*, Session* s)
new_mackie_protocol (Session* s)
{
MackieControlProtocol* mcp = 0;
@ -53,7 +53,7 @@ new_mackie_protocol (ControlProtocolDescriptor*, Session* s)
}
static void
delete_mackie_protocol (ControlProtocolDescriptor*, ControlProtocol* cp)
delete_mackie_protocol (ControlProtocol* cp)
{
try
{
@ -65,26 +65,16 @@ delete_mackie_protocol (ControlProtocolDescriptor*, ControlProtocol* cp)
}
}
/**
This is called on startup to check whether the lib should be loaded.
So anything that can be changed in the UI should not be used here to
prevent loading of the lib.
*/
static bool
probe_mackie_protocol (ControlProtocolDescriptor*)
{
return MackieControlProtocol::probe();
}
// Field names commented out by JE - 06-01-2010
static ControlProtocolDescriptor mackie_descriptor = {
/*name : */ "Mackie",
/*id : */ "uri://ardour.org/surfaces/mackie:0",
/*module : */ 0,
/*probe : */ probe_mackie_protocol,
/*initialize : */ new_mackie_protocol,
/*destroy : */ delete_mackie_protocol,
/* name */ "Mackie",
/* id */ "uri://ardour.org/surfaces/mackie:0",
/* module */ 0,
/* available */ 0,
/* probe_port */ 0,
/* match usb */ 0,
/* initialize */ new_mackie_protocol,
/* destroy */ delete_mackie_protocol,
};
extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () { return &mackie_descriptor; }

View file

@ -115,11 +115,6 @@ const int MackieControlProtocol::MAIN_MODIFIER_MASK = (MackieControlProtocol::MO
MackieControlProtocol* MackieControlProtocol::_instance = 0;
bool MackieControlProtocol::probe()
{
return true;
}
MackieControlProtocol::MackieControlProtocol (Session& session)
: ControlProtocol (session, X_("Mackie"))
, AbstractUI<MackieControlUIRequest> (name())

View file

@ -160,8 +160,6 @@ class MackieControlProtocol
support for the protocol is not optional.
*/
static bool probe();
mutable Glib::Threads::Mutex surfaces_lock;
typedef std::list<std::shared_ptr<Mackie::Surface> > Surfaces;
Surfaces surfaces;

View file

@ -28,7 +28,7 @@ using namespace PBD;
using namespace ArdourSurface;
static ControlProtocol*
new_maschine2 (ControlProtocolDescriptor*, Session* s)
new_maschine2 (Session* s)
{
Maschine2* m2 = 0;
@ -46,24 +46,20 @@ new_maschine2 (ControlProtocolDescriptor*, Session* s)
}
static void
delete_maschine2 (ControlProtocolDescriptor*, ControlProtocol* cp)
delete_maschine2 (ControlProtocol* cp)
{
delete cp;
}
static bool
probe_maschine2 (ControlProtocolDescriptor*)
{
return true;
}
static ControlProtocolDescriptor maschine2_descriptor = {
/*name : */ "NI Maschine2",
/*id : */ "uri://ardour.org/surfaces/maschine2:0",
/*module : */ 0,
/*probe : */ probe_maschine2,
/*initialize : */ new_maschine2,
/*destroy : */ delete_maschine2,
/* name */ "NI Maschine2",
/* id */ "uri://ardour.org/surfaces/maschine2:0",
/* module */ 0,
/* available */ Maschine2::available,
/* probe_port */ 0,
/* match usb */ 0,
/* initialize */ new_maschine2,
/* destroy */ delete_maschine2,
};
extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () { return &maschine2_descriptor; }

View file

@ -103,6 +103,16 @@ class TestLayout : public Maschine2Layout
static TestLayout* tl = NULL;
#endif
bool
Maschine2::available ()
{
if (hid_init()) {
return false;
}
hid_exit ();
return true;
}
Maschine2::Maschine2 (ARDOUR::Session& s)
: ControlProtocol (s, string (X_("NI Maschine2")))
, AbstractUI<Maschine2Request> (name())

View file

@ -64,6 +64,7 @@ class Maschine2: public ARDOUR::ControlProtocol, public AbstractUI<Maschine2Requ
Maschine2 (ARDOUR::Session&);
~Maschine2 ();
static bool available ();
#if 0
bool has_editor () const { return false; }

View file

@ -25,7 +25,7 @@ using namespace ARDOUR;
using namespace ArdourSurface;
static ControlProtocol*
new_osc_protocol (ControlProtocolDescriptor* /*descriptor*/, Session* s)
new_osc_protocol (Session* s)
{
OSC* osc = new OSC (*s, Config->get_osc_port());
@ -35,24 +35,20 @@ new_osc_protocol (ControlProtocolDescriptor* /*descriptor*/, Session* s)
}
static void
delete_osc_protocol (ControlProtocolDescriptor* /*descriptor*/, ControlProtocol* cp)
delete_osc_protocol (ControlProtocol* cp)
{
delete cp;
}
static bool
probe_osc_protocol (ControlProtocolDescriptor* /*descriptor*/)
{
return true; // we can always do OSC
}
static ControlProtocolDescriptor osc_descriptor = {
/*name : */ "Open Sound Control (OSC)",
/*id : */ "uri://ardour.org/surfaces/osc:0",
/*module : */ 0,
/*probe : */ probe_osc_protocol,
/*initialize : */ new_osc_protocol,
/*destroy : */ delete_osc_protocol,
/* name */ "Open Sound Control (OSC)",
/* id */ "uri://ardour.org/surfaces/osc:0",
/* module */ 0,
/* available */ 0,
/* probe_port */ 0,
/* match usb */ 0,
/* initialize */ new_osc_protocol,
/* destroy */ delete_osc_protocol,
};
extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () { return &osc_descriptor; }

View file

@ -30,7 +30,7 @@ using namespace PBD;
using namespace ArdourSurface;
static ControlProtocol*
new_push2 (ControlProtocolDescriptor*, Session* s)
new_push2 (Session* s)
{
Push2 * p2 = 0;
@ -48,7 +48,7 @@ new_push2 (ControlProtocolDescriptor*, Session* s)
}
static void
delete_push2 (ControlProtocolDescriptor*, ControlProtocol* cp)
delete_push2 (ControlProtocol* cp)
{
try
{
@ -60,25 +60,15 @@ delete_push2 (ControlProtocolDescriptor*, ControlProtocol* cp)
}
}
/**
This is called on startup to check whether the lib should be loaded.
So anything that can be changed in the UI should not be used here to
prevent loading of the lib.
*/
static bool
probe_push2 (ControlProtocolDescriptor*)
{
return Push2::probe();
}
static ControlProtocolDescriptor push2_descriptor = {
/*name : */ "Ableton Push 2",
/*id : */ "uri://ardour.org/surfaces/push2:0",
/*module : */ 0,
/*probe : */ probe_push2,
/*initialize : */ new_push2,
/*destroy : */ delete_push2,
/* name */ "Ableton Push 2",
/* id */ "uri://ardour.org/surfaces/push2:0",
/* module */ 0,
/* available */ Push2::available,
/* probe_port */ 0,
/* match usb */ 0,
/* initialize */ new_push2,
/* destroy */ delete_push2,
};
extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () { return &push2_descriptor; }

View file

@ -96,6 +96,16 @@ row_interval_semitones (const Push2::RowInterval row_interval, const bool inkey)
return 5;
}
bool
Push2::available ()
{
bool rv = LIBUSB_SUCCESS == libusb_init (0);
if (rv) {
libusb_exit (0);
}
return rv;
}
Push2::Push2 (ARDOUR::Session& s)
: MIDISurface (s, X_("Ableton Push 2"), X_("Push 2"), true)
, _handle (0)
@ -342,12 +352,6 @@ Push2::init_buttons (bool startup)
}
}
bool
Push2::probe ()
{
return true;
}
void
Push2::splash ()
{

View file

@ -296,7 +296,7 @@ class Push2 : public MIDISurface
Push2 (ARDOUR::Session&);
~Push2 ();
static bool probe ();
static bool available ();
std::string input_port_name () const;
std::string output_port_name () const;

View file

@ -24,7 +24,7 @@
using namespace ARDOUR;
static ControlProtocol*
new_tranzport_protocol (ControlProtocolDescriptor* descriptor, Session* s)
new_tranzport_protocol (Session* s)
{
TranzportControlProtocol* tcp = new TranzportControlProtocol (*s);
@ -38,24 +38,20 @@ new_tranzport_protocol (ControlProtocolDescriptor* descriptor, Session* s)
}
static void
delete_tranzport_protocol (ControlProtocolDescriptor* descriptor, ControlProtocol* cp)
delete_tranzport_protocol (ControlProtocol* cp)
{
delete cp;
}
static bool
probe_tranzport_protocol (ControlProtocolDescriptor* descriptor)
{
return TranzportControlProtocol::probe();
}
static ControlProtocolDescriptor tranzport_descriptor = {
name : "Tranzport",
id : "uri://ardour.org/surfaces/tranzport:0",
module : 0,
probe : probe_tranzport_protocol,
initialize : new_tranzport_protocol,
destroy : delete_tranzport_protocol
/* name */ "Tranzport",
/* id */ "uri://ardour.org/surfaces/tranzport:0",
/* module */ 0,
/* available */ TranzportControlProtocol::available,
/* probe_port */ 0,
/* match usb */ 0,
/* initialize */ new_tranzport_protocol,
/* destroy */ delete_tranzport_protocol,
};

View file

@ -44,7 +44,7 @@ using namespace PBD;
// pure boilerplate and could easily be abstracted elsewhere
bool
TranzportControlProtocol::probe ()
TranzportControlProtocol::available ()
{
struct usb_bus *bus;
struct usb_device *dev;

View file

@ -46,7 +46,7 @@ public:
int set_active (bool yn);
static bool probe ();
static bool available ();
XMLNode& get_state () const;
int set_state (const XMLNode&);

View file

@ -32,7 +32,7 @@ using namespace ArdourSurface;
using namespace US2400;
static ControlProtocol*
new_us2400_protocol (ControlProtocolDescriptor*, Session* s)
new_us2400_protocol (Session* s)
{
US2400Protocol* mcp = 0;
@ -50,7 +50,7 @@ new_us2400_protocol (ControlProtocolDescriptor*, Session* s)
}
static void
delete_us2400_protocol (ControlProtocolDescriptor*, ControlProtocol* cp)
delete_us2400_protocol (ControlProtocol* cp)
{
try
{
@ -62,26 +62,15 @@ delete_us2400_protocol (ControlProtocolDescriptor*, ControlProtocol* cp)
}
}
/**
This is called on startup to check whether the lib should be loaded.
So anything that can be changed in the UI should not be used here to
prevent loading of the lib.
*/
static bool
probe_us2400_protocol (ControlProtocolDescriptor*)
{
return US2400Protocol::probe();
}
// Field names commented out by JE - 06-01-2010
static ControlProtocolDescriptor us2400_descriptor = {
/*name : */ "Tascam US-2400",
/*id : */ "uri://ardour.org/surfaces/us2400:0",
/*module : */ 0,
/*probe : */ probe_us2400_protocol,
/*initialize : */ new_us2400_protocol,
/*destroy : */ delete_us2400_protocol,
/* name */ "Tascam US-2400",
/* id */ "uri://ardour.org/surfaces/us2400:0",
/* module */ 0,
/* avilable */ 0,
/* probe_port */ 0,
/* match usb */ 0,
/* initialize */ new_us2400_protocol,
/* destroy */ delete_us2400_protocol,
};
extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () { return &us2400_descriptor; }

View file

@ -100,11 +100,6 @@ const int US2400Protocol::MAIN_MODIFIER_MASK = (US2400Protocol::MODIFIER_OPTION|
US2400Protocol* US2400Protocol::_instance = 0;
bool US2400Protocol::probe()
{
return true;
}
US2400Protocol::US2400Protocol (Session& session)
: ControlProtocol (session, X_("Tascam US-2400"))
, AbstractUI<US2400ControlUIRequest> (name())

View file

@ -138,8 +138,6 @@ class US2400Protocol
support for the protocol is not optional.
*/
static bool probe();
mutable Glib::Threads::Mutex surfaces_lock;
typedef std::list<std::shared_ptr<US2400::Surface> > Surfaces;
Surfaces surfaces;

View file

@ -26,8 +26,7 @@ using namespace ARDOUR;
using namespace ArdourSurface;
static ControlProtocol*
new_ardour_websockets_protocol (ControlProtocolDescriptor* /*descriptor*/,
Session* s)
new_ardour_websockets_protocol (Session* s)
{
ArdourWebsockets* surface = new ArdourWebsockets (*s);
@ -37,25 +36,20 @@ new_ardour_websockets_protocol (ControlProtocolDescriptor* /*descriptor*/,
}
static void
delete_ardour_websockets_protocol (ControlProtocolDescriptor* /*descriptor*/,
ControlProtocol* cp)
delete_ardour_websockets_protocol (ControlProtocol* cp)
{
delete cp;
}
static bool
probe_ardour_websockets_protocol (ControlProtocolDescriptor* /*descriptor*/)
{
return true;
}
static ControlProtocolDescriptor ardour_websockets_descriptor = {
/*name : */ surface_name,
/*id : */ surface_id,
/*module : */ 0,
/*probe : */ probe_ardour_websockets_protocol,
/*initialize : */ new_ardour_websockets_protocol,
/*destroy : */ delete_ardour_websockets_protocol,
/* name */ surface_name,
/* id */ surface_id,
/* module */ 0,
/* available */ 0,
/* probe_port */ 0,
/* match usb */ 0,
/* initialize */ new_ardour_websockets_protocol,
/* destroy */ delete_ardour_websockets_protocol,
};
extern "C" ARDOURSURFACE_API ControlProtocolDescriptor*

View file

@ -28,7 +28,7 @@ using namespace ARDOUR;
using namespace PBD;
static ControlProtocol*
new_wiimote_protocol (ControlProtocolDescriptor*, Session* s)
new_wiimote_protocol (Session* s)
{
WiimoteControlProtocol* wmcp = new WiimoteControlProtocol (*s);
wmcp->set_active (true);
@ -36,24 +36,20 @@ new_wiimote_protocol (ControlProtocolDescriptor*, Session* s)
}
static void
delete_wiimote_protocol (ControlProtocolDescriptor* /*descriptor*/, ControlProtocol* cp)
delete_wiimote_protocol (ControlProtocol* cp)
{
delete cp;
}
static bool
probe_wiimote_protocol (ControlProtocolDescriptor*)
{
return WiimoteControlProtocol::probe ();
}
static ControlProtocolDescriptor wiimote_descriptor = {
name : "Wiimote",
id : "uri://ardour.org/surfaces/wiimote:0",
module : 0,
probe : probe_wiimote_protocol,
initialize : new_wiimote_protocol,
destroy : delete_wiimote_protocol,
/* name */ "Wiimote",
/* id */ "uri://ardour.org/surfaces/wiimote:0",
/* module */ 0,
/* available */ 0,
/* probe_port */ 0,
/* match usb */ 0,
/* initialize */ new_wiimote_protocol,
/* destroy */ delete_wiimote_protocol,
};
extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () { return &wiimote_descriptor; }

View file

@ -50,12 +50,6 @@ WiimoteControlProtocol::~WiimoteControlProtocol ()
stop ();
}
bool
WiimoteControlProtocol::probe ()
{
return true;
}
int
WiimoteControlProtocol::set_active (bool yn)
{

View file

@ -40,8 +40,6 @@ public:
WiimoteControlProtocol (ARDOUR::Session &);
virtual ~WiimoteControlProtocol ();
static bool probe ();
int set_active (bool yn);
XMLNode& get_state () const;