Browse Source

Fixes to lv2 uis and messages

tags/1.9.4
falkTX 10 years ago
parent
commit
29b2a45ad4
6 changed files with 218 additions and 128 deletions
  1. +55
    -32
      source/backend/plugin/Lv2Plugin.cpp
  2. +11
    -6
      source/bridges/CarlaBridgeToolkitGtk.cpp
  3. +12
    -7
      source/bridges/CarlaBridgeToolkitQt.cpp
  4. +133
    -82
      source/bridges/CarlaBridgeUI-LV2.cpp
  5. +1
    -1
      source/utils/CarlaOscUtils.hpp
  6. +6
    -0
      source/utils/LinkedList.hpp

+ 55
- 32
source/backend/plugin/Lv2Plugin.cpp View File

@@ -39,6 +39,8 @@ extern "C" {
#include <QtCore/QFile>
#include <QtCore/QUrl>

#define URI_CARLA_WORKER "http://kxstudio.sf.net/ns/carla/worker"

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

CARLA_BACKEND_START_NAMESPACE
@@ -361,12 +363,6 @@ public:
for (uint32_t i=0; i < CARLA_URI_MAP_ID_COUNT; ++i)
fCustomURIDs.append(nullptr);

// FIXME
fCustomURIDs.append(carla_strdup("http://drobilla.net/ns/ingen#GraphUIGtk2"));
fCustomURIDs.append(carla_strdup("http://lv2plug.in/ns/ext/state#interface"));
fCustomURIDs.append(carla_strdup("ingen:/root"));
fCustomURIDs.append(carla_strdup("ingen:/root/"));

#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
@@ -2594,12 +2590,12 @@ public:
if (! fAtomQueueIn.isEmpty())
{
const LV2_Atom* atom;
uint32_t portIndex;

const uint32_t j = fEventsIn.ctrlIndex;
uint32_t j, portIndex;

for (; fAtomQueueIn.get(&atom, &portIndex);)
{
j = (portIndex < fEventsIn.count) ? portIndex : fEventsIn.ctrlIndex;

if (atom->type == CARLA_URI_MAP_ID_ATOM_WORKER)
{
CARLA_SAFE_ASSERT_CONTINUE(fExt.worker != nullptr && fExt.worker->work_response != nullptr);
@@ -3004,8 +3000,9 @@ public:
fEventsOut.ctrl->port->writeMidiEvent(static_cast<uint32_t>(ev->time.frames), static_cast<uint8_t>(ev->body.size), data);
}
}
else if (ev->body.type == CARLA_URI_MAP_ID_ATOM_BLANK)
else //if (ev->body.type == CARLA_URI_MAP_ID_ATOM_BLANK)
{
//carla_stdout("Got out event, %s", carla_lv2_urid_unmap(this, ev->body.type));
fAtomQueueOut.put(&ev->body, fEventsOut.ctrl->rindex);
}

@@ -3514,6 +3511,8 @@ public:

for (size_t i=CARLA_URI_MAP_ID_COUNT, count=fCustomURIDs.count(); i < count; ++i)
osc_send_lv2_urid_map(pData->osc.data, static_cast<uint32_t>(i), fCustomURIDs.getAt(i));

osc_send_lv2_urid_map(pData->osc.data, CARLA_URI_MAP_ID_NULL, "Complete");
}

// -------------------------------------------------------------------
@@ -4030,7 +4029,7 @@ public:
{
CARLA_SAFE_ASSERT_RETURN(fExt.worker != nullptr && fExt.worker->work != nullptr, LV2_WORKER_ERR_UNKNOWN);
CARLA_SAFE_ASSERT_RETURN(fEventsIn.ctrl != nullptr, LV2_WORKER_ERR_UNKNOWN);
carla_stdout("Lv2Plugin::handleWorkerSchedule(%i, %p)", size, data);
carla_debug("Lv2Plugin::handleWorkerSchedule(%i, %p)", size, data);

if (pData->engine->isOffline())
{
@@ -4042,18 +4041,18 @@ public:
atom.size = size;
atom.type = CARLA_URI_MAP_ID_ATOM_WORKER;

return fAtomQueueOut.putChunk(&atom, data, fEventsIn.ctrl->rindex) ? LV2_WORKER_SUCCESS : LV2_WORKER_ERR_NO_SPACE;
return fAtomQueueOut.putChunk(&atom, data, fEventsOut.ctrlIndex) ? LV2_WORKER_SUCCESS : LV2_WORKER_ERR_NO_SPACE;
}

LV2_Worker_Status handleWorkerRespond(const uint32_t size, const void* const data)
{
carla_stdout("Lv2Plugin::handleWorkerRespond(%i, %p)", size, data);
carla_debug("Lv2Plugin::handleWorkerRespond(%i, %p)", size, data);

LV2_Atom atom;
atom.size = size;
atom.type = CARLA_URI_MAP_ID_ATOM_WORKER;

return fAtomQueueIn.putChunk(&atom, data, fEventsIn.ctrl->rindex) ? LV2_WORKER_SUCCESS : LV2_WORKER_ERR_NO_SPACE;
return fAtomQueueIn.putChunk(&atom, data, fEventsIn.ctrlIndex) ? LV2_WORKER_SUCCESS : LV2_WORKER_ERR_NO_SPACE;
}

// -------------------------------------------------------------------
@@ -4121,31 +4120,51 @@ public:
CARLA_SAFE_ASSERT_RETURN(bufferSize > 0,);
carla_debug("Lv2Plugin::handleUiWrite(%i, %i, %i, %p)", rindex, bufferSize, format, buffer);

uint32_t index = LV2UI_INVALID_PORT_INDEX;

switch (format)
{
case CARLA_URI_MAP_ID_NULL:
case CARLA_URI_MAP_ID_NULL: {
CARLA_SAFE_ASSERT_RETURN(bufferSize == sizeof(float),);

for (uint32_t i=0; i < pData->param.count; ++i)
{
if (pData->param.data[i].rindex == static_cast<int32_t>(rindex))
{
const float value(*(const float*)buffer);

if (fParamBuffers[i] != value)
setParameterValue(i, value, false, true, true);
break;
}
if (pData->param.data[i].rindex != static_cast<int32_t>(rindex))
continue;
index = i;
break;
}
break;

CARLA_SAFE_ASSERT_RETURN(index != LV2UI_INVALID_PORT_INDEX,);

const float value(*(const float*)buffer);

if (fParamBuffers[index] != value)
setParameterValue(index, value, false, true, true);

} break;

case CARLA_URI_MAP_ID_ATOM_TRANSFER_ATOM:
case CARLA_URI_MAP_ID_ATOM_TRANSFER_EVENT:
// plugins sometimes fails on this, not good...
CARLA_SAFE_ASSERT_INT2(((const LV2_Atom*)buffer)->size == bufferSize, ((const LV2_Atom*)buffer)->size, bufferSize);
case CARLA_URI_MAP_ID_ATOM_TRANSFER_EVENT: {
CARLA_SAFE_ASSERT_RETURN(bufferSize >= sizeof(LV2_Atom),);

fAtomQueueIn.put((const LV2_Atom*)buffer, rindex);
break;
// plugins sometimes fail on this, not good...
CARLA_SAFE_ASSERT_INT2(((const LV2_Atom*)buffer)->size == bufferSize-sizeof(LV2_Atom), ((const LV2_Atom*)buffer)->size, bufferSize-sizeof(LV2_Atom));

for (uint32_t i=0; i < fEventsIn.count; ++i)
{
if (fEventsIn.data[i].rindex != rindex)
continue;
index = i;
break;
}

// for bad plugins
CARLA_SAFE_ASSERT(index != LV2UI_INVALID_PORT_INDEX);
index = fEventsIn.ctrlIndex;

fAtomQueueIn.put((const LV2_Atom*)buffer, index);
} break;

default:
carla_stdout("Lv2Plugin::handleUiWrite(%i, %i, %i:\"%s\", %p) - unknown format", rindex, bufferSize, format, carla_lv2_urid_unmap(this, format), buffer);
@@ -4921,7 +4940,7 @@ public:
void handleTransferAtom(const uint32_t portIndex, const LV2_Atom* const atom)
{
CARLA_SAFE_ASSERT_RETURN(atom != nullptr,);
carla_debug("Lv2Plugin::handleTransferAtom(%i, %p)", portIndex, atom);
carla_stdout("Lv2Plugin::handleTransferAtom(%i, %p)", portIndex, atom);

fAtomQueueIn.put(atom, portIndex);
}
@@ -4930,7 +4949,7 @@ public:
{
CARLA_SAFE_ASSERT_RETURN(urid != CARLA_URI_MAP_ID_NULL,);
CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0',);
carla_debug("Lv2Plugin::handleUridMap(%i v " P_SIZE ", \"%s\")", urid, fCustomURIDs.count()-1, uri);
carla_stdout("Lv2Plugin::handleUridMap(%i v " P_SIZE ", \"%s\")", urid, fCustomURIDs.count()-1, uri);

if (urid < fCustomURIDs.count())
{
@@ -5308,6 +5327,10 @@ private:
if (std::strcmp(uri, LV2_PARAMETERS__sampleRate) == 0)
return CARLA_URI_MAP_ID_PARAM_SAMPLE_RATE;

// Custom
if (std::strcmp(uri, URI_CARLA_WORKER) == 0)
return CARLA_URI_MAP_ID_ATOM_WORKER;

// Custom types
return ((Lv2Plugin*)handle)->getCustomURID(uri);
}
@@ -5362,7 +5385,7 @@ private:
if (urid == CARLA_URI_MAP_ID_ATOM_VECTOR)
return LV2_ATOM__Vector;
if (urid == CARLA_URI_MAP_ID_ATOM_WORKER)
return nullptr; // custom
return URI_CARLA_WORKER; // custom
if (urid == CARLA_URI_MAP_ID_ATOM_TRANSFER_ATOM)
return LV2_ATOM__atomTransfer;
if (urid == CARLA_URI_MAP_ID_ATOM_TRANSFER_EVENT)


+ 11
- 6
source/bridges/CarlaBridgeToolkitGtk.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla Bridge Toolkit, Gtk version
* Copyright (C) 2011-2013 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2014 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
@@ -47,6 +47,7 @@ class CarlaToolkitGtk : public CarlaBridgeToolkit
public:
CarlaToolkitGtk(CarlaBridgeClient* const client, const char* const uiTitle)
: CarlaBridgeToolkit(client, uiTitle),
fNeedsShow(false),
fWindow(nullptr),
fLastX(0),
fLastY(0),
@@ -118,10 +119,11 @@ public:
gtk_window_set_keep_above(GTK_WINDOW(fWindow), true);
}

if (showGui)
if (showGui || fNeedsShow)
{
show();
else
kClient->sendOscUpdate();
fNeedsShow = false;
}

g_timeout_add(30, gtk_ui_timeout, this);
g_signal_connect(fWindow, "destroy", G_CALLBACK(gtk_ui_destroy), this);
@@ -149,18 +151,20 @@ public:

void show() override
{
CARLA_ASSERT(fWindow != nullptr);
carla_debug("CarlaToolkitGtk::show()");

fNeedsShow = true;

if (fWindow != nullptr)
gtk_widget_show_all(fWindow);
}

void hide() override
{
CARLA_ASSERT(fWindow != nullptr);
carla_debug("CarlaToolkitGtk::hide()");

fNeedsShow = false;

if (fWindow != nullptr)
gtk_widget_hide(fWindow);
}
@@ -177,6 +181,7 @@ public:
// ---------------------------------------------------------------------

protected:
bool fNeedsShow;
GtkWidget* fWindow;

gint fLastX;


+ 12
- 7
source/bridges/CarlaBridgeToolkitQt.cpp View File

@@ -88,7 +88,8 @@ public:
#ifdef BRIDGE_CONTAINER
fEmbedContainer(nullptr),
#endif
fMsgTimer(0)
fMsgTimer(0),
fNeedsShow(false)
{
carla_debug("CarlaBridgeToolkitQt::CarlaBridgeToolkitQt(%p, \"%s\")", client, uiTitle);

@@ -190,10 +191,11 @@ public:
fWindow->setWindowFlags(fWindow->windowFlags() | Qt::WindowStaysOnTopHint);
}

if (showGui)
if (showGui || fNeedsShow)
{
show();
else
kClient->sendOscUpdate();
fNeedsShow = false;
}

fMsgTimer = startTimer(30);

@@ -254,18 +256,20 @@ public:

void show() override
{
CARLA_ASSERT(fWindow != nullptr);
carla_debug("CarlaBridgeToolkitQt::show()");

fNeedsShow = true;

if (fWindow != nullptr)
fWindow->show();
}

void hide() override
{
CARLA_ASSERT(fWindow != nullptr);
carla_debug("CarlaBridgeToolkitQt::hide()");

fNeedsShow = false;

if (fWindow != nullptr)
fWindow->hide();
}
@@ -313,7 +317,8 @@ protected:
QEmbedContainer* fEmbedContainer;
#endif

int fMsgTimer;
int fMsgTimer;
bool fNeedsShow;

void handleTimeout()
{


+ 133
- 82
source/bridges/CarlaBridgeUI-LV2.cpp View File

@@ -1,6 +1,6 @@
/*
* Carla Bridge UI, LV2 version
* Copyright (C) 2011-2013 Filipe Coelho <falktx@falktx.com>
* Copyright (C) 2011-2014 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
@@ -22,9 +22,7 @@

#include <QtCore/QDir>

extern "C" {
#include "rtmempool/rtmempool-lv2.h"
}
#define URI_CARLA_WORKER "http://kxstudio.sf.net/ns/carla/worker"

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

@@ -184,6 +182,7 @@ public:
fDescriptor(nullptr),
fRdfDescriptor(nullptr),
fRdfUiDescriptor(nullptr),
fIsReady(false),
#if defined(BRIDGE_COCOA) || defined(BRIDGE_HWND) || defined(BRIDGE_X11)
fIsResizable(false)
#else
@@ -195,12 +194,6 @@ public:
for (uint32_t i=0; i < CARLA_URI_MAP_ID_COUNT; ++i)
fCustomURIDs.append(nullptr);

// FIXME
fCustomURIDs.append(carla_strdup("http://drobilla.net/ns/ingen#GraphUIGtk2"));
fCustomURIDs.append(carla_strdup("http://lv2plug.in/ns/ext/state#interface"));
fCustomURIDs.append(carla_strdup("ingen:/root"));
fCustomURIDs.append(carla_strdup("ingen:/root/"));

// ---------------------------------------------------------------
// initialize options

@@ -418,7 +411,7 @@ public:
fFeatures[kFeatureIdUiParent]->data = getContainerId();
#endif

fHandle = fDescriptor->instantiate(fDescriptor, pluginURI, fRdfUiDescriptor->Bundle, carla_lv2_ui_write_function, this, &fWidget, fFeatures);
fHandle = fDescriptor->instantiate(fDescriptor, fRdfDescriptor->URI, fRdfUiDescriptor->Bundle, carla_lv2_ui_write_function, this, &fWidget, fFeatures);

if (fHandle == nullptr)
{
@@ -467,8 +460,11 @@ public:
{
CarlaBridgeClient::uiClose();

if (fHandle && fDescriptor && fDescriptor->cleanup)
if (fHandle != nullptr && fDescriptor != nullptr && fDescriptor->cleanup != nullptr)
{
fDescriptor->cleanup(fHandle);
fHandle = nullptr;
}

uiLibClose();
}
@@ -500,10 +496,13 @@ public:

void setParameter(const int32_t rindex, const float value) override
{
CARLA_ASSERT(fHandle != nullptr && fDescriptor != nullptr);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,)
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);

if (fHandle != nullptr && fDescriptor != nullptr && fDescriptor->port_event != nullptr)
fDescriptor->port_event(fHandle, rindex, sizeof(float), 0, &value);
if (fDescriptor->port_event == nullptr)
return;

fDescriptor->port_event(fHandle, rindex, sizeof(float), 0, &value);
}

void setProgram(const uint32_t) override
@@ -512,45 +511,67 @@ public:

void setMidiProgram(const uint32_t bank, const uint32_t program) override
{
CARLA_ASSERT(fHandle != nullptr);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,)

if (fExt.programs == nullptr)
return;

if (fHandle != nullptr && fExt.programs != nullptr)
fExt.programs->select_program(fHandle, bank, program);
fExt.programs->select_program(fHandle, bank, program);
}

void noteOn(const uint8_t channel, const uint8_t note, const uint8_t velo) override
{
CARLA_ASSERT(fHandle != nullptr && fDescriptor != nullptr);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,)
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);

if (fHandle != nullptr && fDescriptor != nullptr && fDescriptor->port_event != nullptr)
{
LV2_Atom_MidiEvent midiEv;
midiEv.event.time.frames = 0;
midiEv.event.body.type = CARLA_URI_MAP_ID_MIDI_EVENT;
midiEv.event.body.size = 3;
midiEv.data[0] = MIDI_STATUS_NOTE_ON + channel;
midiEv.data[1] = note;
midiEv.data[2] = velo;
fDescriptor->port_event(fHandle, 0, 3, CARLA_URI_MAP_ID_ATOM_TRANSFER_ATOM, &midiEv);
}
if (fDescriptor->port_event == nullptr)
return;
LV2_Atom_MidiEvent midiEv;
midiEv.event.time.frames = 0;
midiEv.event.body.type = CARLA_URI_MAP_ID_MIDI_EVENT;
midiEv.event.body.size = 3;
midiEv.data[0] = MIDI_STATUS_NOTE_ON + channel;
midiEv.data[1] = note;
midiEv.data[2] = velo;
fDescriptor->port_event(fHandle, 0, 3, CARLA_URI_MAP_ID_ATOM_TRANSFER_ATOM, &midiEv);
}

void noteOff(const uint8_t channel, const uint8_t note) override
{
CARLA_ASSERT(fHandle != nullptr && fDescriptor != nullptr);
CARLA_SAFE_ASSERT_RETURN(fHandle != nullptr,)
CARLA_SAFE_ASSERT_RETURN(fDescriptor != nullptr,);

if (fHandle != nullptr && fDescriptor != nullptr && fDescriptor->port_event != nullptr)
if (fDescriptor->port_event == nullptr)
return;

LV2_Atom_MidiEvent midiEv;
midiEv.event.time.frames = 0;
midiEv.event.body.type = CARLA_URI_MAP_ID_MIDI_EVENT;
midiEv.event.body.size = 3;
midiEv.data[0] = MIDI_STATUS_NOTE_OFF + channel;
midiEv.data[1] = note;
midiEv.data[2] = 0;

fDescriptor->port_event(fHandle, 0, 3, CARLA_URI_MAP_ID_ATOM_TRANSFER_ATOM, &midiEv);
}

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

void waitForOscURIs()
{
sendOscUpdate();

if (fIsReady)
return;

for (int i=0; i < 2000; ++i)
{
LV2_Atom_MidiEvent midiEv;
midiEv.event.time.frames = 0;
midiEv.event.body.type = CARLA_URI_MAP_ID_MIDI_EVENT;
midiEv.event.body.size = 3;
midiEv.data[0] = MIDI_STATUS_NOTE_OFF + channel;
midiEv.data[1] = note;
midiEv.data[2] = 0;

fDescriptor->port_event(fHandle, 0, 3, CARLA_URI_MAP_ID_ATOM_TRANSFER_ATOM, &midiEv);
if (fIsReady)
return;
oscIdle();
carla_msleep(10);
}
}

@@ -558,41 +579,41 @@ public:

LV2_URID getCustomURID(const char* const uri)
{
CARLA_ASSERT(uri != nullptr);
CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0', CARLA_URI_MAP_ID_NULL);
carla_debug("CarlaLv2Client::getCustomURID(\"%s\")", uri);

if (uri == nullptr)
return CARLA_URI_MAP_ID_NULL;
LV2_URID urid = CARLA_URI_MAP_ID_NULL;

for (size_t i=0; i < fCustomURIDs.count(); ++i)
{
const char* const thisUri(fCustomURIDs.getAt(i));

if (thisUri != nullptr && std::strcmp(thisUri, uri) == 0)
return i;
{
urid = i;
break;
}
}

fCustomURIDs.append(carla_strdup(uri));

const LV2_URID urid(fCustomURIDs.count()-1);
if (urid == CARLA_URI_MAP_ID_NULL)
{
urid = fCustomURIDs.count();
fCustomURIDs.append(carla_strdup(uri));
}

if (isOscControlRegistered())
sendOscLv2UridMap(urid, uri);
//if (isOscControlRegistered())
sendOscLv2UridMap(urid, uri);

return urid;
}

const char* getCustomURIString(const LV2_URID urid)
const char* getCustomURIString(const LV2_URID urid) const noexcept
{
CARLA_ASSERT(urid != CARLA_URI_MAP_ID_NULL);
CARLA_ASSERT_INT2(urid < fCustomURIDs.count(), urid, fCustomURIDs.count());
CARLA_SAFE_ASSERT_RETURN(urid != CARLA_URI_MAP_ID_NULL, nullptr);
CARLA_SAFE_ASSERT_RETURN(urid < fCustomURIDs.count(), nullptr);
carla_debug("CarlaLv2Client::getCustomURIString(%i)", urid);

if (urid == CARLA_URI_MAP_ID_NULL)
return nullptr;
if (urid < fCustomURIDs.count())
return fCustomURIDs.getAt(urid);

return nullptr;
return fCustomURIDs.getAt(urid);
}

// ---------------------------------------------------------------------
@@ -605,10 +626,8 @@ public:

uint32_t handleUiPortMap(const char* const symbol)
{
CARLA_ASSERT(symbol != nullptr);

if (symbol == nullptr)
return LV2UI_INVALID_PORT_INDEX;
CARLA_SAFE_ASSERT_RETURN(symbol != nullptr && symbol[0] != '\0', LV2UI_INVALID_PORT_INDEX);
carla_debug("CarlaLv2Client::handleUiPortMap(\"%s\")", symbol);

for (uint32_t i=0; i < fRdfDescriptor->PortCount; ++i)
{
@@ -621,11 +640,9 @@ public:

int handleUiResize(const int width, const int height)
{
CARLA_ASSERT(width > 0);
CARLA_ASSERT(height > 0);

if (width <= 0 || height <= 0)
return 1;
CARLA_SAFE_ASSERT_RETURN(width > 0, 1);
CARLA_SAFE_ASSERT_RETURN(height > 0, 1);
carla_debug("CarlaLv2Client::handleUiResize(%i, %i)", width, height);

toolkitResize(width, height);

@@ -634,6 +651,10 @@ public:

void handleUiWrite(uint32_t portIndex, uint32_t bufferSize, uint32_t format, const void* buffer)
{
CARLA_SAFE_ASSERT_RETURN(buffer != nullptr,);
CARLA_SAFE_ASSERT_RETURN(bufferSize > 0,);
carla_debug("CarlaLv2Client::handleUiWrite(%i, %i, %i, %p)", rindex, bufferSize, format, buffer);

if (format == 0)
{
CARLA_ASSERT(buffer != nullptr);
@@ -647,7 +668,7 @@ public:

const float value(*(const float*)buffer);

if (isOscControlRegistered())
//if (isOscControlRegistered())
sendOscControl(portIndex, value);
}
else if (format == CARLA_URI_MAP_ID_ATOM_TRANSFER_ATOM || CARLA_URI_MAP_ID_ATOM_TRANSFER_EVENT)
@@ -658,7 +679,7 @@ public:
if (bufferSize == 0 || buffer == nullptr)
return;

if (isOscControlRegistered())
//if (isOscControlRegistered())
sendOscLv2AtomTransfer(portIndex, QByteArray((const char*)buffer, bufferSize).toBase64().constData());
}
else
@@ -680,23 +701,45 @@ public:

void handleUridMap(const LV2_URID urid, const char* const uri)
{
CARLA_ASSERT(urid != CARLA_URI_MAP_ID_NULL);
CARLA_ASSERT(uri != nullptr);
carla_debug("CarlaLv2Client::handleUridMap(%i, \"%s\")", urid, uri);
CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0',);
carla_stdout("CarlaLv2Client::handleUridMap(%i, \"%s\")", urid, uri);

if (urid < fCustomURIDs.count())
if (urid == CARLA_URI_MAP_ID_NULL)
{
const char* const ourURI(carla_lv2_urid_unmap(this, urid));
CARLA_SAFE_ASSERT_RETURN(ourURI != nullptr,);
CARLA_SAFE_ASSERT_RETURN(std::strcmp(uri, "Complete") == 0,);
carla_stdout("URID map from host complete");
fIsReady = true;
return;
}

if (std::strcmp(ourURI, uri) != 0)
const uint32_t uridCount(fCustomURIDs.count());

if (urid < uridCount)
{
if (const char* const ourURI = carla_lv2_urid_unmap(this, urid))
{
if (std::strcmp(ourURI, uri) != 0)
carla_stderr2("UI :: wrong URI '%s' vs '%s'", ourURI, uri);
}
else
{
carla_stderr2("UI :: wrong URI '%s' vs '%s'", ourURI, uri);
uint32_t i=0;
for (LinkedList<const char*>::Itenerator it = fCustomURIDs.begin(); it.valid(); it.next())
{
if (i != urid)
continue;
it.setValue(carla_strdup(uri));
break;
}
}
}
else if (urid > uridCount)
{
for (uint32_t i=uridCount; i < urid; ++i)
fCustomURIDs.append(nullptr);
}
else
{
CARLA_SAFE_ASSERT_RETURN(urid == fCustomURIDs.count(),);
fCustomURIDs.append(carla_strdup(uri));
}
}
@@ -711,6 +754,7 @@ private:
const LV2_RDF_UI* fRdfUiDescriptor;
Lv2PluginOptions fOptions;

bool fIsReady;
bool fIsResizable;
LinkedList<const char*> fCustomURIDs;

@@ -951,6 +995,10 @@ private:
if (std::strcmp(uri, LV2_PARAMETERS__sampleRate) == 0)
return CARLA_URI_MAP_ID_PARAM_SAMPLE_RATE;

// Custom
if (std::strcmp(uri, URI_CARLA_WORKER) == 0)
return CARLA_URI_MAP_ID_ATOM_WORKER;

// Custom types
return ((CarlaLv2Client*)handle)->getCustomURID(uri);
}
@@ -1005,7 +1053,7 @@ private:
if (urid == CARLA_URI_MAP_ID_ATOM_VECTOR)
return LV2_ATOM__Vector;
if (urid == CARLA_URI_MAP_ID_ATOM_WORKER)
return nullptr; // custom
return URI_CARLA_WORKER; // custom
if (urid == CARLA_URI_MAP_ID_ATOM_TRANSFER_ATOM)
return LV2_ATOM__atomTransfer;
if (urid == CARLA_URI_MAP_ID_ATOM_TRANSFER_EVENT)
@@ -1133,7 +1181,7 @@ int CarlaBridgeOsc::handleMsgLv2UridMap(CARLA_BRIDGE_OSC_HANDLE_ARGS)
const int32_t urid = argv[0]->i;
const char* const uri = (const char*)&argv[1]->s;

if (urid <= 0)
if (urid < 0)
return 0;

lv2ClientPtr->handleUridMap(urid, uri);
@@ -1170,7 +1218,10 @@ int main(int argc, char* argv[])

// Init OSC
if (useOsc)
{
client.oscInit(oscUrl);
client.waitForOscURIs();
}

// Load UI
int ret;


+ 1
- 1
source/utils/CarlaOscUtils.hpp View File

@@ -305,7 +305,7 @@ void osc_send_lv2_urid_map(const CarlaOscData& oscData, const uint32_t urid, con
{
CARLA_SAFE_ASSERT_RETURN(oscData.path != nullptr && oscData.path[0] != '\0',);
CARLA_SAFE_ASSERT_RETURN(oscData.target != nullptr,);
CARLA_SAFE_ASSERT_RETURN(urid != 0,);
//CARLA_SAFE_ASSERT_RETURN(urid != 0,);
CARLA_SAFE_ASSERT_RETURN(uri != nullptr && uri[0] != '\0',);
carla_debug("osc_send_lv2_urid_map(path:\"%s\", %u, \"%s\")", oscData.path, urid, uri);



+ 6
- 0
source/utils/LinkedList.hpp View File

@@ -101,6 +101,12 @@ public:
return fData->value;
}

void setValue(const T& value) noexcept
{
fData = list_entry(fEntry, Data, siblings);
fData->value = value;
}

private:
Data* fData;
k_list_head* fEntry;


Loading…
Cancel
Save