| @@ -983,11 +983,6 @@ public: | |||||
| bool isOscControlRegistered() const noexcept; | bool isOscControlRegistered() const noexcept; | ||||
| #endif | #endif | ||||
| /*! | |||||
| * Idle OSC. | |||||
| */ | |||||
| void idleOsc() const noexcept; | |||||
| /*! | /*! | ||||
| * Get OSC TCP server path. | * Get OSC TCP server path. | ||||
| */ | */ | ||||
| @@ -1601,7 +1601,6 @@ float CarlaEngine::getOutputPeak(const unsigned int pluginId, const bool isLeft) | |||||
| void CarlaEngine::callback(const EngineCallbackOpcode action, const unsigned int pluginId, const int value1, const int value2, const float value3, const char* const valueStr) noexcept | void CarlaEngine::callback(const EngineCallbackOpcode action, const unsigned int pluginId, const int value1, const int value2, const float value3, const char* const valueStr) noexcept | ||||
| { | { | ||||
| carla_debug("CarlaEngine::callback(%s, %i, %i, %i, %f, \"%s\")", EngineCallbackOpcode2Str(action), pluginId, value1, value2, value3, valueStr); | carla_debug("CarlaEngine::callback(%s, %i, %i, %i, %f, \"%s\")", EngineCallbackOpcode2Str(action), pluginId, value1, value2, value3, valueStr); | ||||
| CARLA_ENGINE_THREAD_SAFE_SECTION | |||||
| if (pData->callback != nullptr) | if (pData->callback != nullptr) | ||||
| { | { | ||||
| @@ -2013,13 +2012,6 @@ bool CarlaEngine::isOscControlRegistered() const noexcept | |||||
| } | } | ||||
| #endif | #endif | ||||
| void CarlaEngine::idleOsc() const noexcept | |||||
| { | |||||
| try { | |||||
| pData->osc.idle(); | |||||
| } catch(...) {} | |||||
| } | |||||
| const char* CarlaEngine::getOscServerPathTCP() const noexcept | const char* CarlaEngine::getOscServerPathTCP() const noexcept | ||||
| { | { | ||||
| return pData->osc.getServerPathTCP(); | return pData->osc.getServerPathTCP(); | ||||
| @@ -71,32 +71,34 @@ void CarlaEngineOsc::init(const char* const name) | |||||
| fName = name; | fName = name; | ||||
| fName.toBasic(); | fName.toBasic(); | ||||
| fServerTCP = lo_server_new_with_proto(nullptr, LO_TCP, osc_error_handler_TCP); | |||||
| fServerTCP = lo_server_thread_new_with_proto(nullptr, LO_TCP, osc_error_handler_TCP); | |||||
| if (fServerTCP != nullptr) | if (fServerTCP != nullptr) | ||||
| { | { | ||||
| if (char* const tmpServerPathTCP = lo_server_get_url(fServerTCP)) | |||||
| if (char* const tmpServerPathTCP = lo_server_thread_get_url(fServerTCP)) | |||||
| { | { | ||||
| fServerPathTCP = tmpServerPathTCP; | fServerPathTCP = tmpServerPathTCP; | ||||
| fServerPathTCP += fName; | fServerPathTCP += fName; | ||||
| std::free(tmpServerPathTCP); | std::free(tmpServerPathTCP); | ||||
| } | } | ||||
| lo_server_add_method(fServerTCP, nullptr, nullptr, osc_message_handler_TCP, this); | |||||
| lo_server_thread_add_method(fServerTCP, nullptr, nullptr, osc_message_handler_TCP, this); | |||||
| lo_server_thread_start(fServerTCP); | |||||
| } | } | ||||
| fServerUDP = lo_server_new_with_proto(nullptr, LO_UDP, osc_error_handler_UDP); | |||||
| fServerUDP = lo_server_thread_new_with_proto(nullptr, LO_UDP, osc_error_handler_UDP); | |||||
| if (fServerUDP != nullptr) | if (fServerUDP != nullptr) | ||||
| { | { | ||||
| if (char* const tmpServerPathUDP = lo_server_get_url(fServerUDP)) | |||||
| if (char* const tmpServerPathUDP = lo_server_thread_get_url(fServerUDP)) | |||||
| { | { | ||||
| fServerPathUDP = tmpServerPathUDP; | fServerPathUDP = tmpServerPathUDP; | ||||
| fServerPathUDP += fName; | fServerPathUDP += fName; | ||||
| std::free(tmpServerPathUDP); | std::free(tmpServerPathUDP); | ||||
| } | } | ||||
| lo_server_add_method(fServerUDP, nullptr, nullptr, osc_message_handler_UDP, this); | |||||
| lo_server_thread_add_method(fServerUDP, nullptr, nullptr, osc_message_handler_UDP, this); | |||||
| lo_server_thread_start(fServerUDP); | |||||
| } | } | ||||
| CARLA_ASSERT(fName.isNotEmpty()); | CARLA_ASSERT(fName.isNotEmpty()); | ||||
| @@ -106,19 +108,6 @@ void CarlaEngineOsc::init(const char* const name) | |||||
| CARLA_SAFE_ASSERT(fServerUDP != nullptr); | CARLA_SAFE_ASSERT(fServerUDP != nullptr); | ||||
| } | } | ||||
| void CarlaEngineOsc::idle() const | |||||
| { | |||||
| if (fServerTCP != nullptr) | |||||
| { | |||||
| while (lo_server_recv_noblock(fServerTCP, 0) != 0) {} | |||||
| } | |||||
| if (fServerUDP != nullptr) | |||||
| { | |||||
| while (lo_server_recv_noblock(fServerUDP, 0) != 0) {} | |||||
| } | |||||
| } | |||||
| void CarlaEngineOsc::close() | void CarlaEngineOsc::close() | ||||
| { | { | ||||
| CARLA_ASSERT(fName.isNotEmpty()); | CARLA_ASSERT(fName.isNotEmpty()); | ||||
| @@ -132,15 +121,17 @@ void CarlaEngineOsc::close() | |||||
| if (fServerTCP != nullptr) | if (fServerTCP != nullptr) | ||||
| { | { | ||||
| lo_server_del_method(fServerTCP, nullptr, nullptr); | |||||
| lo_server_free(fServerTCP); | |||||
| lo_server_thread_stop(fServerTCP); | |||||
| lo_server_thread_del_method(fServerTCP, nullptr, nullptr); | |||||
| lo_server_thread_free(fServerTCP); | |||||
| fServerTCP = nullptr; | fServerTCP = nullptr; | ||||
| } | } | ||||
| if (fServerUDP != nullptr) | if (fServerUDP != nullptr) | ||||
| { | { | ||||
| lo_server_del_method(fServerUDP, nullptr, nullptr); | |||||
| lo_server_free(fServerUDP); | |||||
| lo_server_thread_stop(fServerUDP); | |||||
| lo_server_thread_del_method(fServerUDP, nullptr, nullptr); | |||||
| lo_server_thread_free(fServerUDP); | |||||
| fServerUDP = nullptr; | fServerUDP = nullptr; | ||||
| } | } | ||||
| @@ -165,6 +156,7 @@ int CarlaEngineOsc::handleMessage(const bool isTCP, const char* const path, cons | |||||
| CARLA_SAFE_ASSERT_RETURN(fName.isNotEmpty(), 1); | CARLA_SAFE_ASSERT_RETURN(fName.isNotEmpty(), 1); | ||||
| CARLA_SAFE_ASSERT_RETURN(path != nullptr && path[0] != '\0', 1); | CARLA_SAFE_ASSERT_RETURN(path != nullptr && path[0] != '\0', 1); | ||||
| carla_debug("CarlaEngineOsc::handleMessage(%s, \"%s\", %i, %p, \"%s\", %p)", bool2str(isTCP), path, argc, argv, types, msg); | carla_debug("CarlaEngineOsc::handleMessage(%s, \"%s\", %i, %p, \"%s\", %p)", bool2str(isTCP), path, argc, argv, types, msg); | ||||
| const CarlaCriticalSection::Scope _ccsl(_cs); | |||||
| if (isTCP) | if (isTCP) | ||||
| { | { | ||||
| @@ -20,6 +20,7 @@ | |||||
| #include "CarlaBackend.h" | #include "CarlaBackend.h" | ||||
| #include "CarlaOscUtils.hpp" | #include "CarlaOscUtils.hpp" | ||||
| #include "CarlaMutex.hpp" | |||||
| #include "CarlaString.hpp" | #include "CarlaString.hpp" | ||||
| #define CARLA_ENGINE_OSC_HANDLE_ARGS1 CarlaPlugin* const plugin | #define CARLA_ENGINE_OSC_HANDLE_ARGS1 CarlaPlugin* const plugin | ||||
| @@ -61,7 +62,6 @@ public: | |||||
| ~CarlaEngineOsc(); | ~CarlaEngineOsc(); | ||||
| void init(const char* const name); | void init(const char* const name); | ||||
| void idle() const; | |||||
| void close(); | void close(); | ||||
| // ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
| @@ -99,8 +99,10 @@ private: | |||||
| CarlaString fServerPathTCP; | CarlaString fServerPathTCP; | ||||
| CarlaString fServerPathUDP; | CarlaString fServerPathUDP; | ||||
| lo_server fServerTCP; | |||||
| lo_server fServerUDP; | |||||
| lo_server_thread fServerTCP; | |||||
| lo_server_thread fServerUDP; | |||||
| CarlaCriticalSection _cs; | |||||
| #ifndef BUILD_BRIDGE | #ifndef BUILD_BRIDGE | ||||
| CarlaOscData fControlData; // for carla-control | CarlaOscData fControlData; // for carla-control | ||||
| @@ -111,8 +111,7 @@ void CarlaEngineThread::run() | |||||
| } | } | ||||
| } | } | ||||
| fEngine->idleOsc(); | |||||
| carla_msleep(oscRegisted ? 30 : 50); | |||||
| carla_msleep(25); | |||||
| } | } | ||||
| } | } | ||||
| @@ -8,7 +8,7 @@ include ../Makefile.mk | |||||
| # ---------------------------------------------------------------------------------------------------------------------------- | # ---------------------------------------------------------------------------------------------------------------------------- | ||||
| CARLA_ENGINE_OSC_HPP = CarlaEngineOsc.hpp $(CARLA_BACKEND_H) $(CARLA_OSC_UTILS_HPP) $(CARLA_STRING_HPP) | |||||
| CARLA_ENGINE_OSC_HPP = CarlaEngineOsc.hpp $(CARLA_BACKEND_H) $(CARLA_OSC_UTILS_HPP) $(CARLA_MUTEX_HPP) $(CARLA_STRING_HPP) | |||||
| CARLA_ENGINE_THREAD_HPP = CarlaEngineThread.hpp $(CARLA_BACKEND_H) $(CARLA_THREAD_HPP) | CARLA_ENGINE_THREAD_HPP = CarlaEngineThread.hpp $(CARLA_BACKEND_H) $(CARLA_THREAD_HPP) | ||||
| CARLA_ENGINE_INTERNAL_HPP = CarlaEngineInternal.hpp $(CARLA_ENGINE_OSC_HPP) $(CARLA_ENGINE_THREAD_HPP) $(CARLA_ENGINE_HPP) $(CARLA_MUTEX_HPP) $(LINKED_LIST_HPP) | CARLA_ENGINE_INTERNAL_HPP = CarlaEngineInternal.hpp $(CARLA_ENGINE_OSC_HPP) $(CARLA_ENGINE_THREAD_HPP) $(CARLA_ENGINE_HPP) $(CARLA_MUTEX_HPP) $(LINKED_LIST_HPP) | ||||