Adjust to the non-threaded usage

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-07-09 17:53:00 +01:00
parent 753af115c3
commit 87bc5605d0
No known key found for this signature in database
GPG Key ID: CDBAA37ABC74FBA0
10 changed files with 32 additions and 33 deletions

View File

@ -22,10 +22,11 @@
#include "CarlaUtils.h"
#include "CarlaEngine.hpp"
#ifdef BUILD_BRIDGE
# include "CarlaString.hpp"
#else
#if !(defined(BUILD_BRIDGE) || defined(CARLA_OS_WASM))
# define CARLA_CAN_USE_LOG_THREAD
# include "CarlaLogThread.hpp"
#else
# include "CarlaString.hpp"
#endif
namespace CB = CARLA_BACKEND_NAMESPACE;
@ -58,7 +59,7 @@ struct CarlaHostStandalone : CarlaHostHandleImpl {
void* fileCallbackPtr;
EngineOptions engineOptions;
#ifndef BUILD_BRIDGE
#ifdef CARLA_CAN_USE_LOG_THREAD
CarlaLogThread logThread;
bool logThreadEnabled;
#endif
@ -72,7 +73,7 @@ struct CarlaHostStandalone : CarlaHostHandleImpl {
fileCallback(nullptr),
fileCallbackPtr(nullptr),
engineOptions(),
#ifndef BUILD_BRIDGE
#ifdef CARLA_CAN_USE_LOG_THREAD
logThread(),
logThreadEnabled(false),
#endif

View File

@ -28,11 +28,6 @@
#include "CarlaBase64Utils.hpp"
#include "ThreadSafeFFTW.hpp"
#if !(defined(BUILD_BRIDGE) || defined(CARLA_OS_WASM))
# define CARLA_CAN_USE_LOG_THREAD
# include "CarlaLogThread.hpp"
#endif
#include "water/files/File.h"
#ifdef USING_JUCE

View File

@ -307,7 +307,7 @@ CarlaEngine* CarlaEngine::newDriverByName(const char* const driverName)
return newJack();
#endif
#ifndef BUILD_BRIDGE_ALTERNATIVE_ARCH
#if !(defined(BUILD_BRIDGE_ALTERNATIVE_ARCH) || defined(CARLA_OS_WASM))
if (std::strcmp(driverName, "Dummy") == 0)
return newDummy();
#endif

View File

@ -75,7 +75,7 @@ public:
pData->graph.create(2, 2, 0, 0);
if (! startThread(true))
if (! startThread())
{
close();
setLastError("Failed to start dummy audio thread");

View File

@ -1694,7 +1694,7 @@ private:
PatchbayGraph::PatchbayGraph(CarlaEngine* const engine,
const uint32_t audioIns, const uint32_t audioOuts,
const uint32_t cvIns, const uint32_t cvOuts)
: CarlaThread("PatchbayReorderThread"),
: CarlaRunner("PatchbayReorderRunner"),
connections(),
graph(),
audioBuffer(),
@ -1826,12 +1826,12 @@ PatchbayGraph::PatchbayGraph(CarlaEngine* const engine,
node->properties.set("isOSC", false);
}
startThread();
startRunner(100);
}
PatchbayGraph::~PatchbayGraph()
{
stopThread(-1);
stopRunner();
connections.clear();
extGraph.clear();
@ -2578,13 +2578,10 @@ void PatchbayGraph::process(CarlaEngine::ProtectedData* const data,
}
}
void PatchbayGraph::run()
bool PatchbayGraph::run()
{
while (! shouldThreadExit())
{
carla_msleep(100);
graph.reorderNowIfNeeded();
}
graph.reorderNowIfNeeded();
return true;
}
// -----------------------------------------------------------------------

View File

@ -22,7 +22,7 @@
#include "CarlaMutex.hpp"
#include "CarlaPatchbayUtils.hpp"
#include "CarlaStringList.hpp"
#include "CarlaThread.hpp"
#include "CarlaRunner.hpp"
#include "water/processors/AudioProcessorGraph.h"
#include "water/text/StringArray.h"
@ -163,7 +163,7 @@ struct RackGraph {
// -----------------------------------------------------------------------
// PatchbayGraph
class PatchbayGraph : private CarlaThread {
class PatchbayGraph : private CarlaRunner {
public:
PatchbayConnectionList connections;
AudioProcessorGraph graph;
@ -216,7 +216,7 @@ public:
uint32_t frames);
private:
void run() override;
bool run() override;
CarlaEngine* const kEngine;
CARLA_DECLARE_NON_COPYABLE(PatchbayGraph)

View File

@ -769,25 +769,24 @@ ScopedActionLock::ScopedActionLock(CarlaEngine* const engine,
if (pData->nextAction.needsPost)
{
bool engineStoppedWhileWaiting = false;
#ifndef CARLA_OS_WASM
#if defined(DEBUG) || defined(BUILD_BRIDGE)
// block wait for unlock on processing side
carla_stdout(ACTION_MSG_PREFIX "ScopedPluginAction(%i) - blocking START", pluginId);
#endif
bool engineStoppedWhileWaiting = false;
if (! pData->nextAction.postDone)
{
for (int i = 10; --i >= 0;)
{
#ifndef CARLA_OS_WASM
if (pData->nextAction.sem != nullptr)
{
if (carla_sem_timedwait(*pData->nextAction.sem, 200))
break;
}
else
#endif
{
carla_msleep(200);
}
@ -803,6 +802,7 @@ ScopedActionLock::ScopedActionLock(CarlaEngine* const engine,
#if defined(DEBUG) || defined(BUILD_BRIDGE)
carla_stdout(ACTION_MSG_PREFIX "ScopedPluginAction(%i) - blocking DONE", pluginId);
#endif
#endif
// check if anything went wrong...
if (! pData->nextAction.postDone)

View File

@ -34,12 +34,16 @@ OBJS = \
$(OBJDIR)/CarlaEngine.cpp.o \
$(OBJDIR)/CarlaEngineClient.cpp.o \
$(OBJDIR)/CarlaEngineData.cpp.o \
$(OBJDIR)/CarlaEngineDummy.cpp.o \
$(OBJDIR)/CarlaEngineGraph.cpp.o \
$(OBJDIR)/CarlaEngineInternal.cpp.o \
$(OBJDIR)/CarlaEnginePorts.cpp.o \
$(OBJDIR)/CarlaEngineRunner.cpp.o
ifneq ($(WASM),true)
OBJS += \
$(OBJDIR)/CarlaEngineDummy.cpp.o
endif
ifeq ($(HAVE_LIBLO),true)
OBJS += \
$(OBJDIR)/CarlaEngineOsc.cpp.o \

View File

@ -1,6 +1,6 @@
/*
* Carla Plugin Host
* Copyright (C) 2011-2018 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2022 Filipe Coelho <falktx@falktx.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@ -17,7 +17,9 @@
#include "CarlaUtils.h"
#include "CarlaThread.hpp"
#ifndef CARLA_OS_WASM
# include "CarlaThread.hpp"
#endif
// -------------------------------------------------------------------------------------------------------------------
@ -35,7 +37,9 @@ void carla_set_process_name(const char* name)
{
carla_debug("carla_set_process_name(\"%s\")", name);
#ifndef CARLA_OS_WASM
CarlaThread::setCurrentThreadName(name);
#endif
}
// -------------------------------------------------------------------------------------------------------------------

View File

@ -13,8 +13,6 @@
#include "water/synthesisers/Synthesiser.h"
#include "water/text/StringArray.h"
#include "CarlaThread.hpp"
namespace sfzero
{