Browse Source

Map NATIVE_HOST_OPCODE_REQUEST_IDLE to lv2 worker

tags/v2.3.0-RC1
falkTX 3 years ago
parent
commit
6d4937abdb
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
4 changed files with 49 additions and 13 deletions
  1. +6
    -6
      source/includes/CarlaNative.hpp
  2. +3
    -0
      source/plugin/Makefile
  3. +34
    -4
      source/plugin/carla-lv2.cpp
  4. +6
    -3
      source/utils/CarlaLv2Utils.hpp

+ 6
- 6
source/includes/CarlaNative.hpp View File

@@ -225,18 +225,18 @@ protected:
pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_HOST_IDLE, 0, 0, nullptr, 0.0f);
}

void hostRequestIdle() const
bool hostRequestIdle() const
{
CARLA_SAFE_ASSERT_RETURN(pHost != nullptr,);
CARLA_SAFE_ASSERT_RETURN(pHost != nullptr, 0);

pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_REQUEST_IDLE, 0, 0, nullptr, 0.0f);
return pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_REQUEST_IDLE, 0, 0, nullptr, 0.0f) == 1;
}

void hostQueueDrawInlineDisplay()
bool hostQueueDrawInlineDisplay()
{
CARLA_SAFE_ASSERT_RETURN(pHost != nullptr,);
CARLA_SAFE_ASSERT_RETURN(pHost != nullptr, 0);

pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_QUEUE_INLINE_DISPLAY, 0, 0, nullptr, 0.0f);
return pHost->dispatcher(pHost->handle, NATIVE_HOST_OPCODE_QUEUE_INLINE_DISPLAY, 0, 0, nullptr, 0.0f) == 1;
}

const char* hostGetFilePath(const char* const filetype) const


+ 3
- 0
source/plugin/Makefile View File

@@ -509,6 +509,9 @@ $(OBJDIR)/carla-lv2-export.cpp.o: carla-lv2-export.cpp
-include $(OBJDIR)/carla-host-plugin.cpp.d
-include $(OBJDIR)/carla-native-plugin.cpp.d
-include $(OBJDIR)/carla-lv2.cpp.d
-include $(OBJDIR)/carla-lv2-bundles.cpp.audiogain.d
-include $(OBJDIR)/carla-lv2-bundles.cpp.files.d
-include $(OBJDIR)/carla-lv2-bundles.cpp.miditools.d
-include $(OBJDIR)/carla-lv2-export.cpp.d
-include $(OBJDIR)/carla-vst.cpp.patchbay-fx.d
-include $(OBJDIR)/carla-vst.cpp.patchbay-syn.d


+ 34
- 4
source/plugin/carla-lv2.cpp View File

