Skip to content

Commit

Permalink
Expose inline display on internal plugins; 2.0 Backwards compat fix
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Mar 25, 2019
1 parent b3af597 commit 0514349
Show file tree
Hide file tree
Showing 20 changed files with 110 additions and 48 deletions.
24 changes: 17 additions & 7 deletions source/backend/engine/CarlaEngineNative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int32_t>(index),
touch ? 1 : 0,
nullptr, 0.0f);
}

void reloadFromUI()
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
Expand Down
22 changes: 9 additions & 13 deletions source/backend/plugin/CarlaPluginNative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class CarlaPluginNative : public CarlaPlugin
fIsOffline(false),
fIsUiAvailable(false),
fIsUiVisible(false),
fInlineDisplayNeedsRedraw(false),
fAudioInBuffers(nullptr),
fAudioOutBuffers(nullptr),
fMidiEventInCount(0),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<uint32_t>(index), value != 0);
break;
}

return ret;

// unused for now
(void)index;
(void)value;
(void)ptr;
(void)opt;
}
Expand Down Expand Up @@ -2651,6 +2651,7 @@ class CarlaPluginNative : public CarlaPlugin
bool fIsOffline;
bool fIsUiAvailable;
bool fIsUiVisible;
bool fInlineDisplayNeedsRedraw;

float** fAudioInBuffers;
float** fAudioOutBuffers;
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 15 additions & 3 deletions source/includes/CarlaNative.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;

/* ------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -175,6 +178,13 @@ typedef struct {
NativeTimeInfoBBT bbt;
} NativeTimeInfo;

typedef struct {
unsigned char* data;
int width;
int height;
int stride;
} NativeInlineDisplayImageSurface;

/* ------------------------------------------------------------------------------------------------------------
* HostDescriptor */

Expand All @@ -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);
Expand Down Expand Up @@ -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;

/* ------------------------------------------------------------------------------------------------------------
Expand Down
21 changes: 19 additions & 2 deletions source/includes/CarlaNative.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int32_t>(index),
touch ? 1 : 0,
nullptr, 0.0f);
}

void uiMidiProgramChanged(const uint8_t channel, const uint32_t bank, const uint32_t program) const
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -553,7 +569,8 @@ public: \
ClassName::_process, \
ClassName::_get_state, \
ClassName::_set_state, \
ClassName::_dispatcher
ClassName::_dispatcher, \
ClassName::_render_inline_display

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

Expand Down
5 changes: 3 additions & 2 deletions source/native-plugins/_data.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Carla Native Plugins
* Copyright (C) 2012-2018 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2019 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand All @@ -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[] = {

Expand Down
1 change: 1 addition & 0 deletions source/native-plugins/bigmeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class BigMeterPlugin : public NativePluginAndUiClass
static const NativePluginDescriptor bigmeterDesc = {
/* category */ NATIVE_PLUGIN_CATEGORY_UTILITY,
/* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE
|NATIVE_PLUGIN_HAS_INLINE_DISPLAY
|NATIVE_PLUGIN_HAS_UI
|NATIVE_PLUGIN_NEEDS_FIXED_BUFFERS),
/* supports */ NATIVE_PLUGIN_SUPPORTS_NOTHING,
Expand Down
4 changes: 3 additions & 1 deletion source/native-plugins/bypass.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ static const NativePluginDescriptor bypassDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL
.dispatcher = NULL,

.render_inline_display = NULL
};

// -----------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion source/native-plugins/lfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ static const NativePluginDescriptor lfoDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL
.dispatcher = NULL,

.render_inline_display = NULL
};

// -----------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions source/native-plugins/midi-channel-ab.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Carla Native Plugins
* Copyright (C) 2012-2018 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2019 Filipe Coelho <[email protected]>
* Copyright (C) 2018 Milk Brewster <[email protected]>
*
* This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -198,7 +198,9 @@ static const NativePluginDescriptor midichanabDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL
.dispatcher = NULL,

.render_inline_display = NULL
};

// -----------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion source/native-plugins/midi-channel-filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ static const NativePluginDescriptor midichanfilterDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL
.dispatcher = NULL,

.render_inline_display = NULL
};

// -----------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion source/native-plugins/midi-channelize.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ static const NativePluginDescriptor midichannelizeDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL
.dispatcher = NULL,

.render_inline_display = NULL
};

// -----------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion source/native-plugins/midi-gain.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ static const NativePluginDescriptor midigainDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL
.dispatcher = NULL,

.render_inline_display = NULL
};

// -----------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion source/native-plugins/midi-join.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ static const NativePluginDescriptor midijoinDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL
.dispatcher = NULL,

.render_inline_display = NULL
};

// -----------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion source/native-plugins/midi-split.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ static const NativePluginDescriptor midisplitDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL
.dispatcher = NULL,

.render_inline_display = NULL
};

// -----------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion source/native-plugins/midi-through.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ static const NativePluginDescriptor midithroughDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL
.dispatcher = NULL,

.render_inline_display = NULL
};

// -----------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion source/native-plugins/midi-transpose.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ static const NativePluginDescriptor miditransposeDesc = {
.get_state = NULL,
.set_state = NULL,

.dispatcher = NULL
.dispatcher = NULL,

.render_inline_display = NULL
};

// -----------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion source/plugin/carla-lv2-export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 0514349

Please sign in to comment.