| @@ -432,8 +432,8 @@ void CarlaEngineJack::handleProcessCallback(uint32_t nframes) | |||
| } | |||
| // initialize outputs (zero) | |||
| memset(aouts_tmp_buf1, 0, sizeof(float)*nframes); | |||
| memset(aouts_tmp_buf2, 0, sizeof(float)*nframes); | |||
| zeroF(aouts_tmp_buf1, nframes); | |||
| zeroF(aouts_tmp_buf2, nframes); | |||
| memset(rackControlEventsOut, 0, sizeof(CarlaEngineControlEvent)*MAX_ENGINE_CONTROL_EVENTS); | |||
| memset(rackMidiEventsOut, 0, sizeof(CarlaEngineMidiEvent)*MAX_ENGINE_MIDI_EVENTS); | |||
| @@ -454,8 +454,8 @@ void CarlaEngineJack::handleProcessCallback(uint32_t nframes) | |||
| memcpy(rackMidiEventsIn, rackMidiEventsOut, sizeof(CarlaEngineMidiEvent)*MAX_ENGINE_MIDI_EVENTS); | |||
| // initialize outputs (zero) | |||
| memset(aouts_tmp_buf1, 0, sizeof(float)*nframes); | |||
| memset(aouts_tmp_buf2, 0, sizeof(float)*nframes); | |||
| zeroF(aouts_tmp_buf1, nframes); | |||
| zeroF(aouts_tmp_buf2, nframes); | |||
| memset(rackMidiEventsOut, 0, sizeof(CarlaEngineMidiEvent)*MAX_ENGINE_MIDI_EVENTS); | |||
| } | |||
| @@ -213,8 +213,8 @@ void CarlaEngineRtAudio::handleProcessCallback(void* outputBuffer, void* inputBu | |||
| } | |||
| // initialize outputs (zero) | |||
| memset(aouts_tmp_buf1, 0, sizeof(float)*nframes); | |||
| memset(aouts_tmp_buf2, 0, sizeof(float)*nframes); | |||
| zeroF(aouts_tmp_buf1, nframes); | |||
| zeroF(aouts_tmp_buf2, nframes); | |||
| memset(rackControlEventsOut, 0, sizeof(CarlaEngineControlEvent)*MAX_ENGINE_CONTROL_EVENTS); | |||
| memset(rackMidiEventsOut, 0, sizeof(CarlaEngineMidiEvent)*MAX_ENGINE_MIDI_EVENTS); | |||
| @@ -235,8 +235,8 @@ void CarlaEngineRtAudio::handleProcessCallback(void* outputBuffer, void* inputBu | |||
| memcpy(rackMidiEventsIn, rackMidiEventsOut, sizeof(CarlaEngineMidiEvent)*MAX_ENGINE_MIDI_EVENTS); | |||
| // initialize outputs (zero) | |||
| memset(aouts_tmp_buf1, 0, sizeof(float)*nframes); | |||
| memset(aouts_tmp_buf2, 0, sizeof(float)*nframes); | |||
| zeroF(aouts_tmp_buf1, nframes); | |||
| zeroF(aouts_tmp_buf2, nframes); | |||
| memset(rackMidiEventsOut, 0, sizeof(CarlaEngineMidiEvent)*MAX_ENGINE_MIDI_EVENTS); | |||
| } | |||
| @@ -1326,7 +1326,7 @@ public: | |||
| { | |||
| // disable any output sound if not active | |||
| for (i=0; i < aOut.count; i++) | |||
| memset(outBuffer[i], 0.0f, sizeof(float)*frames); | |||
| zeroF(outBuffer[i], frames); | |||
| aOutsPeak[0] = 0.0; | |||
| aOutsPeak[1] = 0.0; | |||
| @@ -20,6 +20,11 @@ | |||
| CARLA_BACKEND_START_NAMESPACE | |||
| unsigned int uintMin(unsigned int value1, unsigned int value2) | |||
| { | |||
| return value1 < value2 ? value1 : value2; | |||
| } | |||
| void osc_error_handler(const int num, const char* const msg, const char* const path) | |||
| { | |||
| qCritical("CarlaBackend::osc_error_handler(%i, \"%s\", \"%s\")", num, msg, path); | |||
| @@ -28,8 +33,8 @@ void osc_error_handler(const int num, const char* const msg, const char* const p | |||
| CarlaOsc::CarlaOsc(CarlaEngine* const engine_) | |||
| : engine(engine_) | |||
| { | |||
| CARLA_ASSERT(engine); | |||
| qDebug("CarlaOsc::CarlaOsc(%p)", engine_); | |||
| CARLA_ASSERT(engine); | |||
| m_serverPathTCP = nullptr; | |||
| m_serverPathUDP = nullptr; | |||
| @@ -40,7 +45,7 @@ CarlaOsc::CarlaOsc(CarlaEngine* const engine_) | |||
| m_controlData.target = nullptr; | |||
| m_name = nullptr; | |||
| m_name_len = 0; | |||
| m_nameSize = 0; | |||
| } | |||
| CarlaOsc::~CarlaOsc() | |||
| @@ -50,12 +55,16 @@ CarlaOsc::~CarlaOsc() | |||
| void CarlaOsc::init(const char* const name) | |||
| { | |||
| CARLA_ASSERT(name); | |||
| CARLA_ASSERT(m_name_len == 0); | |||
| qDebug("CarlaOsc::init(\"%s\")", name); | |||
| CARLA_ASSERT(! m_serverPathTCP); | |||
| CARLA_ASSERT(! m_serverPathUDP); | |||
| CARLA_ASSERT(! m_serverThreadUDP); | |||
| CARLA_ASSERT(! m_serverThreadUDP); | |||
| CARLA_ASSERT(name); | |||
| CARLA_ASSERT(m_nameSize == 0); | |||
| m_name = strdup(name); | |||
| m_name_len = strlen(name); | |||
| m_name = strdup(name ? name : ""); | |||
| m_nameSize = strlen(m_name); | |||
| // create new OSC thread | |||
| m_serverThreadTCP = lo_server_thread_new_with_proto(nullptr, LO_TCP, osc_error_handler); | |||
| @@ -63,11 +72,11 @@ void CarlaOsc::init(const char* const name) | |||
| // get our full OSC server path | |||
| char* const threadPathTCP = lo_server_thread_get_url(m_serverThreadTCP); | |||
| m_serverPathTCP = strdup(QString("%1%2").arg(threadPathTCP).arg(name).toUtf8().constData()); | |||
| m_serverPathTCP = strdup(QString("%1%2").arg(threadPathTCP).arg(m_name).toUtf8().constData()); | |||
| free(threadPathTCP); | |||
| char* const threadPathUDP = lo_server_thread_get_url(m_serverThreadUDP); | |||
| m_serverPathUDP = strdup(QString("%1%2").arg(threadPathUDP).arg(name).toUtf8().constData()); | |||
| m_serverPathUDP = strdup(QString("%1%2").arg(threadPathUDP).arg(m_name).toUtf8().constData()); | |||
| free(threadPathUDP); | |||
| // register message handler and start OSC thread | |||
| @@ -79,8 +88,12 @@ void CarlaOsc::init(const char* const name) | |||
| void CarlaOsc::close() | |||
| { | |||
| CARLA_ASSERT(m_name); | |||
| qDebug("CarlaOsc::close()"); | |||
| CARLA_ASSERT(m_serverPathTCP); | |||
| CARLA_ASSERT(m_serverPathUDP); | |||
| CARLA_ASSERT(m_serverThreadUDP); | |||
| CARLA_ASSERT(m_serverThreadUDP); | |||
| CARLA_ASSERT(m_name); | |||
| osc_clear_data(&m_controlData); | |||
| @@ -96,9 +109,9 @@ void CarlaOsc::close() | |||
| m_serverPathTCP = nullptr; | |||
| m_serverPathUDP = nullptr; | |||
| free((void*)m_name); | |||
| free(m_name); | |||
| m_name = nullptr; | |||
| m_name_len = 0; | |||
| m_nameSize = 0; | |||
| } | |||
| // ------------------------------------------------------------------------------------------------------------------- | |||
| @@ -109,10 +122,13 @@ int CarlaOsc::handleMessage(const char* const path, const int argc, const lo_arg | |||
| if (! QString(path).contains("put_peak_value")) | |||
| qDebug("CarlaOsc::handleMessage(%s, %i, %p, %s, %p)", path, argc, argv, types, msg); | |||
| #endif | |||
| CARLA_ASSERT(m_serverThreadTCP || m_serverPathUDP); | |||
| CARLA_ASSERT(m_serverPathTCP || m_serverPathUDP); | |||
| CARLA_ASSERT(m_serverThreadTCP || m_serverThreadUDP); | |||
| CARLA_ASSERT(path); | |||
| if (! path) | |||
| return 1; | |||
| // Initial path check | |||
| if (strcmp(path, "/register") == 0) | |||
| { | |||
| @@ -125,7 +141,7 @@ int CarlaOsc::handleMessage(const char* const path, const int argc, const lo_arg | |||
| } | |||
| // Check if message is for this client | |||
| if (strlen(path) <= m_name_len || strncmp(path+1, m_name, m_name_len) != 0) | |||
| if (strlen(path) <= m_nameSize || strncmp(path+1, m_name, m_nameSize) != 0) | |||
| { | |||
| qWarning("CarlaOsc::handleMessage() - message not for this client -> '%s' != '/%s/'", path, m_name); | |||
| return 1; | |||
| @@ -134,11 +150,11 @@ int CarlaOsc::handleMessage(const char* const path, const int argc, const lo_arg | |||
| // Get plugin id from message | |||
| int pluginId = 0; | |||
| if (std::isdigit(path[m_name_len+2])) | |||
| pluginId += path[m_name_len+2]-'0'; | |||
| if (std::isdigit(path[m_nameSize+2])) | |||
| pluginId += path[m_nameSize+2]-'0'; | |||
| if (std::isdigit(path[m_name_len+3])) | |||
| pluginId += (path[m_name_len+3]-'0')*10; | |||
| if (std::isdigit(path[m_nameSize+3])) | |||
| pluginId += (path[m_nameSize+3]-'0')*10; | |||
| if (pluginId < 0 || pluginId > CarlaEngine::maxPluginNumber()) | |||
| { | |||
| @@ -158,7 +174,10 @@ int CarlaOsc::handleMessage(const char* const path, const int argc, const lo_arg | |||
| // Get method from path, "/Carla/i/method" | |||
| int offset = (pluginId >= 10) ? 4 : 3; | |||
| char method[32] = { 0 }; | |||
| memcpy(method, path + (m_name_len + offset), 32); | |||
| memcpy(method, path + (m_nameSize + offset), uintMin(strlen(path), 32)); | |||
| if (method[0] == 0) | |||
| return 1; | |||
| // Common OSC methods | |||
| if (strcmp(method, "/update") == 0) | |||
| @@ -89,8 +89,8 @@ private: | |||
| lo_server_thread m_serverThreadUDP; | |||
| CarlaOscData m_controlData; // for carla-control | |||
| const char* m_name; | |||
| size_t m_name_len; | |||
| char* m_name; | |||
| size_t m_nameSize; | |||
| // ------------------------------------------------------------------- | |||
| @@ -1019,7 +1019,8 @@ public: | |||
| */ | |||
| void setParameterMidiChannel(const uint32_t parameterId, uint8_t channel, const bool sendOsc, const bool sendCallback) | |||
| { | |||
| CARLA_ASSERT(parameterId < param.count && channel < 16); | |||
| CARLA_ASSERT(parameterId < param.count); | |||
| CARLA_ASSERT(channel < 16); | |||
| if (channel >= 16) | |||
| channel = 16; | |||
| @@ -1043,7 +1044,8 @@ public: | |||
| */ | |||
| void setParameterMidiCC(const uint32_t parameterId, int16_t cc, const bool sendOsc, const bool sendCallback) | |||
| { | |||
| CARLA_ASSERT(parameterId < param.count && cc >= -1); | |||
| CARLA_ASSERT(parameterId < param.count); | |||
| CARLA_ASSERT(cc >= -1); | |||
| if (cc < -1 || cc > 0x5F) | |||
| cc = -1; | |||
| @@ -1542,25 +1544,18 @@ public: | |||
| { | |||
| const char* host; | |||
| const char* port; | |||
| const int proto = lo_address_get_protocol(source); | |||
| osc_clear_data(&osc.data); | |||
| host = lo_address_get_hostname(source); | |||
| port = lo_address_get_port(source); | |||
| if (m_type == PLUGIN_DSSI) | |||
| osc.data.source = lo_address_new_with_proto(LO_UDP, host, port); | |||
| else | |||
| osc.data.source = lo_address_new_with_proto(LO_TCP, host, port); | |||
| osc.data.source = lo_address_new_with_proto(proto, host, port); | |||
| host = lo_url_get_hostname(url); | |||
| port = lo_url_get_port(url); | |||
| osc.data.path = lo_url_get_path(url); | |||
| if (m_type == PLUGIN_DSSI) | |||
| osc.data.target = lo_address_new_with_proto(LO_UDP, host, port); | |||
| else | |||
| osc.data.target = lo_address_new_with_proto(LO_TCP, host, port); | |||
| osc.data.target = lo_address_new_with_proto(proto, host, port); | |||
| free((void*)host); | |||
| free((void*)port); | |||
| @@ -1789,7 +1784,8 @@ public: | |||
| #ifndef BUILD_BRIDGE | |||
| // Update OSC control client | |||
| x_engine->osc_send_control_set_parameter_value(m_id, event->value1, event->value3); | |||
| if (x_engine->isOscControlRegisted()) | |||
| x_engine->osc_send_control_set_parameter_value(m_id, event->value1, event->value3); | |||
| #endif | |||
| // Update Host | |||
| @@ -1803,10 +1799,13 @@ public: | |||
| #ifndef BUILD_BRIDGE | |||
| // Update OSC control client | |||
| x_engine->osc_send_control_set_program(m_id, event->value1); | |||
| if (x_engine->isOscControlRegisted()) | |||
| { | |||
| x_engine->osc_send_control_set_program(m_id, event->value1); | |||
| for (uint32_t j=0; j < param.count; j++) | |||
| x_engine->osc_send_control_set_default_value(m_id, j, param.ranges[j].def); | |||
| for (uint32_t j=0; j < param.count; j++) | |||
| x_engine->osc_send_control_set_default_value(m_id, j, param.ranges[j].def); | |||
| } | |||
| #endif | |||
| // Update Host | |||
| @@ -1820,10 +1819,13 @@ public: | |||
| #ifndef BUILD_BRIDGE | |||
| // Update OSC control client | |||
| x_engine->osc_send_control_set_midi_program(m_id, event->value1); | |||
| if (x_engine->isOscControlRegisted()) | |||
| { | |||
| x_engine->osc_send_control_set_midi_program(m_id, event->value1); | |||
| for (uint32_t j=0; j < param.count; j++) | |||
| x_engine->osc_send_control_set_default_value(m_id, j, param.ranges[j].def); | |||
| for (uint32_t j=0; j < param.count; j++) | |||
| x_engine->osc_send_control_set_default_value(m_id, j, param.ranges[j].def); | |||
| } | |||
| #endif | |||
| // Update Host | |||
| @@ -1836,7 +1838,8 @@ public: | |||
| #ifndef BUILD_BRIDGE | |||
| // Update OSC control client | |||
| x_engine->osc_send_control_note_on(m_id, event->value1, event->value2, rint(event->value3)); | |||
| if (x_engine->isOscControlRegisted()) | |||
| x_engine->osc_send_control_note_on(m_id, event->value1, event->value2, rint(event->value3)); | |||
| #endif | |||
| // Update Host | |||
| @@ -1849,7 +1852,8 @@ public: | |||
| #ifndef BUILD_BRIDGE | |||
| // Update OSC control client | |||
| x_engine->osc_send_control_note_off(m_id, event->value1, event->value2); | |||
| if (x_engine->isOscControlRegisted()) | |||
| x_engine->osc_send_control_note_off(m_id, event->value1, event->value2); | |||
| #endif | |||
| // Update Host | |||
| @@ -1972,19 +1976,17 @@ public: | |||
| } | |||
| /*! | |||
| * Initializes all RT buffers of the plugin. | |||
| * Initialize all RT buffers of the plugin. | |||
| */ | |||
| virtual void initBuffers() | |||
| { | |||
| uint32_t i; | |||
| for (i=0; i < aIn.count; i++) | |||
| for (uint32_t i=0; i < aIn.count; i++) | |||
| { | |||
| if (aIn.ports[i]) | |||
| aIn.ports[i]->initBuffer(x_engine); | |||
| } | |||
| for (i=0; i < aOut.count; i++) | |||
| for (uint32_t i=0; i < aOut.count; i++) | |||
| { | |||
| if (aOut.ports[i]) | |||
| aOut.ports[i]->initBuffer(x_engine); | |||
| @@ -2136,7 +2138,7 @@ public: | |||
| // ------------------------------------------------------------------- | |||
| /*! | |||
| * \class CarlaPluginScopedDisabler | |||
| * \class ScopedDisabler | |||
| * | |||
| * \brief Carla plugin scoped disabler | |||
| * | |||
| @@ -2144,7 +2146,7 @@ public: | |||
| * It should be used when the plugin needs reload or state change, something like this: | |||
| * \code | |||
| * { | |||
| * const CarlaPluginScopedDisabler m(plugin); | |||
| * const CarlaPlugin::ScopedDisabler m(plugin); | |||
| * plugin->setChunkData(data); | |||
| * } | |||
| * \endcode | |||
| @@ -1305,7 +1305,7 @@ public: | |||
| { | |||
| // disable any output sound if not active | |||
| for (i=0; i < aOut.count; i++) | |||
| memset(outBuffer[i], 0.0f, sizeof(float)*frames); | |||
| zeroF(outBuffer[i], frames); | |||
| aOutsPeak[0] = 0.0; | |||
| aOutsPeak[1] = 0.0; | |||
| @@ -1193,7 +1193,7 @@ public: | |||
| { | |||
| // disable any output sound if not active | |||
| for (i=0; i < aOut.count; i++) | |||
| memset(outBuffer[i], 0.0f, sizeof(float)*frames); | |||
| zeroF(outBuffer[i], frames); | |||
| aOutsPeak[0] = 0.0; | |||
| aOutsPeak[1] = 0.0; | |||
| @@ -981,7 +981,7 @@ public: | |||
| { | |||
| // disable any output sound if not active | |||
| for (i=0; i < aOut.count; i++) | |||
| memset(outBuffer[i], 0.0f, sizeof(float)*frames); | |||
| zeroF(outBuffer[i], frames); | |||
| aOutsPeak[0] = 0.0; | |||
| aOutsPeak[1] = 0.0; | |||
| @@ -657,7 +657,7 @@ public: | |||
| { | |||
| // disable any output sound if not active | |||
| for (i=0; i < aOut.count; i++) | |||
| memset(outBuffer[i], 0.0f, sizeof(float)*frames); | |||
| zeroF(outBuffer[i], frames); | |||
| aOutsPeak[0] = 0.0; | |||
| aOutsPeak[1] = 0.0; | |||
| @@ -2577,7 +2577,7 @@ public: | |||
| { | |||
| // disable any output sound if not active | |||
| for (i=0; i < aOut.count; i++) | |||
| memset(outBuffer[i], 0.0f, sizeof(float)*frames); | |||
| zeroF(outBuffer[i], frames); | |||
| aOutsPeak[0] = 0.0; | |||
| aOutsPeak[1] = 0.0; | |||
| @@ -1198,7 +1198,7 @@ public: | |||
| else | |||
| { | |||
| for (i=0; i < aOut.count; i++) | |||
| memset(outBuffer[i], 0, sizeof(float)*frames); | |||
| zeroF(outBuffer[i], frames); | |||
| #if ! VST_FORCE_DEPRECATED | |||
| isProcessing = true; | |||
| @@ -1290,7 +1290,7 @@ public: | |||
| { | |||
| // disable any output sound if not active | |||
| for (i=0; i < aOut.count; i++) | |||
| memset(outBuffer[i], 0.0f, sizeof(float)*frames); | |||
| zeroF(outBuffer[i], frames); | |||
| aOutsPeak[0] = 0.0; | |||
| aOutsPeak[1] = 0.0; | |||
| @@ -139,4 +139,11 @@ const char* bool2str(const bool yesNo) | |||
| static inline | |||
| void pass() {} | |||
| static inline | |||
| void zeroF(float* data, const unsigned int size) | |||
| { | |||
| for (unsigned int i=0; i < size; i++) | |||
| *data++ = 0.0f; | |||
| } | |||
| #endif // CARLA_INCLUDES_H | |||