Browse Source

make plugins go silent after 15 minutes in trial version

faust
Alexandros Theodotou 3 years ago
parent
commit
9cd573b53e
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 36
      plugins/chordz/chordz.c
  2. 82
      plugins/common.h
  3. 36
      plugins/compressor/compressor.c
  4. 16
      plugins/meson.build
  5. 48
      plugins/saw/saw.c
  6. 36
      plugins/verb/verb.c

36
plugins/chordz/chordz.c

@ -83,31 +83,11 @@ instantiate ( @@ -83,31 +83,11 @@ instantiate (
SET_SAMPLERATE (self, rate);
PluginCommon * pl_common = &self->common.pl_common;
#define HAVE_FEATURE(x) \
(!strcmp(features[i]->URI, x))
for (int i = 0; features[i]; ++i)
{
if (HAVE_FEATURE (LV2_URID__map))
{
pl_common->map =
(LV2_URID_Map*) features[i]->data;
}
else if (HAVE_FEATURE (LV2_LOG__log))
{
pl_common->log =
(LV2_Log_Log *) features[i]->data;
}
}
#undef HAVE_FEATURE
if (!pl_common->map)
{
lv2_log_error (
&pl_common->logger, "Missing feature urid:map\n");
goto fail;
}
int ret =
plugin_common_instantiate (
pl_common, features, 1);
if (ret)
goto fail;
/* map uris */
map_uris (pl_common->map, &self->common);
@ -666,6 +646,12 @@ run ( @@ -666,6 +646,12 @@ run (
{
Chordz * self = (Chordz *) instance;
#ifdef TRIAL_VER
if (get_time_since_instantiation (
&self->common.pl_common) > SECONDS_TO_SILENCE)
return;
#endif
#ifndef RELEASE
struct timeval tp;
gettimeofday(&tp, NULL);

82
plugins/common.h

@ -26,8 +26,14 @@ @@ -26,8 +26,14 @@
#ifndef __Z_COMMON_H__
#define __Z_COMMON_H__
#include PLUGIN_CONFIG
#include <string.h>
#ifdef TRIAL_VER
#include <time.h>
#endif
#include "lv2/atom/atom.h"
#include "lv2/atom/forge.h"
#include "lv2/core/lv2.h"
@ -90,8 +96,25 @@ typedef struct PluginCommon @@ -90,8 +96,25 @@ typedef struct PluginCommon
/** Plugin samplerate. */
double samplerate;
#ifdef TRIAL_VER
clock_t instantiation_time;
#endif
} PluginCommon;
#ifdef TRIAL_VER
static inline double
get_time_since_instantiation (
PluginCommon * pl_common)
{
clock_t end = clock ();
return
(double)
(end - pl_common->instantiation_time) /
CLOCKS_PER_SEC;
}
#endif
static inline void
map_common_uris (
LV2_URID_Map* map,
@ -125,6 +148,65 @@ map_common_uris ( @@ -125,6 +148,65 @@ map_common_uris (
#undef MAP
}
/**
* @param with_worker 1 to add the worker feature.
*
* @return Non-zero on fail.
*/
static inline int
plugin_common_instantiate (
PluginCommon * pl_common,
const LV2_Feature * const * features,
int with_worker)
{
#ifdef TRIAL_VER
pl_common->instantiation_time = clock ();
#endif
#define HAVE_FEATURE(x) \
(!strcmp(features[i]->URI, x))
for (int i = 0; features[i]; ++i)
{
if (HAVE_FEATURE (LV2_URID__map))
{
pl_common->map =
(LV2_URID_Map*) features[i]->data;
}
else if (HAVE_FEATURE (LV2_LOG__log))
{
pl_common->log =
(LV2_Log_Log *) features[i]->data;
}
if (with_worker)
{
if (HAVE_FEATURE (LV2_WORKER__schedule))
{
pl_common->schedule =
(LV2_Worker_Schedule *) features[i]->data;
}
}
}
#undef HAVE_FEATURE
if (!pl_common->map)
{
lv2_log_error (
&pl_common->logger, "Missing feature urid:map\n");
return -1;
}
else if (with_worker && !pl_common->schedule)
{
lv2_log_error (
&pl_common->logger,
"Missing feature work:schedule\n");
return -1;
}
return 0;
}
/** Gets the samplerate form a plugin or UI. */
#define GET_SAMPLERATE(_x) \
((_x)->common.pl_common.samplerate)

36
plugins/compressor/compressor.c

@ -67,31 +67,11 @@ instantiate ( @@ -67,31 +67,11 @@ instantiate (
SET_SAMPLERATE (self, rate);
PluginCommon * pl_common = &self->common.pl_common;
#define HAVE_FEATURE(x) \
(!strcmp(features[i]->URI, x))
for (int i = 0; features[i]; ++i)
{
if (HAVE_FEATURE (LV2_URID__map))
{
pl_common->map =
(LV2_URID_Map*) features[i]->data;
}
else if (HAVE_FEATURE (LV2_LOG__log))
{
pl_common->log =
(LV2_Log_Log *) features[i]->data;
}
}
#undef HAVE_FEATURE
if (!pl_common->map)
{
lv2_log_error (
&pl_common->logger, "Missing feature urid:map\n");
goto fail;
}
int ret =
plugin_common_instantiate (
pl_common, features, 1);
if (ret)
goto fail;
/* map uris */
map_uris (pl_common->map, &self->common);
@ -176,6 +156,12 @@ run ( @@ -176,6 +156,12 @@ run (
{
Compressor * self = (Compressor *) instance;
#ifdef TRIAL_VER
if (get_time_since_instantiation (
&self->common.pl_common) > SECONDS_TO_SILENCE)
return;
#endif
#ifndef RELEASE
struct timeval tp;
gettimeofday(&tp, NULL);

16
plugins/meson.build

@ -26,9 +26,15 @@ plugins = [ @@ -26,9 +26,15 @@ plugins = [
foreach pl : plugins
if get_option ('plugins').contains (pl[0])
pl_str = 'Z' + pl[0]
pl_caps = pl[0].to_upper ()
pl_lowercase = pl[0].to_lower ()
plugin_name = pl[0]
plugin_name_for_export = plugin_name
if get_option ('trial_ver')
plugin_name_for_export = plugin_name + '-trial'
endif
pl_str = 'Z' + plugin_name_for_export
pl_caps = plugin_name.to_upper ()
pl_lowercase = plugin_name.to_lower ()
pl_dsp_lib_name_noext = pl_str + '_dsp'
pl_type = pl[1]
pl_version = pl[2]
@ -82,6 +88,10 @@ if get_option ('plugins').contains (pl[0]) @@ -82,6 +88,10 @@ if get_option ('plugins').contains (pl[0])
if get_option('buildtype') == 'release'
config_h_data.set ('RELEASE', 1)
endif
if get_option ('trial_ver')
config_h_data.set ('TRIAL_VER', 1)
config_h_data.set ('SECONDS_TO_SILENCE', 900)
endif
config_h_data.set_quoted (
pl_caps + '_VERSION', pl[1])

48
plugins/saw/saw.c

@ -299,43 +299,11 @@ instantiate ( @@ -299,43 +299,11 @@ instantiate (
SET_SAMPLERATE (self, rate);
PluginCommon * pl_common = &self->common.pl_common;
#define HAVE_FEATURE(x) \
(!strcmp(features[i]->URI, x))
for (int i = 0; features[i]; ++i)
{
if (HAVE_FEATURE (LV2_URID__map))
{
pl_common->map =
(LV2_URID_Map*) features[i]->data;
}
else if (HAVE_FEATURE (LV2_WORKER__schedule))
{
pl_common->schedule =
(LV2_Worker_Schedule *) features[i]->data;
}
else if (HAVE_FEATURE (LV2_LOG__log))
{
pl_common->log =
(LV2_Log_Log *) features[i]->data;
}
}
#undef HAVE_FEATURE
if (!pl_common->map)
{
lv2_log_error (
&pl_common->logger, "Missing feature urid:map\n");
goto fail;
}
else if (!pl_common->schedule)
{
lv2_log_error (
&pl_common->logger,
"Missing feature work:schedule\n");
goto fail;
}
int ret =
plugin_common_instantiate (
pl_common, features, 1);
if (ret)
goto fail;
/* map uris */
map_uris (pl_common->map, &self->common);
@ -597,6 +565,12 @@ run ( @@ -597,6 +565,12 @@ run (
{
Saw * self = (Saw *) instance;
#ifdef TRIAL_VER
if (get_time_since_instantiation (
&self->common.pl_common) > SECONDS_TO_SILENCE)
return;
#endif
#ifndef RELEASE
#if 0
struct timeval tp;

36
plugins/verb/verb.c

@ -74,31 +74,11 @@ instantiate ( @@ -74,31 +74,11 @@ instantiate (
SET_SAMPLERATE (self, rate);
PluginCommon * pl_common = &self->common.pl_common;
#define HAVE_FEATURE(x) \
(!strcmp(features[i]->URI, x))
for (int i = 0; features[i]; ++i)
{
if (HAVE_FEATURE (LV2_URID__map))
{
pl_common->map =
(LV2_URID_Map*) features[i]->data;
}
else if (HAVE_FEATURE (LV2_LOG__log))
{
pl_common->log =
(LV2_Log_Log *) features[i]->data;
}
}
#undef HAVE_FEATURE
if (!pl_common->map)
{
lv2_log_error (
&pl_common->logger, "Missing feature urid:map\n");
goto fail;
}
int ret =
plugin_common_instantiate (
pl_common, features, 1);
if (ret)
goto fail;
/* map uris */
map_uris (pl_common->map, &self->common);
@ -183,6 +163,12 @@ run ( @@ -183,6 +163,12 @@ run (
{
Verb * self = (Verb *) instance;
#ifdef TRIAL_VER
if (get_time_since_instantiation (
&self->common.pl_common) > SECONDS_TO_SILENCE)
return;
#endif
#if 0
struct timeval tp;
gettimeofday(&tp, NULL);

Loading…
Cancel
Save