diff --git a/source/backend/plugin/CarlaPlugin.cpp b/source/backend/plugin/CarlaPlugin.cpp index 1bb0644da..9d7eb78c9 100644 --- a/source/backend/plugin/CarlaPlugin.cpp +++ b/source/backend/plugin/CarlaPlugin.cpp @@ -1036,6 +1036,8 @@ void CarlaPlugin::setId(const unsigned int newId) void CarlaPlugin::setName(const char* const newName) { + CARLA_ASSERT(newName != nullptr); + fName = newName; } diff --git a/source/backend/plugin/Lv2Plugin.cpp b/source/backend/plugin/Lv2Plugin.cpp index 8eb3f5328..016bf6418 100644 --- a/source/backend/plugin/Lv2Plugin.cpp +++ b/source/backend/plugin/Lv2Plugin.cpp @@ -15,9 +15,9 @@ * For a full copy of the GNU General Public License see the GPL.txt file */ +#define WANT_LV2 #include "CarlaPluginInternal.hpp" -#define WANT_LV2 #ifdef WANT_LV2 #include "CarlaPluginGui.hpp" @@ -587,9 +587,9 @@ public: { CARLA_ASSERT(fRdfDescriptor != nullptr); - uint32_t i, count = 0; + uint32_t count = 0; - for (i=0; i < fRdfDescriptor->PortCount; ++i) + for (uint32_t i=0; i < fRdfDescriptor->PortCount; ++i) { const LV2_Property portTypes(fRdfDescriptor->Ports[i].Types); @@ -604,9 +604,9 @@ public: { CARLA_ASSERT(fRdfDescriptor != nullptr); - uint32_t i, count = 0; + uint32_t count = 0; - for (i=0; i < fRdfDescriptor->PortCount; ++i) + for (uint32_t i=0; i < fRdfDescriptor->PortCount; ++i) { const LV2_Property portTypes(fRdfDescriptor->Ports[i].Types); @@ -643,11 +643,13 @@ public: unsigned int availableOptions() override { + const uint32_t hasMidiIn(midiInCount() > 0); + unsigned int options = 0x0; options |= PLUGIN_OPTION_MAP_PROGRAM_CHANGES; - if (midiInCount() == 0 || ! needsFixedBuffer()) + if (! (hasMidiIn || needsFixedBuffer())) options |= PLUGIN_OPTION_FIXED_BUFFER; if (kData->engine->getProccessMode() != PROCESS_MODE_CONTINUOUS_RACK) @@ -658,7 +660,7 @@ public: options |= PLUGIN_OPTION_FORCE_STEREO; } - if (midiInCount() > 0) + if (hasMidiIn) { options |= PLUGIN_OPTION_SEND_CONTROL_CHANGES; options |= PLUGIN_OPTION_SEND_CHANNEL_PRESSURE; @@ -765,7 +767,7 @@ public: const int32_t rindex(kData->param.data[parameterId].rindex); if (rindex < static_cast(fRdfDescriptor->PortCount)) - strncpy(strBuf, fRdfDescriptor->Ports[rindex].Symbol, STR_MAX); + std::strncpy(strBuf, fRdfDescriptor->Ports[rindex].Symbol, STR_MAX); else CarlaPlugin::getParameterSymbol(parameterId, strBuf); } @@ -781,9 +783,11 @@ public: { const LV2_RDF_Port& port(fRdfDescriptor->Ports[rindex]); - if (LV2_HAVE_PORT_UNIT_SYMBOL(port.Unit.Hints) && port.Unit.Symbol) + if (LV2_HAVE_PORT_UNIT_SYMBOL(port.Unit.Hints) && port.Unit.Symbol != nullptr) + { std::strncpy(strBuf, port.Unit.Symbol, STR_MAX); - + return; + } else if (LV2_HAVE_PORT_UNIT_UNIT(port.Unit.Hints)) { switch (port.Unit.Unit) @@ -966,6 +970,8 @@ public: CarlaPlugin::setCustomData(type, key, value, sendGui); + // FIXME - we should only call this once, after all data is stored + if (fExt.state != nullptr) { LV2_State_Status status; @@ -1025,10 +1031,10 @@ public: if (index >= 0 && index < static_cast(fRdfDescriptor->PresetCount)) { - const ScopedDisabler sd(this); - - if (const LilvState* state = gLv2World.getState(fRdfDescriptor->Presets[index].URI, (LV2_URID_Map*)fFeatures[kFeatureIdUridMap]->data)) + if (const LilvState* state = gLv2World.getState(fRdfDescriptor->Presets[index].URI, (const LV2_URID_Map*)fFeatures[kFeatureIdUridMap]->data)) { + const ScopedDisabler sd(this); + lilv_state_restore(state, fExt.state, fHandle, carla_lilv_set_port_value, this, 0, fFeatures); if (fHandle2 != nullptr) @@ -1052,8 +1058,8 @@ public: if (index >= 0 && fExt.programs != nullptr && fExt.programs->select_program != nullptr) { - const uint32_t bank = kData->midiprog.data[index].bank; - const uint32_t program = kData->midiprog.data[index].program; + const uint32_t bank(kData->midiprog.data[index].bank); + const uint32_t program(kData->midiprog.data[index].program); const ScopedSingleProcessLocker spl(this, (sendGui || sendOsc || sendCallback)); @@ -1126,11 +1132,12 @@ public: { if (yesNo) { - fUi.widget = nullptr; - if (fUi.handle == nullptr) + { + fUi.widget = nullptr; fUi.handle = fUi.descriptor->instantiate(fUi.descriptor, fRdfDescriptor->URI, fUi.rdfDescriptor->Bundle, carla_lv2_ui_write_function, this, &fUi.widget, fFeatures); + } CARLA_ASSERT(fUi.handle != nullptr); CARLA_ASSERT(fUi.widget != nullptr); @@ -1180,11 +1187,12 @@ public: fFeatures[kFeatureIdUiParent]->URI = LV2_UI__parent; } - fUi.widget = nullptr; - if (fUi.handle == nullptr) + { + fUi.widget = nullptr; fUi.handle = fUi.descriptor->instantiate(fUi.descriptor, fRdfDescriptor->URI, fUi.rdfDescriptor->Bundle, carla_lv2_ui_write_function, this, &fUi.widget, fFeatures); + } CARLA_ASSERT(fUi.handle != nullptr); CARLA_ASSERT(fUi.widget != nullptr); @@ -1313,7 +1321,7 @@ public: uint32_t aIns, aOuts, cvIns, cvOuts, params, j; aIns = aOuts = cvIns = cvOuts = params = 0; - NonRtList evIns, evOuts; + NonRtList evIns, evOuts; bool forcedStereoIn, forcedStereoOut; forcedStereoIn = forcedStereoOut = false; @@ -1644,7 +1652,7 @@ public: } } else - carla_stderr("WARNING - Got a broken Port (Atom Sequence, but not input or output)"); + carla_stderr("WARNING - Got a broken Port (Atom-Sequence, but not input or output)"); } else if (LV2_IS_PORT_EVENT(portTypes)) { @@ -1910,7 +1918,7 @@ public: } else { - kData->param.data[j].type = PARAMETER_INPUT; + kData->param.data[j].type = PARAMETER_INPUT; kData->param.data[j].hints |= PARAMETER_IS_ENABLED; kData->param.data[j].hints |= PARAMETER_IS_AUTOMABLE; needsCtrlIn = true; @@ -1918,6 +1926,7 @@ public: // MIDI CC value const LV2_RDF_PortMidiMap& portMidiMap(fRdfDescriptor->Ports[i].MidiMap); + if (LV2_IS_PORT_MIDI_MAP_CC(portMidiMap.Type)) { if (! MIDI_IS_CONTROL_BANK_SELECT(portMidiMap.Number)) @@ -1936,7 +1945,7 @@ public: stepLarge = 1.0f; kData->param.data[j].type = PARAMETER_LATENCY; - kData->param.data[j].hints = 0; + kData->param.data[j].hints = 0x0; } else if (LV2_IS_PORT_DESIGNATION_SAMPLE_RATE(portDesignation)) { @@ -1946,7 +1955,7 @@ public: stepLarge = 1.0f; kData->param.data[j].type = PARAMETER_SAMPLE_RATE; - kData->param.data[j].hints = 0; + kData->param.data[j].hints = 0x0; } else if (LV2_IS_PORT_DESIGNATION_FREEWHEELING(portDesignation)) { @@ -1985,9 +1994,10 @@ public: // check if parameter is not enabled or automable if (LV2_IS_PORT_NOT_ON_GUI(portProps)) - kData->param.data[j].hints &= ~PARAMETER_IS_ENABLED; - - if (LV2_IS_PORT_CAUSES_ARTIFACTS(portProps) || LV2_IS_PORT_EXPENSIVE(portProps) || LV2_IS_PORT_NOT_AUTOMATIC(portProps)) + { + kData->param.data[j].hints &= ~(PARAMETER_IS_ENABLED|PARAMETER_IS_AUTOMABLE); + } + else if (LV2_IS_PORT_CAUSES_ARTIFACTS(portProps) || LV2_IS_PORT_EXPENSIVE(portProps) || LV2_IS_PORT_NOT_AUTOMATIC(portProps)) kData->param.data[j].hints &= ~PARAMETER_IS_AUTOMABLE; kData->param.ranges[j].min = min; @@ -1997,11 +2007,11 @@ public: kData->param.ranges[j].stepSmall = stepSmall; kData->param.ranges[j].stepLarge = stepLarge; + // Start parameters in their default values + fParamBuffers[j] = def; + if (kData->param.data[j].type != PARAMETER_LV2_FREEWHEEL) { - // Start parameters in their default values - fParamBuffers[j] = def; - fDescriptor->connect_port(fHandle, i, &fParamBuffers[j]); if (fHandle2 != nullptr) @@ -2132,7 +2142,7 @@ public: { kData->prog.clear(); - uint32_t count = fRdfDescriptor->PresetCount; + const uint32_t count(fRdfDescriptor->PresetCount); if (count > 0) { @@ -2151,7 +2161,7 @@ public: if (fExt.programs != nullptr && fExt.programs->get_program != nullptr && fExt.programs->select_program != nullptr) { while (fExt.programs->get_program(fHandle, count)) - count++; + ++count; } if (count > 0) @@ -2191,7 +2201,7 @@ public: else { // load default state - if (const LilvState* state = gLv2World.getState(fDescriptor->URI, (LV2_URID_Map*)fFeatures[kFeatureIdUridMap]->data)) + if (const LilvState* state = gLv2World.getState(fDescriptor->URI, (const LV2_URID_Map*)fFeatures[kFeatureIdUridMap]->data)) { lilv_state_restore(state, fExt.state, fHandle, carla_lilv_set_port_value, this, 0, fFeatures); diff --git a/source/libs/lilv/lilv-0.16.0/lilv/lilv.h b/source/libs/lilv/lilv-0.16.0/lilv/lilv.h index f69ba3a40..d05aa8958 100644 --- a/source/libs/lilv/lilv-0.16.0/lilv/lilv.h +++ b/source/libs/lilv/lilv-0.16.0/lilv/lilv.h @@ -1215,9 +1215,9 @@ lilv_port_get_scale_points(const LilvPlugin* plugin, */ LILV_API LilvState* -lilv_state_new_from_world(LilvWorld* world, - LV2_URID_Map* map, - const LilvNode* subject); +lilv_state_new_from_world(LilvWorld* world, + const LV2_URID_Map* map, + const LilvNode* subject); /** Load a state snapshot from a file. @@ -1234,19 +1234,19 @@ lilv_state_new_from_world(LilvWorld* world, */ LILV_API LilvState* -lilv_state_new_from_file(LilvWorld* world, - LV2_URID_Map* map, - const LilvNode* subject, - const char* path); +lilv_state_new_from_file(LilvWorld* world, + const LV2_URID_Map* map, + const LilvNode* subject, + const char* path); /** Load a state snapshot from a string made by lilv_state_to_string(). */ LILV_API LilvState* -lilv_state_new_from_string(LilvWorld* world, - LV2_URID_Map* map, - const char* str); +lilv_state_new_from_string(LilvWorld* world, + const LV2_URID_Map* map, + const char* str); /** Function to get a port value. diff --git a/source/libs/lilv/lilv-0.16.0/src/state.c b/source/libs/lilv/lilv-0.16.0/src/state.c index 6282caaaf..d7db16f07 100644 --- a/source/libs/lilv/lilv-0.16.0/src/state.c +++ b/source/libs/lilv/lilv-0.16.0/src/state.c @@ -555,9 +555,9 @@ new_state_from_model(LilvWorld* world, LILV_API LilvState* -lilv_state_new_from_world(LilvWorld* world, - LV2_URID_Map* map, - const LilvNode* node) +lilv_state_new_from_world(LilvWorld* world, + const LV2_URID_Map* map, + const LilvNode* node) { if (!lilv_node_is_uri(node) && !lilv_node_is_blank(node)) { LILV_ERRORF("Subject `%s' is not a URI or blank node.\n", @@ -573,10 +573,10 @@ lilv_state_new_from_world(LilvWorld* world, LILV_API LilvState* -lilv_state_new_from_file(LilvWorld* world, - LV2_URID_Map* map, - const LilvNode* subject, - const char* path) +lilv_state_new_from_file(LilvWorld* world, + const LV2_URID_Map* map, + const LilvNode* subject, + const char* path) { if (subject && !lilv_node_is_uri(subject) && !lilv_node_is_blank(subject)) { @@ -627,9 +627,9 @@ set_prefixes(SerdEnv* env) LILV_API LilvState* -lilv_state_new_from_string(LilvWorld* world, - LV2_URID_Map* map, - const char* str) +lilv_state_new_from_string(LilvWorld* world, + const LV2_URID_Map* map, + const char* str) { if (!str) { return NULL; diff --git a/source/utils/CarlaJuceUtils.hpp b/source/utils/CarlaJuceUtils.hpp index 22090b88b..bf7cbffe5 100644 --- a/source/utils/CarlaJuceUtils.hpp +++ b/source/utils/CarlaJuceUtils.hpp @@ -331,7 +331,8 @@ private: It's probably best to use the latter form when writing your object declarations anyway, as this is a better representation of the code that you actually want the compiler to produce. */ - CARLA_DECLARE_NON_COPYABLE(ScopedPointer) + ScopedPointer(const ScopedPointer&); + ScopedPointer& operator=(const ScopedPointer&); #endif }; diff --git a/source/utils/CarlaLv2Utils.hpp b/source/utils/CarlaLv2Utils.hpp index 7ed7695f7..aa474af81 100644 --- a/source/utils/CarlaLv2Utils.hpp +++ b/source/utils/CarlaLv2Utils.hpp @@ -378,7 +378,7 @@ public: } } - const LilvState* getState(const LV2_URI uri, LV2_URID_Map* const uridMap) + const LilvState* getState(const LV2_URI uri, const LV2_URID_Map* const uridMap) { CARLA_ASSERT(uri != nullptr);