diff --git a/source/backend/CarlaUtils.h b/source/backend/CarlaUtils.h index e3c89ed09..8d76ca2bb 100644 --- a/source/backend/CarlaUtils.h +++ b/source/backend/CarlaUtils.h @@ -193,7 +193,7 @@ CARLA_EXPORT CarlaPipeClientHandle carla_pipe_client_new(const char* argv[], Car /*! * TODO. */ -CARLA_EXPORT void carla_pipe_client_idle(CarlaPipeClientHandle handle); +CARLA_EXPORT const char* carla_pipe_client_idle(CarlaPipeClientHandle handle); /*! * TODO. diff --git a/source/backend/utils/PipeClient.cpp b/source/backend/utils/PipeClient.cpp index 3bd5a8a79..4d0f56ad3 100644 --- a/source/backend/utils/PipeClient.cpp +++ b/source/backend/utils/PipeClient.cpp @@ -1,6 +1,6 @@ /* * Carla Plugin Host - * Copyright (C) 2011-2018 Filipe Coelho + * Copyright (C) 2011-2019 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -19,6 +19,11 @@ #include "CarlaPipeUtils.hpp" +#ifdef CARLA_OS_HAIKU +# include "CarlaStringList.hpp" +# define CARLA_PIPE_WITHOUT_CALLBACK +#endif + namespace CB = CarlaBackend; // ------------------------------------------------------------------------------------------------------------------- @@ -30,6 +35,10 @@ public: : CarlaPipeClient(), fCallbackFunc(callbackFunc), fCallbackPtr(callbackPtr), +#ifdef CARLA_PIPE_WITHOUT_CALLBACK + fMsgsReceived(), + fLastMsgReceived(nullptr), +#endif fLastReadLine(nullptr) { CARLA_SAFE_ASSERT(fCallbackFunc != nullptr); @@ -42,10 +51,42 @@ public: delete[] fLastReadLine; fLastReadLine = nullptr; } +#ifdef CARLA_PIPE_WITHOUT_CALLBACK + if (fLastMsgReceived != nullptr) + { + delete[] fLastMsgReceived; + fLastMsgReceived = nullptr; + } +#endif + } + + const char* idlePipeAndReturnMessage() + { + CarlaPipeClient::idlePipe(); + +#ifdef CARLA_PIPE_WITHOUT_CALLBACK + if (fMsgsReceived.count() == 0) + return nullptr; + + delete[] fLastMsgReceived; + fLastMsgReceived = fMsgsReceived.getAndRemoveFirst(); + return fLastMsgReceived; +#else + return nullptr; +#endif } const char* readlineblock(const uint timeout) noexcept { +#ifdef CARLA_PIPE_WITHOUT_CALLBACK + if (fMsgsReceived.count() != 0) + { + delete[] fLastMsgReceived; + fLastMsgReceived = fMsgsReceived.getAndRemoveFirst(); + return fLastMsgReceived; + } +#endif + delete[] fLastReadLine; fLastReadLine = CarlaPipeClient::_readlineblock(timeout); return fLastReadLine; @@ -53,12 +94,16 @@ public: bool msgReceived(const char* const msg) noexcept override { +#ifdef CARLA_PIPE_WITHOUT_CALLBACK + fMsgsReceived.append(msg); +#else if (fCallbackFunc != nullptr) { try { fCallbackFunc(fCallbackPtr, msg); } CARLA_SAFE_EXCEPTION("msgReceived"); } +#endif return true; } @@ -66,6 +111,10 @@ public: private: const CarlaPipeCallbackFunc fCallbackFunc; void* const fCallbackPtr; +#ifdef CARLA_PIPE_WITHOUT_CALLBACK + CarlaStringList fMsgsReceived; + const char* fLastMsgReceived; +#endif const char* fLastReadLine; CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ExposedCarlaPipeClient) @@ -86,11 +135,11 @@ CarlaPipeClientHandle carla_pipe_client_new(const char* argv[], CarlaPipeCallbac return pipe; } -void carla_pipe_client_idle(CarlaPipeClientHandle handle) +const char* carla_pipe_client_idle(CarlaPipeClientHandle handle) { - CARLA_SAFE_ASSERT_RETURN(handle != nullptr,); + CARLA_SAFE_ASSERT_RETURN(handle != nullptr, nullptr); - ((ExposedCarlaPipeClient*)handle)->idlePipe(); + return ((ExposedCarlaPipeClient*)handle)->idlePipeAndReturnMessage(); } bool carla_pipe_client_is_running(CarlaPipeClientHandle handle) diff --git a/source/frontend/carla_database.py b/source/frontend/carla_database.py index faef1ae82..c11ff4673 100755 --- a/source/frontend/carla_database.py +++ b/source/frontend/carla_database.py @@ -68,13 +68,15 @@ if haveLRDF and readEnvVars: # --------------------------------------------------------------------------------------------------------------------- # Plugin Query (helper functions) -def findBinaries(binPath, OS): +def findBinaries(binPath, pluginType, OS): binaries = [] - if OS == "WINDOWS": - extensions = (".dll",) + if OS == "HAIKU": + extensions = ("") if pluginType == PLUGIN_VST2 else (".so",) elif OS == "MACOS": extensions = (".dylib", ".so") + elif OS == "WINDOWS": + extensions = (".dll",) else: extensions = (".so",) @@ -715,7 +717,7 @@ class SearchPluginsThread(QThread): del settings for iPATH in LADSPA_PATH: - binaries = findBinaries(iPATH, OS) + binaries = findBinaries(iPATH, PLUGIN_LADSPA, OS) for binary in binaries: if binary not in ladspaBinaries: ladspaBinaries.append(binary) @@ -751,7 +753,7 @@ class SearchPluginsThread(QThread): del settings for iPATH in DSSI_PATH: - binaries = findBinaries(iPATH, OS) + binaries = findBinaries(iPATH, PLUGIN_DSSI, OS) for binary in binaries: if binary not in dssiBinaries: dssiBinaries.append(binary) @@ -793,7 +795,7 @@ class SearchPluginsThread(QThread): if MACOS and not isWine: binaries = findMacVSTBundles(iPATH, False) else: - binaries = findBinaries(iPATH, OS) + binaries = findBinaries(iPATH, PLUGIN_VST2, OS) for binary in binaries: if binary not in vst2Binaries: vst2Binaries.append(binary) diff --git a/source/frontend/carla_shared.py b/source/frontend/carla_shared.py index 2b9c90b89..3041a146f 100644 --- a/source/frontend/carla_shared.py +++ b/source/frontend/carla_shared.py @@ -393,19 +393,21 @@ elif HAIKU: splitter = ":" DEFAULT_LADSPA_PATH = HOME + "/.ladspa" - DEFAULT_LADSPA_PATH += ":/boot/common/add-ons/ladspa" + DEFAULT_LADSPA_PATH += ":/system/add-ons/media/ladspaplugins" + DEFAULT_LADSPA_PATH += ":/system/lib/ladspa" DEFAULT_DSSI_PATH = HOME + "/.dssi" - DEFAULT_DSSI_PATH += ":/boot/common/add-ons/dssi" + DEFAULT_DSSI_PATH += ":/system/add-ons/media/dssiplugins" + DEFAULT_DSSI_PATH += ":/system/lib/dssi" DEFAULT_LV2_PATH = HOME + "/.lv2" - DEFAULT_LV2_PATH += ":/boot/common/add-ons/lv2" + DEFAULT_LV2_PATH += ":/system/add-ons/media/lv2plugins" DEFAULT_VST2_PATH = HOME + "/.vst" - DEFAULT_VST2_PATH += ":/boot/common/add-ons/vst" + DEFAULT_VST2_PATH += ":/system/add-ons/media/vstplugins" DEFAULT_VST3_PATH = HOME + "/.vst3" - DEFAULT_VST3_PATH += ":/boot/common/add-ons/vst3" + DEFAULT_VST3_PATH += ":/system/add-ons/media/vst3plugins" elif MACOS: splitter = ":" diff --git a/source/frontend/carla_utils.py b/source/frontend/carla_utils.py index 874efded7..2450a3031 100644 --- a/source/frontend/carla_utils.py +++ b/source/frontend/carla_utils.py @@ -203,7 +203,7 @@ class CarlaUtils(object): self.lib.carla_pipe_client_new.restype = CarlaPipeClientHandle self.lib.carla_pipe_client_idle.argtypes = [CarlaPipeClientHandle] - self.lib.carla_pipe_client_idle.restype = None + self.lib.carla_pipe_client_idle.restype = c_char_p self.lib.carla_pipe_client_is_running.argtypes = [CarlaPipeClientHandle] self.lib.carla_pipe_client_is_running.restype = c_bool @@ -318,14 +318,22 @@ class CarlaUtils(object): for i in range(argc): cargv[i] = c_char_p(argv[i].encode("utf-8")) + self._pipeClientFunc = func self._pipeClientCallback = CarlaPipeCallbackFunc(func) return self.lib.carla_pipe_client_new(cargv, self._pipeClientCallback, None) def pipe_client_idle(self, handle): - try: - self.lib.carla_pipe_client_idle(handle) - except OSError as e: - print("pipe_client_idle", e) + while True: + try: + msg = self.lib.carla_pipe_client_idle(handle) + except OSError as e: + print("pipe_client_idle", e) + return + + if not msg: + break + + self._pipeClientFunc(None, msg.decode("utf-8", errors="ignore")) def pipe_client_is_running(self, handle): return bool(self.lib.carla_pipe_client_is_running(handle)) diff --git a/source/modules/lilv/config/lilv_config.h b/source/modules/lilv/config/lilv_config.h index b3d98da24..f717dcb1b 100644 --- a/source/modules/lilv/config/lilv_config.h +++ b/source/modules/lilv/config/lilv_config.h @@ -25,7 +25,7 @@ #if defined(__APPLE__) #define LILV_DEFAULT_LV2_PATH "~/Library/Audio/Plug-Ins/LV2:/Library/Audio/Plug-Ins/LV2" #elif defined(__HAIKU__) - #define LILV_DEFAULT_LV2_PATH "~/.lv2:/boot/common/add-ons/lv2" + #define LILV_DEFAULT_LV2_PATH "~/.lv2:/system/add-ons/media/lv2plugins" #elif defined(__WIN32__) #define LILV_DEFAULT_LV2_PATH "%APPDATA%\\LV2;%COMMONPROGRAMFILES%\\LV2" #else diff --git a/source/utils/CarlaOscUtils.hpp b/source/utils/CarlaOscUtils.hpp index 94e7a43be..46d3d22fd 100644 --- a/source/utils/CarlaOscUtils.hpp +++ b/source/utils/CarlaOscUtils.hpp @@ -131,7 +131,7 @@ void osc_send_control(const CarlaOscData& oscData, const int32_t index, const fl CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(index != -1,); // -1 == PARAMETER_NULL - carla_debug("osc_send_control(path:\"%s\", %i, %f)", oscData.path, index, value); + carla_debug("osc_send_control(path:\"%s\", %i, %f)", oscData.path, index, static_cast(value)); char targetPath[std::strlen(oscData.path)+9]; std::strcpy(targetPath, oscData.path); @@ -212,7 +212,7 @@ void osc_send_sample_rate(const CarlaOscData& oscData, const float sampleRate) n CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',); CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,); CARLA_SAFE_ASSERT_RETURN(sampleRate > 0.0f,); - carla_debug("osc_send_sample_rate(path:\"%s\", %f)", oscData.path, sampleRate); + carla_debug("osc_send_sample_rate(path:\"%s\", %f)", oscData.path, static_cast(sampleRate)); char targetPath[std::strlen(oscData.path)+13]; std::strcpy(targetPath, oscData.path); diff --git a/source/utils/CarlaStringList.hpp b/source/utils/CarlaStringList.hpp index d53abb6c0..78ffba22a 100644 --- a/source/utils/CarlaStringList.hpp +++ b/source/utils/CarlaStringList.hpp @@ -1,6 +1,6 @@ /* * Carla String List - * Copyright (C) 2014-2017 Filipe Coelho + * Copyright (C) 2014-2019 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -281,6 +281,23 @@ public: // ------------------------------------------------------------------- + const char* getAndRemoveFirst() noexcept + { + CARLA_SAFE_ASSERT_RETURN(fCount > 0, nullptr); + + const Data* const data = list_entry_const(fQueue.next, Data, siblings); + CARLA_SAFE_ASSERT_RETURN(data != nullptr, nullptr); + + const char* const ret = data->value; + + Itenerator it = begin2(); + LinkedList::remove(it); + + return ret; + } + + // ------------------------------------------------------------------- + bool contains(const char* const string) noexcept { CARLA_SAFE_ASSERT_RETURN(string != nullptr, false);