@@ -57,6 +57,7 @@ public:
fMidiEventCount(0),
fLastProjectPath(),
fLoadedFile(),
fPluginNeedsIdle(false),
fWorkerUISignal(0)
{
carla_zeroStruct(fHost);
@@ -234,7 +235,7 @@ public:
if (event == nullptr)
continue;

if (event->body.type == fURIs.uiEvents && fWorkerUISignal != -1)
if (event->body.type == fURIs.carlaUiEvents && fWorkerUISignal != -1)
{
CARLA_SAFE_ASSERT_CONTINUE((fDescriptor->hints & NATIVE_PLUGIN_NEEDS_UI_OPEN_SAVE) == 0);

@@ -320,6 +321,14 @@ public:

fDescriptor->process(fHandle, fPorts.audioCVIns, fPorts.audioCVOuts, frames, fMidiEvents, fMidiEventCount);

if (fPluginNeedsIdle)
{
fPluginNeedsIdle = false;
const char* const msg = "idle";
const size_t msgSize = std::strlen(msg);
fWorker->schedule_work(fWorker->handle, static_cast<uint32_t>(msgSize + 1U), msg);
}

if (fWorkerUISignal == -1 && fPorts.hasUI)
{
const char* const msg = "quit";
@@ -334,7 +343,7 @@ public:

aev->time.frames = 0;
aev->body.size = msgSize;
aev->body.type = fURIs.uiEvents;
aev->body.type = fURIs.carlaUiEvents;
std::memcpy(LV2_ATOM_BODY(&aev->body), msg, msgSize);

const uint32_t size = lv2_atom_pad_size(static_cast<uint32_t>(sizeof(LV2_Atom_Event) + msgSize));
@@ -517,6 +526,15 @@ public:
{
const char* const msg = (const char*)data;

if (fDescriptor->hints & NATIVE_PLUGIN_REQUESTS_IDLE)
{
if (std::strcmp(msg, "idle") == 0)
{
fDescriptor->dispatcher(fHandle, NATIVE_PLUGIN_OPCODE_IDLE, 0, 0, nullptr, 0.0f);
return LV2_WORKER_SUCCESS;
}
}

if (fDescriptor->hints & NATIVE_PLUGIN_NEEDS_UI_OPEN_SAVE)
{
fLoadedFile = msg;
@@ -839,11 +857,21 @@ protected:
case NATIVE_HOST_OPCODE_RELOAD_ALL:
case NATIVE_HOST_OPCODE_HOST_IDLE:
case NATIVE_HOST_OPCODE_INTERNAL_PLUGIN:
case NATIVE_HOST_OPCODE_QUEUE_INLINE_DISPLAY:
case NATIVE_HOST_OPCODE_REQUEST_IDLE:
// nothing
break;

case NATIVE_HOST_OPCODE_REQUEST_IDLE:
CARLA_SAFE_ASSERT_RETURN(fDescriptor->hints & NATIVE_PLUGIN_REQUESTS_IDLE, 0);
if (fWorker != nullptr)
{
fPluginNeedsIdle = true;
return 1;
}
return 0;

case NATIVE_HOST_OPCODE_QUEUE_INLINE_DISPLAY:
break;

case NATIVE_HOST_OPCODE_GET_FILE_PATH:
CARLA_SAFE_ASSERT_RETURN(ptr != nullptr, 0);
if (std::strcmp((char*)ptr, "carla") == 0 && fLastProjectPath != nullptr)
@@ -908,8 +936,10 @@ private:

CarlaString fLastProjectPath;
CarlaString fLoadedFile;
volatile bool fPluginNeedsIdle;

int fWorkerUISignal;
// -1 needs close, 0 idle, 1 stuff is writing??

// -------------------------------------------------------------------



+ 6
- 3
source/utils/CarlaLv2Utils.hpp View File

@@ -1524,7 +1524,8 @@ protected:
LV2_URID timeFrame;
LV2_URID timeSpeed;
LV2_URID timeTicksPerBeat;
LV2_URID uiEvents;
LV2_URID carlaRequestIdle;
LV2_URID carlaUiEvents;

URIDs()
: atomBlank(0),
@@ -1553,7 +1554,8 @@ protected:
timeFrame(0),
timeSpeed(0),
timeTicksPerBeat(0),
uiEvents(0) {}
carlaRequestIdle(0),
carlaUiEvents(0) {}

void map(const LV2_URID_Map* const uridMap)
{
@@ -1583,7 +1585,8 @@ protected:
timeBeatsPerBar = uridMap->map(uridMap->handle, LV2_TIME__beatsPerBar);
timeBeatsPerMinute = uridMap->map(uridMap->handle, LV2_TIME__beatsPerMinute);
timeTicksPerBeat = uridMap->map(uridMap->handle, LV2_KXSTUDIO_PROPERTIES__TimePositionTicksPerBeat);
uiEvents = uridMap->map(uridMap->handle, "urn:carla:transmitEv");
carlaRequestIdle = uridMap->map(uridMap->handle, "urn:carla:idle");
carlaUiEvents = uridMap->map(uridMap->handle, "urn:carla:uiEvents");
}
} fURIs;



Loading…
Cancel
Save