get_hostinfo vst3 for the plugin too
This commit is contained in:
parent
2179986eec
commit
04187631ab
@ -166,6 +166,20 @@ static const char * getDatadirCb(void *handle) {
|
|||||||
return datadir;
|
return datadir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void save_host_name(Steinberg_FUnknown *context, char dest[128]) {
|
||||||
|
Steinberg_Vst_IHostApplication *app = (Steinberg_Vst_IHostApplication*) context;
|
||||||
|
Steinberg_Vst_String128 s;
|
||||||
|
app->lpVtbl->getName(app, s);
|
||||||
|
dest[0] = '\0';
|
||||||
|
// Dumb casting from char16 to char8
|
||||||
|
for (int i = 0; i < 128; i++) {
|
||||||
|
dest[i] = s[i];
|
||||||
|
if (!s[i])
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
TRACE("save_host_name, hostName = %s\n", dest);
|
||||||
|
}
|
||||||
|
|
||||||
static double clamp(double x, double m, double M) {
|
static double clamp(double x, double m, double M) {
|
||||||
return x < m ? m : (x > M ? M : x);
|
return x < m ? m : (x > M ? M : x);
|
||||||
}
|
}
|
||||||
@ -308,11 +322,17 @@ typedef struct pluginInstance {
|
|||||||
#endif
|
#endif
|
||||||
void * mem;
|
void * mem;
|
||||||
struct Steinberg_IBStream * state;
|
struct Steinberg_IBStream * state;
|
||||||
|
char hostName[128];
|
||||||
} pluginInstance;
|
} pluginInstance;
|
||||||
|
|
||||||
static Steinberg_Vst_IComponentVtbl pluginVtblIComponent;
|
static Steinberg_Vst_IComponentVtbl pluginVtblIComponent;
|
||||||
static Steinberg_Vst_IAudioProcessorVtbl pluginVtblIAudioProcessor;
|
static Steinberg_Vst_IAudioProcessorVtbl pluginVtblIAudioProcessor;
|
||||||
|
|
||||||
|
const char* getHostinfoCb(void *handle) {
|
||||||
|
pluginInstance *p = (pluginInstance *)handle;
|
||||||
|
return p->hostName;
|
||||||
|
}
|
||||||
|
|
||||||
static void pluginStateLockCb(void *handle) {
|
static void pluginStateLockCb(void *handle) {
|
||||||
pluginInstance *p = (pluginInstance *)handle;
|
pluginInstance *p = (pluginInstance *)handle;
|
||||||
while (atomic_flag_test_and_set(&p->syncLockFlag))
|
while (atomic_flag_test_and_set(&p->syncLockFlag))
|
||||||
@ -414,6 +434,9 @@ static Steinberg_tresult pluginInitialize(void *thisInterface, struct Steinberg_
|
|||||||
if (p->context != NULL)
|
if (p->context != NULL)
|
||||||
return Steinberg_kResultFalse;
|
return Steinberg_kResultFalse;
|
||||||
p->context = context;
|
p->context = context;
|
||||||
|
|
||||||
|
save_host_name(context, p->hostName);
|
||||||
|
|
||||||
p->lastSampleRate = 0.f;
|
p->lastSampleRate = 0.f;
|
||||||
p->curSampleRate = 0.f;
|
p->curSampleRate = 0.f;
|
||||||
p->nextSampleRate = 0.f;
|
p->nextSampleRate = 0.f;
|
||||||
@ -422,7 +445,8 @@ static Steinberg_tresult pluginInitialize(void *thisInterface, struct Steinberg_
|
|||||||
/* .handle = */ (void *)p,
|
/* .handle = */ (void *)p,
|
||||||
/* .format = */ "vst3",
|
/* .format = */ "vst3",
|
||||||
/* .get_bindir = */ getBindirCb,
|
/* .get_bindir = */ getBindirCb,
|
||||||
/* .get_datadir = */ getDatadirCb
|
/* .get_datadir = */ getDatadirCb,
|
||||||
|
/* .get_hostinfo = */ getHostinfoCb
|
||||||
};
|
};
|
||||||
plugin_init(&p->p, &cbs);
|
plugin_init(&p->p, &cbs);
|
||||||
#if DATA_PRODUCT_PARAMETERS_IN_N > 0
|
#if DATA_PRODUCT_PARAMETERS_IN_N > 0
|
||||||
@ -1475,7 +1499,7 @@ static void plugViewTimerCb(HWND p1, UINT p2, UINT_PTR p3, DWORD p4) {
|
|||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
const char* get_hostinfo(void *handle) {
|
const char* UIgetHostinfoCb(void *handle) {
|
||||||
plugView *v = (plugView *)handle;
|
plugView *v = (plugView *)handle;
|
||||||
return v->ctrl->hostName;
|
return v->ctrl->hostName;
|
||||||
}
|
}
|
||||||
@ -1496,7 +1520,7 @@ static Steinberg_tresult plugViewAttached(void* thisInterface, void* parent, Ste
|
|||||||
/* .format = */ "vst3",
|
/* .format = */ "vst3",
|
||||||
/* .get_bindir = */ getBindirCb,
|
/* .get_bindir = */ getBindirCb,
|
||||||
/* .get_datadir = */ getDatadirCb,
|
/* .get_datadir = */ getDatadirCb,
|
||||||
/* .get_hostinfo = */ get_hostinfo,
|
/* .get_hostinfo = */ UIgetHostinfoCb,
|
||||||
# if DATA_PRODUCT_PARAMETERS_N > 0
|
# if DATA_PRODUCT_PARAMETERS_N > 0
|
||||||
/* .set_parameter_begin = */ plugViewSetParameterBeginCb,
|
/* .set_parameter_begin = */ plugViewSetParameterBeginCb,
|
||||||
/* .set_parameter = */ plugViewSetParameterCb,
|
/* .set_parameter = */ plugViewSetParameterCb,
|
||||||
@ -1828,17 +1852,7 @@ static Steinberg_tresult controllerInitialize(void* thisInterface, struct Steinb
|
|||||||
return Steinberg_kResultFalse;
|
return Steinberg_kResultFalse;
|
||||||
c->context = context;
|
c->context = context;
|
||||||
|
|
||||||
Steinberg_Vst_IHostApplication *app = (Steinberg_Vst_IHostApplication*) context;
|
save_host_name(context, c->hostName);
|
||||||
Steinberg_Vst_String128 s;
|
|
||||||
app->lpVtbl->getName(app, s);
|
|
||||||
c->hostName[0] = '\0';
|
|
||||||
// Dumb casting from char16 to char8
|
|
||||||
for (int i = 0; i < 128; i++) {
|
|
||||||
c->hostName[i] = s[i];
|
|
||||||
if (!s[i])
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
TRACE("controller initialize, hostName = %s\n", c->hostName);
|
|
||||||
|
|
||||||
#if DATA_PRODUCT_PARAMETERS_IN_N > 0
|
#if DATA_PRODUCT_PARAMETERS_IN_N > 0
|
||||||
for (int i = 0; i < DATA_PRODUCT_PARAMETERS_IN_N; i++)
|
for (int i = 0; i < DATA_PRODUCT_PARAMETERS_IN_N; i++)
|
||||||
@ -2556,6 +2570,7 @@ static Steinberg_tresult factoryGetClassInfoUnicode(void* thisInterface, Steinbe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// You need this only if you need the hostname (or create host related objects) at factory stage
|
// You need this only if you need the hostname (or create host related objects) at factory stage
|
||||||
|
// I tried and this does not get called consistently
|
||||||
static Steinberg_tresult factorySetHostContext(void* thisInterface, struct Steinberg_FUnknown* context) {
|
static Steinberg_tresult factorySetHostContext(void* thisInterface, struct Steinberg_FUnknown* context) {
|
||||||
(void)thisInterface;
|
(void)thisInterface;
|
||||||
(void)context;
|
(void)context;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
* File author: Stefano D'Angelo
|
* File author: Stefano D'Angelo
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef struct plugin {
|
typedef struct plugin {
|
||||||
@ -37,6 +38,7 @@ typedef struct plugin {
|
|||||||
} plugin;
|
} plugin;
|
||||||
|
|
||||||
static void plugin_init(plugin *instance, const plugin_callbacks *cbs) {
|
static void plugin_init(plugin *instance, const plugin_callbacks *cbs) {
|
||||||
|
printf("plugin_init; hostinfo: %s\n", cbs->get_hostinfo(cbs->handle));
|
||||||
(void)instance;
|
(void)instance;
|
||||||
(void)cbs;
|
(void)cbs;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user