From 0514349938fd7cc1cdfc23e9aee34d8184cd0d04 Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 25 Mar 2019 17:58:26 +0100 Subject: [PATCH] Expose inline display on internal plugins; 2.0 Backwards compat fix Signed-off-by: falkTX --- source/backend/engine/CarlaEngineNative.cpp | 24 +++++++++++++++------ source/backend/plugin/CarlaPluginNative.cpp | 22 ++++++++----------- source/includes/CarlaNative.h | 18 +++++++++++++--- source/includes/CarlaNative.hpp | 21 ++++++++++++++++-- source/native-plugins/_data.cpp | 5 +++-- source/native-plugins/bigmeter.cpp | 1 + source/native-plugins/bypass.c | 4 +++- source/native-plugins/lfo.c | 4 +++- source/native-plugins/midi-channel-ab.c | 6 ++++-- source/native-plugins/midi-channel-filter.c | 4 +++- source/native-plugins/midi-channelize.c | 4 +++- source/native-plugins/midi-gain.c | 4 +++- source/native-plugins/midi-join.c | 4 +++- source/native-plugins/midi-split.c | 4 +++- source/native-plugins/midi-through.c | 4 +++- source/native-plugins/midi-transpose.c | 4 +++- source/plugin/carla-lv2-export.cpp | 1 - source/plugin/carla-lv2.cpp | 8 ++++++- source/plugin/carla-native-plugin.cpp | 1 - source/plugin/carla-vst.cpp | 15 +++++++------ 20 files changed, 110 insertions(+), 48 deletions(-) diff --git a/source/backend/engine/CarlaEngineNative.cpp b/source/backend/engine/CarlaEngineNative.cpp index cc0ac48527..35f93a7533 100644 --- a/source/backend/engine/CarlaEngineNative.cpp +++ b/source/backend/engine/CarlaEngineNative.cpp @@ -352,7 +352,11 @@ class CarlaEngineNative : public CarlaEngine if (pluginId != 0) return; - pHost->ui_parameter_touch(pHost->handle, index, touch); + pHost->dispatcher(pHost->handle, + NATIVE_HOST_OPCODE_UI_TOUCH_PARAMETER, + static_cast(index), + touch ? 1 : 0, + nullptr, 0.0f); } void reloadFromUI() @@ -2338,7 +2342,8 @@ static const NativePluginDescriptor carlaRackDesc = { CarlaEngineNative::_process, CarlaEngineNative::_get_state, CarlaEngineNative::_set_state, - CarlaEngineNative::_dispatcher + CarlaEngineNative::_dispatcher, + /* _render_inline_dsplay */ nullptr }; static const NativePluginDescriptor carlaRackNoMidiOutDesc = { @@ -2379,7 +2384,8 @@ static const NativePluginDescriptor carlaRackNoMidiOutDesc = { CarlaEngineNative::_process, CarlaEngineNative::_get_state, CarlaEngineNative::_set_state, - CarlaEngineNative::_dispatcher + CarlaEngineNative::_dispatcher, + /* _render_inline_dsplay */ nullptr }; static const NativePluginDescriptor carlaPatchbayDesc = { @@ -2420,7 +2426,8 @@ static const NativePluginDescriptor carlaPatchbayDesc = { CarlaEngineNative::_process, CarlaEngineNative::_get_state, CarlaEngineNative::_set_state, - CarlaEngineNative::_dispatcher + CarlaEngineNative::_dispatcher, + /* _render_inline_dsplay */ nullptr }; static const NativePluginDescriptor carlaPatchbay3sDesc = { @@ -2461,7 +2468,8 @@ static const NativePluginDescriptor carlaPatchbay3sDesc = { CarlaEngineNative::_process, CarlaEngineNative::_get_state, CarlaEngineNative::_set_state, - CarlaEngineNative::_dispatcher + CarlaEngineNative::_dispatcher, + /* _render_inline_dsplay */ nullptr }; static const NativePluginDescriptor carlaPatchbay16Desc = { @@ -2502,7 +2510,8 @@ static const NativePluginDescriptor carlaPatchbay16Desc = { CarlaEngineNative::_process, CarlaEngineNative::_get_state, CarlaEngineNative::_set_state, - CarlaEngineNative::_dispatcher + CarlaEngineNative::_dispatcher, + /* _render_inline_dsplay */ nullptr }; static const NativePluginDescriptor carlaPatchbay32Desc = { @@ -2543,7 +2552,8 @@ static const NativePluginDescriptor carlaPatchbay32Desc = { CarlaEngineNative::_process, CarlaEngineNative::_get_state, CarlaEngineNative::_set_state, - CarlaEngineNative::_dispatcher + CarlaEngineNative::_dispatcher, + /* _render_inline_dsplay */ nullptr }; CARLA_BACKEND_END_NAMESPACE diff --git a/source/backend/plugin/CarlaPluginNative.cpp b/source/backend/plugin/CarlaPluginNative.cpp index ccad7fa62e..681867accf 100644 --- a/source/backend/plugin/CarlaPluginNative.cpp +++ b/source/backend/plugin/CarlaPluginNative.cpp @@ -251,6 +251,7 @@ class CarlaPluginNative : public CarlaPlugin fIsOffline(false), fIsUiAvailable(false), fIsUiVisible(false), + fInlineDisplayNeedsRedraw(false), fAudioInBuffers(nullptr), fAudioOutBuffers(nullptr), fMidiEventInCount(0), @@ -279,7 +280,6 @@ class CarlaPluginNative : public CarlaPlugin fHost.get_time_info = carla_host_get_time_info; fHost.write_midi_event = carla_host_write_midi_event; fHost.ui_parameter_changed = carla_host_ui_parameter_changed; - fHost.ui_parameter_touch = carla_host_ui_parameter_touch; fHost.ui_custom_data_changed = carla_host_ui_custom_data_changed; fHost.ui_closed = carla_host_ui_closed; fHost.ui_open_file = carla_host_ui_open_file; @@ -2394,11 +2394,6 @@ class CarlaPluginNative : public CarlaPlugin setParameterValue(index, value, false, true, true); } - void handleUiParameterTouch(const uint32_t index, const bool touch) const - { - pData->engine->touchPluginParameter(pData->id, index, touch); - } - void handleUiCustomDataChanged(const char* const key, const char* const value) { setCustomData(CUSTOM_DATA_TYPE_STRING, key, value, false); @@ -2460,13 +2455,18 @@ class CarlaPluginNative : public CarlaPlugin case NATIVE_HOST_OPCODE_INTERNAL_PLUGIN: ret = 1; break; + case NATIVE_HOST_OPCODE_QUEUE_INLINE_DISPLAY: + fInlineDisplayNeedsRedraw = true; + break; + case NATIVE_HOST_OPCODE_UI_TOUCH_PARAMETER: + CARLA_SAFE_ASSERT_RETURN(index >= 0, 0); + pData->engine->touchPluginParameter(pData->id, static_cast(index), value != 0); + break; } return ret; // unused for now - (void)index; - (void)value; (void)ptr; (void)opt; } @@ -2651,6 +2651,7 @@ class CarlaPluginNative : public CarlaPlugin bool fIsOffline; bool fIsUiAvailable; bool fIsUiVisible; + bool fInlineDisplayNeedsRedraw; float** fAudioInBuffers; float** fAudioOutBuffers; @@ -2702,11 +2703,6 @@ class CarlaPluginNative : public CarlaPlugin handlePtr->handleUiParameterChanged(index, value); } - static void carla_host_ui_parameter_touch(NativeHostHandle handle, uint32_t index, bool touch) - { - handlePtr->handleUiParameterTouch(index, touch); - } - static void carla_host_ui_custom_data_changed(NativeHostHandle handle, const char* key, const char* value) { handlePtr->handleUiCustomDataChanged(key, value); diff --git a/source/includes/CarlaNative.h b/source/includes/CarlaNative.h index fb79b9b90f..63f498887e 100644 --- a/source/includes/CarlaNative.h +++ b/source/includes/CarlaNative.h @@ -63,7 +63,8 @@ typedef enum { NATIVE_PLUGIN_USES_PANNING = 1 << 8, /** uses stereo balance if unset (default) */ NATIVE_PLUGIN_USES_STATE = 1 << 9, NATIVE_PLUGIN_USES_TIME = 1 << 10, - NATIVE_PLUGIN_USES_PARENT_ID = 1 << 11 /** can set transient hint to parent */ + NATIVE_PLUGIN_USES_PARENT_ID = 1 << 11, /** can set transient hint to parent */ + NATIVE_PLUGIN_HAS_INLINE_DISPLAY = 1 << 12 } NativePluginHints; typedef enum { @@ -106,7 +107,9 @@ typedef enum { NATIVE_HOST_OPCODE_RELOAD_ALL = 5, /** nothing */ NATIVE_HOST_OPCODE_UI_UNAVAILABLE = 6, /** nothing */ NATIVE_HOST_OPCODE_HOST_IDLE = 7, /** nothing */ - NATIVE_HOST_OPCODE_INTERNAL_PLUGIN = 8 /** nothing */ + NATIVE_HOST_OPCODE_INTERNAL_PLUGIN = 8, /** nothing */ + NATIVE_HOST_OPCODE_QUEUE_INLINE_DISPLAY = 9, /** nothing */ + NATIVE_HOST_OPCODE_UI_TOUCH_PARAMETER = 10 /** uses index, value as bool */ } NativeHostDispatcherOpcode; /* ------------------------------------------------------------------------------------------------------------ @@ -175,6 +178,13 @@ typedef struct { NativeTimeInfoBBT bbt; } NativeTimeInfo; +typedef struct { + unsigned char* data; + int width; + int height; + int stride; +} NativeInlineDisplayImageSurface; + /* ------------------------------------------------------------------------------------------------------------ * HostDescriptor */ @@ -192,7 +202,6 @@ typedef struct { bool (*write_midi_event)(NativeHostHandle handle, const NativeMidiEvent* event); void (*ui_parameter_changed)(NativeHostHandle handle, uint32_t index, float value); - void (*ui_parameter_touch)(NativeHostHandle handle, uint32_t index, bool touch); void (*ui_midi_program_changed)(NativeHostHandle handle, uint8_t channel, uint32_t bank, uint32_t program); void (*ui_custom_data_changed)(NativeHostHandle handle, const char* key, const char* value); void (*ui_closed)(NativeHostHandle handle); @@ -256,6 +265,9 @@ typedef struct _NativePluginDescriptor { intptr_t (*dispatcher)(NativePluginHandle handle, NativePluginDispatcherOpcode opcode, int32_t index, intptr_t value, void* ptr, float opt); + const NativeInlineDisplayImageSurface* (*render_inline_display)(NativePluginHandle handle, + uint32_t width, uint32_t height); + } NativePluginDescriptor; /* ------------------------------------------------------------------------------------------------------------ diff --git a/source/includes/CarlaNative.hpp b/source/includes/CarlaNative.hpp index 0fb0f6de47..7bb0d82832 100644 --- a/source/includes/CarlaNative.hpp +++ b/source/includes/CarlaNative.hpp @@ -117,7 +117,11 @@ class NativePluginClass { CARLA_SAFE_ASSERT_RETURN(pHost != nullptr,); - pHost->ui_parameter_touch(pHost->handle, index, touch); + pHost->dispatcher(pHost->handle, + NATIVE_HOST_OPCODE_UI_TOUCH_PARAMETER, + static_cast(index), + touch ? 1 : 0, + nullptr, 0.0f); } void uiMidiProgramChanged(const uint8_t channel, const uint32_t bank, const uint32_t program) const @@ -376,6 +380,13 @@ class NativePluginClass CARLA_SAFE_ASSERT_RETURN(uiName != nullptr && uiName[0] != '\0',); } + virtual const NativeInlineDisplayImageSurface* renderInlineDisplay(const uint32_t width, const uint32_t height) + { + CARLA_SAFE_ASSERT_RETURN(width > 0 && height > 0, nullptr); + + return nullptr; + } + // ------------------------------------------------------------------- private: @@ -511,6 +522,11 @@ class NativePluginClass (void)index; } + static const NativeInlineDisplayImageSurface* _render_inline_display(NativePluginHandle handle, uint32_t width, uint32_t height) + { + return handlePtr->renderInlineDisplay(width, height); + } + #undef handlePtr CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(NativePluginClass) @@ -553,7 +569,8 @@ public: \ ClassName::_process, \ ClassName::_get_state, \ ClassName::_set_state, \ - ClassName::_dispatcher + ClassName::_dispatcher, \ + ClassName::_render_inline_display // ----------------------------------------------------------------------- diff --git a/source/native-plugins/_data.cpp b/source/native-plugins/_data.cpp index 12d69d3428..23da94f707 100644 --- a/source/native-plugins/_data.cpp +++ b/source/native-plugins/_data.cpp @@ -1,6 +1,6 @@ /* * Carla Native Plugins - * Copyright (C) 2012-2018 Filipe Coelho + * Copyright (C) 2012-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 @@ -24,7 +24,8 @@ nullptr, nullptr, nullptr, nullptr, nullptr, \ nullptr, nullptr, nullptr, nullptr, nullptr, \ nullptr, nullptr, nullptr, nullptr, nullptr, \ - nullptr, nullptr, nullptr, nullptr, nullptr, nullptr + nullptr, nullptr, nullptr, nullptr, nullptr, \ + nullptr, nullptr static const NativePluginDescriptor sNativePluginDescriptors[] = { diff --git a/source/native-plugins/bigmeter.cpp b/source/native-plugins/bigmeter.cpp index aa79319f76..4f3d70eda5 100644 --- a/source/native-plugins/bigmeter.cpp +++ b/source/native-plugins/bigmeter.cpp @@ -174,6 +174,7 @@ class BigMeterPlugin : public NativePluginAndUiClass static const NativePluginDescriptor bigmeterDesc = { /* category */ NATIVE_PLUGIN_CATEGORY_UTILITY, /* hints */ static_cast(NATIVE_PLUGIN_IS_RTSAFE + |NATIVE_PLUGIN_HAS_INLINE_DISPLAY |NATIVE_PLUGIN_HAS_UI |NATIVE_PLUGIN_NEEDS_FIXED_BUFFERS), /* supports */ NATIVE_PLUGIN_SUPPORTS_NOTHING, diff --git a/source/native-plugins/bypass.c b/source/native-plugins/bypass.c index 8c78f9382f..aabd5370ec 100644 --- a/source/native-plugins/bypass.c +++ b/source/native-plugins/bypass.c @@ -89,7 +89,9 @@ static const NativePluginDescriptor bypassDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL + .dispatcher = NULL, + + .render_inline_display = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/lfo.c b/source/native-plugins/lfo.c index 6c947f52de..f3d39f4b15 100644 --- a/source/native-plugins/lfo.c +++ b/source/native-plugins/lfo.c @@ -309,7 +309,9 @@ static const NativePluginDescriptor lfoDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL + .dispatcher = NULL, + + .render_inline_display = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-channel-ab.c b/source/native-plugins/midi-channel-ab.c index 6ebe92c1fb..bb8c4a4f0d 100644 --- a/source/native-plugins/midi-channel-ab.c +++ b/source/native-plugins/midi-channel-ab.c @@ -1,6 +1,6 @@ /* * Carla Native Plugins - * Copyright (C) 2012-2018 Filipe Coelho + * Copyright (C) 2012-2019 Filipe Coelho * Copyright (C) 2018 Milk Brewster * * This program is free software; you can redistribute it and/or @@ -198,7 +198,9 @@ static const NativePluginDescriptor midichanabDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL + .dispatcher = NULL, + + .render_inline_display = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-channel-filter.c b/source/native-plugins/midi-channel-filter.c index 4f522ddad3..2d66053a37 100644 --- a/source/native-plugins/midi-channel-filter.c +++ b/source/native-plugins/midi-channel-filter.c @@ -189,7 +189,9 @@ static const NativePluginDescriptor midichanfilterDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL + .dispatcher = NULL, + + .render_inline_display = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-channelize.c b/source/native-plugins/midi-channelize.c index 511aa4751e..bc993c72be 100644 --- a/source/native-plugins/midi-channelize.c +++ b/source/native-plugins/midi-channelize.c @@ -197,7 +197,9 @@ static const NativePluginDescriptor midichannelizeDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL + .dispatcher = NULL, + + .render_inline_display = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-gain.c b/source/native-plugins/midi-gain.c index cb2951ab78..0ef3ca8a87 100644 --- a/source/native-plugins/midi-gain.c +++ b/source/native-plugins/midi-gain.c @@ -259,7 +259,9 @@ static const NativePluginDescriptor midigainDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL + .dispatcher = NULL, + + .render_inline_display = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-join.c b/source/native-plugins/midi-join.c index e105424337..df44e89e86 100644 --- a/source/native-plugins/midi-join.c +++ b/source/native-plugins/midi-join.c @@ -136,7 +136,9 @@ static const NativePluginDescriptor midijoinDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL + .dispatcher = NULL, + + .render_inline_display = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-split.c b/source/native-plugins/midi-split.c index c3c786c4e4..2ccb80e60e 100644 --- a/source/native-plugins/midi-split.c +++ b/source/native-plugins/midi-split.c @@ -129,7 +129,9 @@ static const NativePluginDescriptor midisplitDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL + .dispatcher = NULL, + + .render_inline_display = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-through.c b/source/native-plugins/midi-through.c index ea3f86f96d..4f3a334855 100644 --- a/source/native-plugins/midi-through.c +++ b/source/native-plugins/midi-through.c @@ -110,7 +110,9 @@ static const NativePluginDescriptor midithroughDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL + .dispatcher = NULL, + + .render_inline_display = NULL }; // ----------------------------------------------------------------------- diff --git a/source/native-plugins/midi-transpose.c b/source/native-plugins/midi-transpose.c index dd8ec5010a..bf10eb3262 100644 --- a/source/native-plugins/midi-transpose.c +++ b/source/native-plugins/midi-transpose.c @@ -222,7 +222,9 @@ static const NativePluginDescriptor miditransposeDesc = { .get_state = NULL, .set_state = NULL, - .dispatcher = NULL + .dispatcher = NULL, + + .render_inline_display = NULL }; // ----------------------------------------------------------------------- diff --git a/source/plugin/carla-lv2-export.cpp b/source/plugin/carla-lv2-export.cpp index ed38ccdc67..e6de2eb26e 100644 --- a/source/plugin/carla-lv2-export.cpp +++ b/source/plugin/carla-lv2-export.cpp @@ -198,7 +198,6 @@ static void writePluginFile(const NativePluginDescriptor* const pluginDesc) hostDesc.get_time_info = nullptr; hostDesc.write_midi_event = nullptr; hostDesc.ui_parameter_changed = nullptr; - hostDesc.ui_parameter_touch = nullptr; hostDesc.ui_midi_program_changed = nullptr; hostDesc.ui_custom_data_changed = nullptr; hostDesc.ui_closed = nullptr; diff --git a/source/plugin/carla-lv2.cpp b/source/plugin/carla-lv2.cpp index e513bd636b..65fec79ba6 100644 --- a/source/plugin/carla-lv2.cpp +++ b/source/plugin/carla-lv2.cpp @@ -94,7 +94,6 @@ class NativePlugin : public Lv2PluginBaseClass fHost.get_time_info = host_get_time_info; fHost.write_midi_event = host_write_midi_event; fHost.ui_parameter_changed = host_ui_parameter_changed; - fHost.ui_parameter_touch = host_ui_parameter_touch; fHost.ui_custom_data_changed = host_ui_custom_data_changed; fHost.ui_closed = host_ui_closed; fHost.ui_open_file = host_ui_open_file; @@ -713,11 +712,18 @@ class NativePlugin : public Lv2PluginBaseClass 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: // nothing break; + case NATIVE_HOST_OPCODE_UI_UNAVAILABLE: handleUiClosed(); break; + + case NATIVE_HOST_OPCODE_UI_TOUCH_PARAMETER: + CARLA_SAFE_ASSERT_RETURN(index >= 0, 0); + handleUiParameterTouch(static_cast(index), value != 0); + break; } return ret; diff --git a/source/plugin/carla-native-plugin.cpp b/source/plugin/carla-native-plugin.cpp index 474c895722..8f5077a6b8 100644 --- a/source/plugin/carla-native-plugin.cpp +++ b/source/plugin/carla-native-plugin.cpp @@ -81,7 +81,6 @@ int main() nullptr, // write_midi_event nullptr, // ui_parameter_changed - nullptr, // ui_parameter_touch nullptr, // ui_midi_program_changed nullptr, // ui_custom_data_changed nullptr, // ui_closed diff --git a/source/plugin/carla-vst.cpp b/source/plugin/carla-vst.cpp index 9d21d32212..fa7b740870 100644 --- a/source/plugin/carla-vst.cpp +++ b/source/plugin/carla-vst.cpp @@ -131,7 +131,6 @@ class NativePlugin fHost.get_time_info = host_get_time_info; fHost.write_midi_event = host_write_midi_event; fHost.ui_parameter_changed = host_ui_parameter_changed; - fHost.ui_parameter_touch = host_ui_parameter_touch; fHost.ui_custom_data_changed = host_ui_custom_data_changed; fHost.ui_closed = host_ui_closed; fHost.ui_open_file = host_ui_open_file; @@ -761,6 +760,8 @@ class NativePlugin case NATIVE_HOST_OPCODE_RELOAD_MIDI_PROGRAMS: case NATIVE_HOST_OPCODE_UI_UNAVAILABLE: case NATIVE_HOST_OPCODE_INTERNAL_PLUGIN: + case NATIVE_HOST_OPCODE_QUEUE_INLINE_DISPLAY: + // nothing break; case NATIVE_HOST_OPCODE_RELOAD_ALL: @@ -770,12 +771,17 @@ class NativePlugin case NATIVE_HOST_OPCODE_HOST_IDLE: hostCallback(audioMasterIdle); break; + + case NATIVE_HOST_OPCODE_UI_TOUCH_PARAMETER: + CARLA_SAFE_ASSERT_RETURN(index >= 0, 0); + handleUiParameterTouch(static_cast(index), value != 0); + break; } // unused for now return 0; - (void)index; (void)value; (void)ptr; (void)opt; + (void)ptr; (void)opt; } private: @@ -879,11 +885,6 @@ class NativePlugin handlePtr->handleUiParameterChanged(index, value); } - static void host_ui_parameter_touch(NativeHostHandle handle, uint32_t index, bool touch) - { - handlePtr->handleUiParameterTouch(index, touch); - } - static void host_ui_custom_data_changed(NativeHostHandle handle, const char* key, const char* value) { handlePtr->handleUiCustomDataChanged(key, value);