diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index 8a286b27f..09deca4a3 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -107,10 +107,12 @@ void CarlaEngineEventPort::initBuffer(CarlaEngine* const engine) if (engine == nullptr) return; +#ifndef BUILD_BRIDGE if (kProcessMode == PROCESS_MODE_CONTINUOUS_RACK) fBuffer = engine->getRackEventBuffer(kIsInput); else if (kProcessMode == PROCESS_MODE_PATCHBAY && ! kIsInput) carla_zeroMem(fBuffer, sizeof(EngineEvent)*PATCHBAY_EVENT_COUNT); +#endif } uint32_t CarlaEngineEventPort::getEventCount() @@ -700,11 +702,9 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons case PLUGIN_NONE: break; -#ifndef BUILD_BRIDGE case PLUGIN_INTERNAL: plugin = CarlaPlugin::newNative(init); break; -#endif case PLUGIN_LADSPA: plugin = CarlaPlugin::newLADSPA(init, (const LADSPA_RDF_Descriptor*)extra); diff --git a/source/backend/engine/CarlaEngineOsc.cpp b/source/backend/engine/CarlaEngineOsc.cpp index 19955bec5..a542dbd8d 100644 --- a/source/backend/engine/CarlaEngineOsc.cpp +++ b/source/backend/engine/CarlaEngineOsc.cpp @@ -23,11 +23,13 @@ CARLA_BACKEND_START_NAMESPACE +#ifndef BUILD_BRIDGE // ------------------------------------------------------------------- // Bridge Helper, defined in plugin/CarlaBlugin.cpp extern int CarlaPluginSetOscBridgeInfo(CarlaPlugin* const plugin, const PluginBridgeInfoType type, const int argc, const lo_arg* const* const argv, const char* const types); +#endif // ----------------------------------------------------------------------- @@ -161,9 +163,7 @@ bool isDigit(const char c) int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, const int argc, const lo_arg* const* const argv, const char* const types, const lo_message msg) { -#if DEBUG - carla_debug("CarlaEngineOsc::handleMessage(%s, %s, %i, %p, %s, %p)", bool2str(isTCP), path, argc, argv, types, msg); -#endif + carla_debug("CarlaEngineOsc::handleMessage(%s, \"%s\", %i, %p, \"%s\", %p)", bool2str(isTCP), path, argc, argv, types, msg); CARLA_ASSERT(fName.isNotEmpty()); CARLA_ASSERT(fServerPathTCP.isNotEmpty()); CARLA_ASSERT(fServerPathUDP.isNotEmpty()); @@ -185,12 +185,12 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, cons #ifndef BUILD_BRIDGE // Initial path check - if (strcmp(path, "/register") == 0) + if (std::strcmp(path, "/register") == 0) { const lo_address source = lo_message_get_source(msg); return handleMsgRegister(isTCP, argc, argv, types, source); } - if (strcmp(path, "/unregister") == 0) + if (std::strcmp(path, "/unregister") == 0) { return handleMsgUnregister(); } @@ -270,104 +270,104 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, cons } // Common OSC methods (DSSI and bridge UIs) - if (strcmp(method, "update") == 0) + if (std::strcmp(method, "update") == 0) { const lo_address source = lo_message_get_source(msg); return handleMsgUpdate(plugin, argc, argv, types, source); } - if (strcmp(method, "configure") == 0) + if (std::strcmp(method, "configure") == 0) return handleMsgConfigure(plugin, argc, argv, types); - if (strcmp(method, "control") == 0) + if (std::strcmp(method, "control") == 0) return handleMsgControl(plugin, argc, argv, types); - if (strcmp(method, "program") == 0) + if (std::strcmp(method, "program") == 0) return handleMsgProgram(plugin, argc, argv, types); - if (strcmp(method, "midi") == 0) + if (std::strcmp(method, "midi") == 0) return handleMsgMidi(plugin, argc, argv, types); - if (strcmp(method, "exiting") == 0) + if (std::strcmp(method, "exiting") == 0) return handleMsgExiting(plugin); #ifndef BUILD_BRIDGE // Internal methods - if (strcmp(method, "set_active") == 0) + if (std::strcmp(method, "set_active") == 0) return handleMsgSetActive(plugin, argc, argv, types); - if (strcmp(method, "set_drywet") == 0) + if (std::strcmp(method, "set_drywet") == 0) return handleMsgSetDryWet(plugin, argc, argv, types); - if (strcmp(method, "set_volume") == 0) + if (std::strcmp(method, "set_volume") == 0) return handleMsgSetVolume(plugin, argc, argv, types); - if (strcmp(method, "set_balance_left") == 0) + if (std::strcmp(method, "set_balance_left") == 0) return handleMsgSetBalanceLeft(plugin, argc, argv, types); - if (strcmp(method, "set_balance_right") == 0) + if (std::strcmp(method, "set_balance_right") == 0) return handleMsgSetBalanceRight(plugin, argc, argv, types); - if (strcmp(method, "set_panning") == 0) + if (std::strcmp(method, "set_panning") == 0) return handleMsgSetPanning(plugin, argc, argv, types); - if (strcmp(method, "set_parameter_value") == 0) + if (std::strcmp(method, "set_parameter_value") == 0) return handleMsgSetParameterValue(plugin, argc, argv, types); - if (strcmp(method, "set_parameter_midi_cc") == 0) + if (std::strcmp(method, "set_parameter_midi_cc") == 0) return handleMsgSetParameterMidiCC(plugin, argc, argv, types); - if (strcmp(method, "set_parameter_midi_channel") == 0) + if (std::strcmp(method, "set_parameter_midi_channel") == 0) return handleMsgSetParameterMidiChannel(plugin, argc, argv, types); - if (strcmp(method, "set_program") == 0) + if (std::strcmp(method, "set_program") == 0) return handleMsgSetProgram(plugin, argc, argv, types); - if (strcmp(method, "set_midi_program") == 0) + if (std::strcmp(method, "set_midi_program") == 0) return handleMsgSetMidiProgram(plugin, argc, argv, types); - if (strcmp(method, "note_on") == 0) + if (std::strcmp(method, "note_on") == 0) return handleMsgNoteOn(plugin, argc, argv, types); - if (strcmp(method, "note_off") == 0) + if (std::strcmp(method, "note_off") == 0) return handleMsgNoteOff(plugin, argc, argv, types); // Plugin Bridges if ((plugin->hints() & PLUGIN_IS_BRIDGE) > 0 && strlen(method) > 11 && strncmp(method, "bridge_", 7) == 0) { - if (strcmp(method+7, "set_peaks") == 0) + if (std::strcmp(method+7, "set_peaks") == 0) return handleMsgBridgeSetPeaks(plugin, argc, argv, types); - if (strcmp(method+7, "audio_count") == 0) + if (std::strcmp(method+7, "audio_count") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeAudioCount, argc, argv, types); - if (strcmp(method+7, "midi_count") == 0) + if (std::strcmp(method+7, "midi_count") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeMidiCount, argc, argv, types); - if (strcmp(method+7, "parameter_count") == 0) + if (std::strcmp(method+7, "parameter_count") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeParameterCount, argc, argv, types); - if (strcmp(method+7, "program_count") == 0) + if (std::strcmp(method+7, "program_count") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeProgramCount, argc, argv, types); - if (strcmp(method+7, "midi_program_count") == 0) + if (std::strcmp(method+7, "midi_program_count") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeMidiProgramCount, argc, argv, types); - if (strcmp(method+7, "plugin_info") == 0) + if (std::strcmp(method+7, "plugin_info") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgePluginInfo, argc, argv, types); - if (strcmp(method+7, "parameter_info") == 0) + if (std::strcmp(method+7, "parameter_info") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeParameterInfo, argc, argv, types); - if (strcmp(method+7, "parameter_data") == 0) + if (std::strcmp(method+7, "parameter_data") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeParameterData, argc, argv, types); - if (strcmp(method+7, "parameter_ranges") == 0) + if (std::strcmp(method+7, "parameter_ranges") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeParameterRanges, argc, argv, types); - if (strcmp(method+7, "program_info") == 0) + if (std::strcmp(method+7, "program_info") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeProgramInfo, argc, argv, types); - if (strcmp(method+7, "midi_program_info") == 0) + if (std::strcmp(method+7, "midi_program_info") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeMidiProgramInfo, argc, argv, types); - if (strcmp(method+7, "configure") == 0) + if (std::strcmp(method+7, "configure") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeConfigure, argc, argv, types); - if (strcmp(method+7, "set_parameter_value") == 0) + if (std::strcmp(method+7, "set_parameter_value") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeSetParameterValue, argc, argv, types); - if (strcmp(method+7, "set_default_value") == 0) + if (std::strcmp(method+7, "set_default_value") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeSetDefaultValue, argc, argv, types); - if (strcmp(method+7, "set_program") == 0) + if (std::strcmp(method+7, "set_program") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeSetProgram, argc, argv, types); - if (strcmp(method+7, "set_midi_program") == 0) + if (std::strcmp(method+7, "set_midi_program") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeSetMidiProgram, argc, argv, types); - if (strcmp(method+7, "set_custom_data") == 0) + if (std::strcmp(method+7, "set_custom_data") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeSetCustomData, argc, argv, types); - if (strcmp(method+7, "set_chunk_data") == 0) + if (std::strcmp(method+7, "set_chunk_data") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeSetChunkData, argc, argv, types); - if (strcmp(method+7, "update") == 0) + if (std::strcmp(method+7, "update") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeUpdateNow, argc, argv, types); - if (strcmp(method+7, "error") == 0) + if (std::strcmp(method+7, "error") == 0) return CarlaPluginSetOscBridgeInfo(plugin, kPluginBridgeError, argc, argv, types); } #endif // Plugin-specific methods, FIXME #if 0 //def WANT_LV2 - if (strcmp(method, "lv2_atom_transfer") == 0) + if (std::strcmp(method, "lv2_atom_transfer") == 0) return handleMsgLv2AtomTransfer(plugin, argc, argv, types); - if (strcmp(method, "lv2_event_transfer") == 0) + if (std::strcmp(method, "lv2_event_transfer") == 0) return handleMsgLv2EventTransfer(plugin, argc, argv, types); #endif diff --git a/source/backend/engine/CarlaEngineOsc.hpp b/source/backend/engine/CarlaEngineOsc.hpp index 79fd93c09..1668d5037 100644 --- a/source/backend/engine/CarlaEngineOsc.hpp +++ b/source/backend/engine/CarlaEngineOsc.hpp @@ -19,8 +19,8 @@ #define __CARLA_ENGINE_OSC_HPP__ #include "CarlaBackend.hpp" -#include "CarlaString.hpp" #include "CarlaOscUtils.hpp" +#include "CarlaString.hpp" #define CARLA_ENGINE_OSC_HANDLE_ARGS1 CarlaPlugin* const plugin #define CARLA_ENGINE_OSC_HANDLE_ARGS2 CarlaPlugin* const plugin, const int argc, const lo_arg* const* const argv, const char* const types diff --git a/source/backend/plugin/FluidSynthPlugin.cpp b/source/backend/plugin/FluidSynthPlugin.cpp index aaaf0d1f8..ccc311539 100644 --- a/source/backend/plugin/FluidSynthPlugin.cpp +++ b/source/backend/plugin/FluidSynthPlugin.cpp @@ -1406,7 +1406,7 @@ CARLA_BACKEND_START_NAMESPACE CarlaPlugin* CarlaPlugin::newSF2(const Initializer& init, const bool use16Outs) { - carla_debug("CarlaPlugin::newSF2({%p, \"%s\", \"%s\", \"%s\"})", init.engine, init.filename, init.name, init.label); + carla_debug("CarlaPlugin::newSF2({%p, \"%s\", \"%s\", \"%s\"}, %s)", init.engine, init.filename, init.name, init.label, bool2str(use16Outs)); #ifdef WANT_FLUIDSYNTH if (! fluid_is_soundfont(init.filename)) @@ -1436,6 +1436,9 @@ CarlaPlugin* CarlaPlugin::newSF2(const Initializer& init, const bool use16Outs) #else init.engine->setLastError("fluidsynth support not available"); return nullptr; + + // unused + (void)use16Outs; #endif } diff --git a/source/bridges/CarlaBridgeClient.hpp b/source/bridges/CarlaBridgeClient.hpp index e70bb7a1a..4695605b8 100644 --- a/source/bridges/CarlaBridgeClient.hpp +++ b/source/bridges/CarlaBridgeClient.hpp @@ -15,10 +15,10 @@ * For a full copy of the GNU General Public License see the GPL.txt file */ -#ifndef CARLA_BRIDGE_CLIENT_HPP -#define CARLA_BRIDGE_CLIENT_HPP +#ifndef __CARLA_BRIDGE_CLIENT_HPP__ +#define __CARLA_BRIDGE_CLIENT_HPP__ -#include "carla_bridge_osc.hpp" +#include "CarlaBridgeOsc.hpp" CARLA_BRIDGE_START_NAMESPACE @@ -132,15 +132,15 @@ protected: // --------------------------------------------------------------------- private: - CarlaBridgeOsc m_osc; - CarlaBridgeToolkit* const m_toolkit; + CarlaBridgeOsc const kOsc; + CarlaBridgeToolkit* const kToolkit; - const CarlaOscData* m_oscData; + const CarlaOscData* fOscData; #ifdef BUILD_BRIDGE_UI - char* m_uiFilename; - void* m_uiLib; - bool m_uiQuit; + char* fFilename; + void* fLib; + bool fQuit; #else friend class CarlaPluginClient; #endif @@ -150,4 +150,4 @@ private: CARLA_BRIDGE_END_NAMESPACE -#endif // CARLA_BRIDGE_CLIENT_HPP +#endif // __CARLA_BRIDGE_CLIENT_HPP__ diff --git a/source/bridges/CarlaBridgeOsc.cpp b/source/bridges/CarlaBridgeOsc.cpp index 387a826a0..b9e458d0f 100644 --- a/source/bridges/CarlaBridgeOsc.cpp +++ b/source/bridges/CarlaBridgeOsc.cpp @@ -15,159 +15,107 @@ * For a full copy of the GNU General Public License see the GPL.txt file */ -#include "carla_bridge_osc.hpp" -#include "carla_bridge_client.hpp" +#include "CarlaBridgeOsc.hpp" + +#include "CarlaBridgeClient.hpp" #include "CarlaMIDI.h" #include "CarlaUtils.hpp" -#include -#include +int main() { return 0; } CARLA_BRIDGE_START_NAMESPACE // ----------------------------------------------------------------------- -CarlaBridgeOsc::CarlaBridgeOsc(CarlaBridgeClient* const client_) - : client(client_) +CarlaBridgeOsc::CarlaBridgeOsc(CarlaBridgeClient* const client) + : kClient(client), + fServer(nullptr) { carla_debug("CarlaBridgeOsc::CarlaBridgeOsc(%p)", client); - CARLA_ASSERT(client); - - m_name = nullptr; - m_nameSize = 0; - - m_server = nullptr; - m_serverPath = nullptr; + CARLA_ASSERT(client != nullptr); } CarlaBridgeOsc::~CarlaBridgeOsc() { carla_debug("CarlaBridgeOsc::~CarlaBridgeOsc()"); - CARLA_ASSERT(! m_name); - CARLA_ASSERT(! m_server); - CARLA_ASSERT(! m_serverPath); + CARLA_ASSERT(fName.isEmpty()); + CARLA_ASSERT(fServerPath.isEmpty()); + CARLA_ASSERT(fServer == nullptr); } -bool CarlaBridgeOsc::init(const char* const url) +void CarlaBridgeOsc::init(const char* const url) { carla_debug("CarlaBridgeOsc::init(\"%s\")", url); - CARLA_ASSERT(! m_name); - CARLA_ASSERT(! m_server); - CARLA_ASSERT(! m_serverPath); - CARLA_ASSERT(m_nameSize == 0); - CARLA_ASSERT(url); - - if (! url) - { - carla_stderr("CarlaBridgeOsc::init(\"%s\") - invalid url", url); - return false; - } + CARLA_ASSERT(fName.isEmpty()); + CARLA_ASSERT(fServerPath.isEmpty()); + CARLA_ASSERT(fServer == nullptr); + CARLA_ASSERT(url != nullptr); #ifdef BUILD_BRIDGE_PLUGIN - m_name = strdup("carla-bridge-plugin"); + fName = "carla-bridge-plugin"; #else - m_name = strdup("carla-bridge-ui"); + fName = "carla-bridge-ui"; #endif - m_nameSize = strlen(m_name); - - char* const host = lo_url_get_hostname(url); - char* const path = lo_url_get_path(url); - char* const port = lo_url_get_port(url); - if (! host) { - carla_stderr("CarlaBridgeOsc::init(\"%s\") - failed to get url hostname", url); - return false; - } - - if (! path) - { - std::free(host); - carla_stderr("CarlaBridgeOsc::init(\"%s\") - failed to get url path", url); - return false; - } + char* const host = lo_url_get_hostname(url); + char* const port = lo_url_get_port(url); + fControlData.path = carla_strdup_free(lo_url_get_path(url)); + fControlData.target = lo_address_new_with_proto(LO_TCP, host, port); - if (! port) - { std::free(host); - std::free(path); - carla_stderr("CarlaBridgeOsc::init(\"%s\") - failed to get url port", url); - return false; + std::free(port); } - m_controlData.path = carla_strdup(path); - m_controlData.target = lo_address_new_with_proto(LO_TCP, host, port); + fServer = lo_server_new_with_proto(nullptr, LO_TCP, osc_error_handler); - std::free(path); - std::free(host); - std::free(port); - - if (! m_controlData.target) + if (fServer != nullptr) { - carla_stderr("CarlaBridgeOsc::init(\"%s\") - failed to get new url address for host '%s' and port '%s'", url, host, port); - return false; + if (char* const tmpServerPath = lo_server_get_url(fServer)) + { + fServerPath = tmpServerPath; + fServerPath += fName; + std::free(tmpServerPath); + } + + lo_server_add_method(fServer, nullptr, nullptr, osc_message_handler, this); } - m_server = lo_server_new_with_proto(nullptr, LO_TCP, osc_error_handler); - - if (! m_server) - { - carla_stderr("CarlaBridgeOsc::init(\"%s\") - failed to create new OSC server", url); - return false; - } - - if (char* const serverUrl = lo_server_get_url(m_server)) - { - m_serverPath = strdup(QString("%1%2").arg(serverUrl).arg(m_name).toUtf8().constData()); - std::free(serverUrl); - } - else - m_serverPath = strdup(QString("%1carla-bridge").arg(serverUrl).toUtf8().constData()); - - lo_server_add_method(m_server, nullptr, nullptr, osc_message_handler, this); - - return true; + CARLA_ASSERT(fName.isNotEmpty()); + CARLA_ASSERT(fServerPath.isNotEmpty()); + CARLA_ASSERT(fServer != nullptr); } void CarlaBridgeOsc::idle() { - CARLA_ASSERT(m_server); - - if (m_server) + if (fServer != nullptr) { - while (lo_server_recv_noblock(m_server, 0) != 0) {} + while (lo_server_recv_noblock(fServer, 0) != 0) {} } } void CarlaBridgeOsc::close() { carla_debug("CarlaBridgeOsc::close()"); - CARLA_ASSERT(m_name); - CARLA_ASSERT(m_server); - CARLA_ASSERT(m_serverPath); + CARLA_ASSERT(fName.isNotEmpty()); + CARLA_ASSERT(fServerPath.isNotEmpty()); + CARLA_ASSERT(fServer != nullptr); - m_nameSize = 0; + fName.clear(); - if (m_name) + if (fServer != nullptr) { - free(m_name); - m_name = nullptr; + lo_server_del_method(fServer, nullptr, nullptr); + lo_server_free(fServer); + fServer = nullptr; } - if (m_server) - { - lo_server_del_method(m_server, nullptr, nullptr); - lo_server_free(m_server); - m_server = nullptr; - } + fServerPath.clear(); + fControlData.free(); - if (m_serverPath) - { - free(m_serverPath); - m_serverPath = nullptr; - } - - m_controlData.free(); + CARLA_ASSERT(fName.isEmpty()); + CARLA_ASSERT(fServerPath.isEmpty()); + CARLA_ASSERT(fServer == nullptr); } // ----------------------------------------------------------------------- @@ -175,31 +123,35 @@ void CarlaBridgeOsc::close() int CarlaBridgeOsc::handleMessage(const char* const path, const int argc, const lo_arg* const* const argv, const char* const types, const lo_message msg) { carla_debug("CarlaBridgeOsc::handleMessage(\"%s\", %i, %p, \"%s\", %p)", path, argc, argv, types, msg); - CARLA_ASSERT(m_name); - CARLA_ASSERT(m_server); - CARLA_ASSERT(m_serverPath); - CARLA_ASSERT(path); + CARLA_ASSERT(fName.isNotEmpty()); + CARLA_ASSERT(fServerPath.isNotEmpty()); + CARLA_ASSERT(fServer != nullptr); + CARLA_ASSERT(path != nullptr); - if (! path) + if (path == nullptr) { carla_stderr("CarlaBridgeOsc::handleMessage() - got invalid path"); return 1; } - if (! (m_name && m_server && m_serverPath)) + if (fName.isEmpty()) { carla_stderr("CarlaBridgeOsc::handleMessage(\"%s\", ...) - received message but client is offline", path); return 1; } - if (strlen(path) <= m_nameSize || strncmp(path+1, m_name, m_nameSize) != 0) + const size_t nameSize = fName.length(); + + // Check if message is for this client + if (std::strlen(path) <= nameSize || std::strncmp(path+1, (const char*)fName, nameSize) != 0) { - carla_stderr("CarlaBridgeOsc::handleMessage() - message not for this client: '%s' != '/%s/'", path, m_name); + carla_stderr("CarlaBridgeOsc::handleMessage() - message not for this client -> '%s' != '/%s/'", path, (const char*)fName); return 1; } + // Get method from path char method[32] = { 0 }; - strncpy(method, path + (m_nameSize + 2), 31); + std::strncpy(method, path + (nameSize + 2), 31); if (method[0] == '\0') { @@ -208,49 +160,48 @@ int CarlaBridgeOsc::handleMessage(const char* const path, const int argc, const } // Common OSC methods - if (strcmp(method, "configure") == 0) + if (std::strcmp(method, "configure") == 0) return handleMsgConfigure(argc, argv, types); - if (strcmp(method, "control") == 0) + if (std::strcmp(method, "control") == 0) return handleMsgControl(argc, argv, types); - if (strcmp(method, "program") == 0) + if (std::strcmp(method, "program") == 0) return handleMsgProgram(argc, argv, types); - if (strcmp(method, "midi_program") == 0) + if (std::strcmp(method, "midi-program") == 0) return handleMsgMidiProgram(argc, argv, types); - if (strcmp(method, "midi") == 0) + if (std::strcmp(method, "midi") == 0) return handleMsgMidi(argc, argv, types); - if (strcmp(method, "sample-rate") == 0) + if (std::strcmp(method, "sample-rate") == 0) return 0; // unused - if (strcmp(method, "show") == 0) + if (std::strcmp(method, "show") == 0) return handleMsgShow(); - if (strcmp(method, "hide") == 0) + if (std::strcmp(method, "hide") == 0) return handleMsgHide(); - if (strcmp(method, "quit") == 0) + if (std::strcmp(method, "quit") == 0) return handleMsgQuit(); #ifdef BRIDGE_LV2 // LV2 UI methods - if (strcmp(method, "lv2_atom_transfer") == 0) + if (std::strcmp(method, "lv2_atom_transfer") == 0) return handleMsgLv2TransferAtom(argc, argv, types); - if (strcmp(method, "lv2_event_transfer") == 0) + if (std::strcmp(method, "lv2_event_transfer") == 0) return handleMsgLv2TransferEvent(argc, argv, types); #endif #ifdef BUILD_BRIDGE_PLUGIN // Plugin methods - if (strcmp(method, "plugin_save_now") == 0) + if (std::strcmp(method, "plugin_save_now") == 0) return handleMsgPluginSaveNow(); - if (strcmp(method, "plugin_set_chunk") == 0) + if (std::strcmp(method, "plugin_set_chunk") == 0) return handleMsgPluginSetChunk(argc, argv, types); - if (strcmp(method, "plugin_set_custom_data") == 0) + if (std::strcmp(method, "plugin_set_custom_data") == 0) return handleMsgPluginSetCustomData(argc, argv, types); -#endif - #if 0 // TODO - else if (strcmp(method, "set_parameter_midi_channel") == 0) + if (std::strcmp(method, "set_parameter_midi_channel") == 0) return osc_set_parameter_midi_channel_handler(argv); - else if (strcmp(method, "set_parameter_midi_cc") == 0) + if (std::strcmp(method, "set_parameter_midi_cc") == 0) return osc_set_parameter_midi_channel_handler(argv); +#endif #endif carla_stderr("CarlaBridgeOsc::handleMessage(\"%s\", ...) - received unsupported OSC method '%s'", path, method); @@ -260,30 +211,37 @@ int CarlaBridgeOsc::handleMessage(const char* const path, const int argc, const int CarlaBridgeOsc::handleMsgConfigure(CARLA_BRIDGE_OSC_HANDLE_ARGS) { carla_debug("CarlaBridgeOsc::handleMsgConfigure()"); + CARLA_ASSERT(kClient != nullptr); CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "ss"); - if (! client) + if (kClient == nullptr) return 1; // nothing here for now - return 0; - Q_UNUSED(argv); + // unused + (void)argv; } int CarlaBridgeOsc::handleMsgControl(CARLA_BRIDGE_OSC_HANDLE_ARGS) { carla_debug("CarlaBridgeOsc::handleMsgControl()"); + CARLA_ASSERT(kClient != nullptr); CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "if"); - if (! client) + if (kClient == nullptr) return 1; const int32_t index = argv[0]->i; const float value = argv[1]->f; - client->setParameter(index, value); + CARLA_SAFE_ASSERT_INT(index != -1, index); + + if (index == -1) + return 1; + + kClient->setParameter(index, value); return 0; } @@ -291,14 +249,20 @@ int CarlaBridgeOsc::handleMsgControl(CARLA_BRIDGE_OSC_HANDLE_ARGS) int CarlaBridgeOsc::handleMsgProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS) { carla_debug("CarlaBridgeOsc::handleMsgProgram()"); + CARLA_ASSERT(kClient != nullptr); CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(1, "i"); - if (! client) + if (kClient == nullptr) return 1; const int32_t index = argv[0]->i; - client->setProgram(index); + CARLA_SAFE_ASSERT_INT(index >= 0, index); + + if (index < 0) + return 1; + + kClient->setProgram(static_cast(index)); return 0; } @@ -307,14 +271,20 @@ int CarlaBridgeOsc::handleMsgProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS) int CarlaBridgeOsc::handleMsgMidiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS) { carla_debug("CarlaBridgeOsc::handleMsgMidiProgram()"); + CARLA_ASSERT(kClient != nullptr); CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(1, "i"); - if (! client) + if (kClient == nullptr) return 1; const int32_t index = argv[0]->i; - client->setMidiProgram(index); + CARLA_SAFE_ASSERT_INT(index >= 0, index); + + if (index < 0) + return 1; + + kClient->setMidiProgram(static_cast(index)); return 0; } @@ -322,15 +292,24 @@ int CarlaBridgeOsc::handleMsgMidiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS) int CarlaBridgeOsc::handleMsgMidiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS) { carla_debug("CarlaBridgeOsc::handleMsgMidiProgram()"); + CARLA_ASSERT(kClient != nullptr); CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(2, "ii"); - if (! client) + if (kClient == nullptr) return 1; const int32_t bank = argv[0]->i; const int32_t program = argv[1]->i; - client->setMidiProgram(bank, program); + CARLA_SAFE_ASSERT_INT(bank >= 0, bank); + CARLA_SAFE_ASSERT_INT(program >= 0, program); + + if (bank < 0) + return 1; + if (program < 0) + return 1; + + kClient->setMidiProgram(static_cast(bank), static_cast(program)); return 0; } @@ -339,14 +318,13 @@ int CarlaBridgeOsc::handleMsgMidiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS) int CarlaBridgeOsc::handleMsgMidi(CARLA_BRIDGE_OSC_HANDLE_ARGS) { carla_debug("CarlaBridgeOsc::handleMsgMidi()"); + CARLA_ASSERT(kClient != nullptr); CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(1, "m"); - if (! client) + if (kClient == nullptr) return 1; - const uint8_t* const mdata = argv[0]->m; - const uint8_t data[4] = { mdata[0], mdata[1], mdata[2], mdata[3] }; - + const uint8_t* const data = argv[0]->m; uint8_t status = data[1]; uint8_t channel = status & 0x0F; @@ -358,14 +336,27 @@ int CarlaBridgeOsc::handleMsgMidi(CARLA_BRIDGE_OSC_HANDLE_ARGS) { const uint8_t note = data[2]; - client->noteOff(channel, note); + CARLA_SAFE_ASSERT_INT(note < MAX_MIDI_NOTE, note); + + if (note >= MAX_MIDI_NOTE) + return 1; + + kClient->noteOff(channel, note); } else if (MIDI_IS_STATUS_NOTE_ON(status)) { const uint8_t note = data[2]; const uint8_t velo = data[3]; - client->noteOn(channel, note, velo); + CARLA_SAFE_ASSERT_INT(note < MAX_MIDI_NOTE, note); + CARLA_SAFE_ASSERT_INT(velo < MAX_MIDI_VALUE, velo); + + if (note >= MAX_MIDI_NOTE) + return 1; + if (velo >= MAX_MIDI_VALUE) + return 1; + + kClient->noteOn(channel, note, velo); } return 0; @@ -374,11 +365,12 @@ int CarlaBridgeOsc::handleMsgMidi(CARLA_BRIDGE_OSC_HANDLE_ARGS) int CarlaBridgeOsc::handleMsgShow() { carla_debug("CarlaBridgeOsc::handleMsgShow()"); + CARLA_ASSERT(kClient != nullptr); - if (! client) + if (kClient == nullptr) return 1; - client->toolkitShow(); + kClient->toolkitShow(); return 0; } @@ -386,11 +378,12 @@ int CarlaBridgeOsc::handleMsgShow() int CarlaBridgeOsc::handleMsgHide() { carla_debug("CarlaBridgeOsc::handleMsgHide()"); + CARLA_ASSERT(kClient != nullptr); - if (! client) + if (kClient == nullptr) return 1; - client->toolkitHide(); + kClient->toolkitHide(); return 0; } @@ -398,11 +391,12 @@ int CarlaBridgeOsc::handleMsgHide() int CarlaBridgeOsc::handleMsgQuit() { carla_debug("CarlaBridgeOsc::handleMsgQuit()"); + CARLA_ASSERT(kClient != nullptr); - if (! client) + if (kClient == nullptr) return 1; - client->toolkitQuit(); + kClient->toolkitQuit(); return 0; } diff --git a/source/bridges/CarlaBridgeOsc.hpp b/source/bridges/CarlaBridgeOsc.hpp index 621b77d27..d8004e7ea 100644 --- a/source/bridges/CarlaBridgeOsc.hpp +++ b/source/bridges/CarlaBridgeOsc.hpp @@ -18,8 +18,9 @@ #ifndef __CARLA_BRIDGE_OSC_HPP__ #define __CARLA_BRIDGE_OSC_HPP__ -#include "carla_bridge.hpp" +#include "CarlaBridge.hpp" #include "CarlaOscUtils.hpp" +#include "CarlaString.hpp" #define CARLA_BRIDGE_OSC_HANDLE_ARGS const int argc, const lo_arg* const* const argv, const char* const types @@ -58,7 +59,7 @@ public: CarlaBridgeOsc(CarlaBridgeClient* const client); ~CarlaBridgeOsc(); - bool init(const char* const url); + void init(const char* const url); void idle(); void close(); @@ -66,31 +67,30 @@ public: bool isControlRegistered() const { - return bool(m_controlData.target); + return (fControlData.target != nullptr); } const CarlaOscData* getControlData() const { - return &m_controlData; + return &fControlData; } const char* getServerPath() const { - return m_serverPath; + return (const char*)fServerPath; } // ------------------------------------------------------------------- private: - CarlaBridgeClient* const client; + CarlaBridgeClient* const kClient; - char* m_name; - size_t m_nameSize; + CarlaString fName; - lo_server m_server; - char* m_serverPath; + CarlaString fServerPath; + lo_server fServer; - CarlaOscData m_controlData; + CarlaOscData fControlData; // ------------------------------------------------------------------- @@ -118,14 +118,14 @@ private: // ------------------------------------------------------------------- - static void osc_error_handler(const int num, const char* const msg, const char* const path) + static void osc_error_handler(int num, const char* msg, const char* path) { carla_stderr("CarlaBridgeOsc::osc_error_handler(%i, \"%s\", \"%s\")", num, msg, path); } - static int osc_message_handler(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg, void* const user_data) + static int osc_message_handler(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg, void* userData) { - return ((CarlaBridgeOsc*)user_data)->handleMessage(path, argc, argv, types, msg); + return ((CarlaBridgeOsc*)userData)->handleMessage(path, argc, argv, types, msg); } }; diff --git a/source/bridges/CarlaBridgeToolkit.hpp b/source/bridges/CarlaBridgeToolkit.hpp index 882aea54b..28a8c2d15 100644 --- a/source/bridges/CarlaBridgeToolkit.hpp +++ b/source/bridges/CarlaBridgeToolkit.hpp @@ -18,7 +18,7 @@ #ifndef __CARLA_BRIDGE_TOOLKIT_HPP__ #define __CARLA_BRIDGE_TOOLKIT_HPP__ -#include "carla_bridge.hpp" +#include "CarlaBridge.hpp" CARLA_BRIDGE_START_NAMESPACE @@ -52,8 +52,8 @@ public: static CarlaBridgeToolkit* createNew(CarlaBridgeClient* const client, const char* const uiTitle); protected: - CarlaBridgeClient* const client; - char* uiTitle; + CarlaBridgeClient* const kClient; + char* fUiTitle; }; /**@}*/ diff --git a/source/bridges/CarlaBridgeToolkit-gtk.cpp b/source/bridges/CarlaBridgeToolkitGtk.cpp similarity index 100% rename from source/bridges/CarlaBridgeToolkit-gtk.cpp rename to source/bridges/CarlaBridgeToolkitGtk.cpp diff --git a/source/bridges/CarlaBridgeToolkit-plugin.cpp b/source/bridges/CarlaBridgeToolkitPlugin.cpp similarity index 100% rename from source/bridges/CarlaBridgeToolkit-plugin.cpp rename to source/bridges/CarlaBridgeToolkitPlugin.cpp diff --git a/source/bridges/CarlaBridgeToolkit-qt.cpp b/source/bridges/CarlaBridgeToolkitQt.cpp similarity index 100% rename from source/bridges/CarlaBridgeToolkit-qt.cpp rename to source/bridges/CarlaBridgeToolkitQt.cpp diff --git a/source/bridges/qtcreator/carla-bridge-plugin.pro b/source/bridges/qtcreator/carla-bridge-plugin.pro index b72565228..b174904df 100644 --- a/source/bridges/qtcreator/carla-bridge-plugin.pro +++ b/source/bridges/qtcreator/carla-bridge-plugin.pro @@ -12,87 +12,87 @@ VERSION = 0.5.0 # ----------------------------------------------------------- SOURCES = \ - ../carla_bridge_client.cpp \ - ../carla_bridge_osc.cpp \ - ../carla_bridge_toolkit.cpp \ - ../carla_bridge_plugin.cpp +# ../CarlaBridgeClient.cpp \ + ../CarlaBridgeOsc.cpp +# ../CarlaBridgeToolkit.cpp \ +# ../CarlaBridgePlugin.cpp HEADERS = \ - ../carla_bridge.hpp \ - ../carla_bridge_client.hpp \ - ../carla_bridge_osc.hpp \ - ../carla_bridge_toolkit.hpp + ../CarlaBridge.hpp \ + ../CarlaBridgeClient.hpp \ + ../CarlaBridgeOsc.hpp \ + ../CarlaBridgeToolkit.hpp # ----------------------------------------------------------- # carla-engine SOURCES += \ - ../../backend/engine/carla_engine.cpp \ - ../../backend/engine/carla_engine_osc.cpp \ - ../../backend/engine/carla_engine_thread.cpp \ - ../../backend/engine/jack.cpp \ - ../../backend/engine/plugin.cpp \ - ../../backend/engine/rtaudio.cpp + ../../backend/engine/CarlaEngine.cpp \ + ../../backend/engine/CarlaEngineOsc.cpp \ + ../../backend/engine/CarlaEngineThread.cpp \ + ../../backend/engine/CarlaEngineJack.cpp \ + ../../backend/engine/CarlaEnginePlugin.cpp \ + ../../backend/engine/CarlaEngineRtAudio.cpp # carla-plugin SOURCES += \ - ../../backend/plugin/carla_plugin.cpp \ - ../../backend/plugin/carla_plugin_thread.cpp \ - ../../backend/plugin/native.cpp \ - ../../backend/plugin/ladspa.cpp \ - ../../backend/plugin/dssi.cpp \ - ../../backend/plugin/lv2.cpp \ - ../../backend/plugin/vst.cpp \ - ../../backend/plugin/fluidsynth.cpp \ - ../../backend/plugin/linuxsampler.cpp + ../../backend/plugin/CarlaPlugin.cpp \ + ../../backend/plugin/CarlaPluginThread.cpp \ + ../../backend/plugin/NativePlugin.cpp \ + ../../backend/plugin/LadspaPlugin.cpp \ + ../../backend/plugin/DssiPlugin.cpp \ + ../../backend/plugin/Lv2Plugin.cpp \ + ../../backend/plugin/VstPlugin.cpp \ + ../../backend/plugin/FluidSynthPlugin.cpp \ + ../../backend/plugin/LinuxSamplerPlugin.cpp # carla-standalone SOURCES += \ - ../../backend/standalone/carla_standalone.cpp + ../../backend/standalone/CarlaStandalone.cpp # ----------------------------------------------------------- # common HEADERS += \ - ../../backend/carla_backend.hpp \ - ../../backend/carla_engine.hpp \ - ../../backend/carla_native.h \ - ../../backend/carla_native.hpp \ - ../../backend/carla_plugin.hpp \ - ../../backend/carla_standalone.hpp + ../../CarlaBackend.hpp \ + ../../CarlaEngine.hpp \ + ../../CarlaNative.h \ + ../../CarlaNative.hpp \ + ../../CarlaPlugin.hpp \ + ../../CarlaStandalone.hpp # engine HEADERS += \ - ../../backend/engine/carla_engine_internal.hpp \ - ../../backend/engine/carla_engine_osc.hpp \ - ../../backend/engine/carla_engine_thread.hpp \ - ../../backend/engine/plugin/DistrhoPluginInfo.h + ../../backend/engine/CarlaEngineInternal.hpp \ + ../../backend/engine/CarlaEngineOsc.hpp \ + ../../backend/engine/CarlaEngineThread.hpp \ + ../../backend/engine/distrho/DistrhoPluginInfo.h # plugin HEADERS += \ - ../../backend/plugin/carla_plugin_internal.hpp \ - ../../backend/plugin/carla_plugin_thread.hpp + ../../backend/plugin/CarlaPluginInternal.hpp \ + ../../backend/plugin/CarlaPluginThread.hpp # includes HEADERS += \ - ../../includes/carla_defines.hpp \ - ../../includes/carla_midi.h \ + ../../includes/CarlaDefines.hpp \ + ../../includes/CarlaMIDI.h \ ../../includes/ladspa_rdf.hpp \ ../../includes/lv2_rdf.hpp # utils HEADERS += \ - ../../utils/carla_backend_utils.hpp \ - ../../utils/carla_juce_utils.hpp \ - ../../utils/carla_ladspa_utils.hpp \ - ../../utils/carla_lib_utils.hpp \ - ../../utils/carla_lv2_utils.hpp \ - ../../utils/carla_osc_utils.hpp \ - ../../utils/carla_state_utils.hpp \ - ../../utils/carla_vst_utils.hpp \ - ../../utils/carla_utils.hpp \ + ../../utils/CarlaBackendUtils.hpp \ + ../../utils/CarlaJuceUtils.hpp \ + ../../utils/CarlaLadspaUtils.hpp \ + ../../utils/CarlaLibUtils.hpp \ + ../../utils/CarlaLv2Utils.hpp \ + ../../utils/CarlaOscUtils.hpp \ + ../../utils/CarlaStateUtils.hpp \ + ../../utils/CarlaVstUtils.hpp \ + ../../utils/CarlaUtils.hpp \ ../../utils/lv2_atom_queue.hpp \ - ../../utils/rt_list.hpp + ../../utils/RtList.hpp INCLUDEPATH = .. \ ../../backend \ @@ -111,8 +111,8 @@ DEFINES += DEBUG DEFINES += BUILD_BRIDGE BUILD_BRIDGE_PLUGIN BRIDGE_PLUGIN DEFINES += WANT_JACK -DEFINES += WANT_LADSPA -# WANT_DSSI WANT_LV2 WANT_VST +DEFINES += WANT_LADSPA WANT_DSSI +# WANT_LV2 WANT_VST LIBS = -ldl \ ../../libs/lilv.a \ diff --git a/source/libs/Makefile b/source/libs/Makefile index 5fde88858..7aa11d6e1 100644 --- a/source/libs/Makefile +++ b/source/libs/Makefile @@ -25,34 +25,16 @@ jackbridge-win64.dll.so: lilv.a: $(MAKE) -C lilv -lilv_posix32.a: - $(MAKE) -C lilv posix32 - -lilv_posix64.a: - $(MAKE) -C lilv posix64 - -lilv_win32.a: - $(MAKE) -C lilv win32 - -lilv_win64.a: - $(MAKE) -C lilv win64 +lilv_%.a: + $(MAKE) -C lilv $* # -------------------------------------------------------------- rtmempool.a: $(MAKE) -C rtmempool -rtmempool_posix32.a: - $(MAKE) -C rtmempool posix32 - -rtmempool_posix64.a: - $(MAKE) -C rtmempool posix64 - -rtmempool_win32.a: - $(MAKE) -C rtmempool win32 - -rtmempool_win64.a: - $(MAKE) -C rtmempool win64 +rtmempool_%.a: + $(MAKE) -C rtmempool $* # -------------------------------------------------------------- diff --git a/source/utils/CarlaOscUtils.hpp b/source/utils/CarlaOscUtils.hpp index a0f0a49e3..33c952b6f 100644 --- a/source/utils/CarlaOscUtils.hpp +++ b/source/utils/CarlaOscUtils.hpp @@ -141,7 +141,7 @@ void osc_send_midi_program(const CarlaOscData* const oscData, const int32_t inde { char targetPath[strlen(oscData->path)+14]; strcpy(targetPath, oscData->path); - strcat(targetPath, "/midi_program"); + strcat(targetPath, "/midi-program"); lo_send(oscData->target, targetPath, "i", index); } } @@ -158,7 +158,7 @@ void osc_send_midi_program(const CarlaOscData* const oscData, const int32_t bank { char targetPath[strlen(oscData->path)+14]; strcpy(targetPath, oscData->path); - strcat(targetPath, "/midi_program"); + strcat(targetPath, "/midi-program"); lo_send(oscData->target, targetPath, "ii", bank, program); } }