Merge branch 'master' into cmd-handler

This commit is contained in:
Tom M 2017-10-06 13:11:21 +02:00 committed by GitHub
commit 82b2000d08
6 changed files with 227 additions and 198 deletions

View file

@ -40,9 +40,13 @@
#define L(x);
fluid_LADSPA_FxUnit_t* new_fluid_LADSPA_FxUnit(fluid_synth_t* synth){
if(synth == NULL)
return NULL;
fluid_LADSPA_FxUnit_t* FxUnit=FLUID_NEW(fluid_LADSPA_FxUnit_t);
assert(FxUnit);
assert(synth);
if(FxUnit == NULL)
return NULL;
/* The default state is 'bypassed'. The Fx unit has to be turned on explicitly by the user. */
/* Those settings have to be done in order to allow fluid_LADSPA_clean. */
FxUnit->Bypass=fluid_LADSPA_Bypassed;
@ -64,19 +68,12 @@ void fluid_LADSPA_CreateSystemNodes(fluid_LADSPA_FxUnit_t* FxUnit){
int nr_input_nodes;
int nr_fx_input_nodes;
int nr_output_nodes;
int temp;
int i;
/* Retrieve the number of synth / audio out / Fx send nodes */
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.audio-groups", &temp) == FLUID_OK);
nr_input_nodes=(int) temp;
printf("%i audio groups\n", nr_input_nodes);
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.audio-channels", &temp) == FLUID_OK);
nr_output_nodes=temp;
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.effects-channels", &temp) == FLUID_OK);
nr_fx_input_nodes=temp;
nr_input_nodes = FxUnit->synth->audio_groups;
nr_output_nodes = FxUnit->synth->audio_channels;
nr_fx_input_nodes = FxUnit->synth->effects_channels;
/* Create regular input nodes (associated with audio groups) */
for (i=0; i < nr_input_nodes; i++){
@ -95,7 +92,7 @@ void fluid_LADSPA_CreateSystemNodes(fluid_LADSPA_FxUnit_t* FxUnit){
};
/* Create output nodes (usually towards the sound card) */
for (i=0; i < nr_input_nodes; i++){
for (i=0; i < nr_output_nodes; i++){
sprintf(str, "out%i_L",(i+1));
fluid_LADSPA_CreateNode(FxUnit, str, fluid_LADSPA_node_is_audio | fluid_LADSPA_node_is_sink);
sprintf(str, "out%i_R",(i+1));
@ -221,7 +218,11 @@ fluid_LADSPA_handle_start(fluid_synth_t* synth, int ac, char** av, fluid_ostream
L(fluid_ostream_printf(out,"ladspa_start: starting..."));
assert(synth);
FxUnit=synth->LADSPA_FxUnit; assert(FxUnit);
FxUnit=synth->LADSPA_FxUnit;
if (!FxUnit) {
fluid_ostream_printf(out, "ladspa not active!\n");
return FLUID_FAILED;
}
/* When calling fluid_ladspastart, the Fx unit must be 'cleared' (no plugins, no libs, no nodes). Verify this here. */
if (FxUnit->NumberPlugins || FxUnit->NumberLibs){
@ -703,20 +704,14 @@ fluid_LADSPA_run(fluid_LADSPA_FxUnit_t* FxUnit, fluid_real_t* left_buf[], fluid_
int nr_audio_channels;
int nr_fx_sends;
int nr_groups;
int byte_size = FLUID_BUFSIZE * sizeof(fluid_real_t);
int byte_size = FLUID_BUFSIZE * sizeof(LADSPA_Data);
char str[99];
fluid_LADSPA_Node_t* n;
int temp;
/* Retrieve the number of synth / audio out / Fx send nodes */
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.audio-groups", &temp) == FLUID_OK);
nr_groups=(int) temp;
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.audio-channels", &temp) == FLUID_OK);
nr_audio_channels=temp;
assert(fluid_settings_getint(FxUnit->synth->settings, "synth.effects-channels", &temp) == FLUID_OK);
nr_fx_sends=temp;
nr_groups = FxUnit->synth->audio_groups;
nr_audio_channels = FxUnit->synth->audio_channels;
nr_fx_sends = FxUnit->synth->effects_channels;
/* Fixme: Retrieving nodes via names is inefficient
* (but not that bad, because the interesting nodes are always at the start of the list).
@ -863,8 +858,8 @@ fluid_LADSPA_CreateNode(fluid_LADSPA_FxUnit_t* FxUnit, char * Name, int flags){
printf( "***Error026***\n"
"The node name %s starts with a digit / minus sign!\n"
"Please use a letter to start a node name.\n"
"A constant node is created by using `#' as first character,\n"
"for example #-2.5.\n",
"A constant node is created by using `$' as first character,\n"
"for example $-2.5.\n",
Name);
fluid_LADSPA_clear(FxUnit);
return NULL;
@ -894,8 +889,8 @@ fluid_LADSPA_CreateNode(fluid_LADSPA_FxUnit_t* FxUnit, char * Name, int flags){
NewNode->OutCount=0;
NewNode->flags=flags;
/* A nodename starting with "#" means that the node holds a constant value. */
if (NewNode->Name[0] == '#'){
/* A nodename starting with "$" means that the node holds a constant value. */
if (NewNode->Name[0] == '$'){
assert(flags & fluid_LADSPA_node_is_control);
/* Skip the first character => +1 */
NewNode->buf[0]=(LADSPA_Data)atof(NewNode->Name+1);
@ -990,7 +985,11 @@ int fluid_LADSPA_handle_add(fluid_synth_t* synth, int ac, char** av, fluid_ostre
char ** CommandLine;
fluid_LADSPA_FxUnit_t* FxUnit;
assert(synth);
FxUnit=synth->LADSPA_FxUnit; assert(FxUnit);
FxUnit=synth->LADSPA_FxUnit;
if (!FxUnit) {
fluid_ostream_printf(out, "ladspa not active!\n");
return FLUID_FAILED;
}
if (ac>=FLUID_LADSPA_MaxTokens){
/* Can't be tested. fluidsynth limits the number of tokens. */
printf("***Error001***\n"
@ -1036,7 +1035,11 @@ int fluid_LADSPA_handle_declnode(fluid_synth_t* synth, int ac, char** av, fluid_
fluid_real_t NodeValue;
fluid_LADSPA_FxUnit_t* FxUnit;
assert(synth);
FxUnit=synth->LADSPA_FxUnit; assert(FxUnit);
FxUnit=synth->LADSPA_FxUnit;
if (!FxUnit) {
fluid_ostream_printf(out, "ladspa not active!\n");
return FLUID_FAILED;
}
if (ac<2){
printf("***Error028***\n"
@ -1067,7 +1070,11 @@ int fluid_LADSPA_handle_setnode(fluid_synth_t* synth, int ac, char** av, fluid_o
fluid_LADSPA_FxUnit_t* FxUnit;
fluid_LADSPA_Node_t* CurrentNode;
assert(synth);
FxUnit=synth->LADSPA_FxUnit; assert(FxUnit);
FxUnit=synth->LADSPA_FxUnit;
if (!FxUnit) {
fluid_ostream_printf(out, "ladspa not active!\n");
return FLUID_FAILED;
}
if (ac!=2){
printf("***Error029***\n"
@ -1102,7 +1109,11 @@ int fluid_LADSPA_handle_setnode(fluid_synth_t* synth, int ac, char** av, fluid_o
int fluid_LADSPA_handle_clear(fluid_synth_t* synth, int ac, char** av, fluid_ostream_t out){
fluid_LADSPA_FxUnit_t* FxUnit;
assert(synth);
FxUnit=synth->LADSPA_FxUnit; assert(FxUnit);
FxUnit=synth->LADSPA_FxUnit;
if (!FxUnit) {
fluid_ostream_printf(out, "ladspa not active!\n");
return FLUID_FAILED;
}
fluid_LADSPA_clear(FxUnit);
return(FLUID_OK);
};

View file

@ -122,7 +122,7 @@ typedef struct {
/* List of Command lines
* During the setup phase, each ladspa_add command creates one command sequence. For example:
* ./aw.so alienwah_stereo Input <- Master_L_Synth Output -> Master_R_Synth Parameter <- #42.0
* ./aw.so alienwah_stereo Input <- Master_L_Synth Output -> Master_R_Synth Parameter <- $42.0
* Those lists are stored in LADSPA_Command_Sequence.
* One command line results in one plugin => size MaxPlugins.
*/

View file

@ -554,7 +554,7 @@ fluid_jack_driver_process (jack_nframes_t nframes, void *arg)
}
}
audio_driver = client->audio_driver;
audio_driver = fluid_atomic_pointer_get (&client->audio_driver);
if (!audio_driver) return 0;
if (audio_driver->callback != NULL)

View file

@ -42,10 +42,6 @@
#include "config_win32.h"
#endif
#ifdef HAVE_SIGNAL_H
#include "signal.h"
#endif
#include "fluid_lash.h"
#ifndef WITH_MIDI
@ -259,16 +255,6 @@ fast_render_loop(fluid_settings_t* settings, fluid_synth_t* synth, fluid_player_
delete_fluid_file_renderer(renderer);
}
#ifdef HAVE_SIGNAL_H
/*
* handle_signal
*/
void handle_signal(int sig_num)
{
}
#endif
/*
* main
*/
@ -585,14 +571,18 @@ int main(int argc, char** argv)
}
#endif
/* The 'groups' setting is only relevant for LADSPA operation
/* The 'groups' setting is relevant for LADSPA operation and channel mapping
* in rvoice_mixer.
* If not given, set number groups to number of audio channels, because
* they are the same (there is nothing between synth output and 'sound card')
*/
if ((audio_groups == 0) && (audio_channels != 0)) {
audio_groups = audio_channels;
}
fluid_settings_setint(settings, "synth.audio-groups", audio_groups);
if (audio_groups != 0)
{
fluid_settings_setint(settings, "synth.audio-groups", audio_groups);
}
if (fast_render) {
midi_in = 0;
@ -622,10 +612,6 @@ int main(int argc, char** argv)
argv[i]);
}
#ifdef HAVE_SIGNAL_H
/* signal(SIGINT, handle_signal); */
#endif
/* start the synthesis thread */
if (!fast_render) {
adriver = new_fluid_audio_driver(settings, synth);

View file

@ -555,7 +555,7 @@ new_fluid_synth(fluid_settings_t *settings)
fluid_sfloader_t* loader;
double gain;
int i, nbuf;
int with_ladspa = 0;
/* initialize all the conversion tables and other stuff */
if (fluid_synth_initialized == 0)
@ -694,8 +694,15 @@ new_fluid_synth(fluid_settings_t *settings)
#ifdef LADSPA
/* Create and initialize the Fx unit.*/
synth->LADSPA_FxUnit = new_fluid_LADSPA_FxUnit(synth);
fluid_rvoice_mixer_set_ladspa(synth->eventhandler->mixer, synth->LADSPA_FxUnit);
fluid_settings_getint(settings, "synth.ladspa.active", &with_ladspa);
if (with_ladspa) {
synth->LADSPA_FxUnit = new_fluid_LADSPA_FxUnit(synth);
if(synth->LADSPA_FxUnit == NULL) {
FLUID_LOG(FLUID_ERR, "Out of memory");
goto error_recovery;
}
fluid_rvoice_mixer_set_ladspa(synth->eventhandler->mixer, synth->LADSPA_FxUnit);
}
#endif
/* allocate and add the default sfont loader */
@ -905,8 +912,10 @@ delete_fluid_synth(fluid_synth_t* synth)
#ifdef LADSPA
/* Release the LADSPA Fx unit */
fluid_LADSPA_shutdown(synth->LADSPA_FxUnit);
FLUID_FREE(synth->LADSPA_FxUnit);
if (synth->LADSPA_FxUnit) {
fluid_LADSPA_shutdown(synth->LADSPA_FxUnit);
FLUID_FREE(synth->LADSPA_FxUnit);
}
#endif
fluid_rec_mutex_destroy(synth->mutex);

View file

@ -42,11 +42,6 @@ static int fluid_settings_tokenize(const char *s, char *buf, char **ptr);
/* Common structure to all settings nodes */
typedef struct {
int type; /**< fluid_types_enum */
} fluid_setting_node_t;
typedef struct {
fluid_setting_node_t node;
char* value;
char* def;
int hints;
@ -56,7 +51,6 @@ typedef struct {
} fluid_str_setting_t;
typedef struct {
fluid_setting_node_t node;
double value;
double def;
double min;
@ -67,7 +61,6 @@ typedef struct {
} fluid_num_setting_t;
typedef struct {
fluid_setting_node_t node;
int value;
int def;
int min;
@ -78,152 +71,184 @@ typedef struct {
} fluid_int_setting_t;
typedef struct {
fluid_setting_node_t node;
fluid_hashtable_t *hashtable;
} fluid_set_setting_t;
typedef struct {
int type; /**< fluid_types_enum */
union
{
fluid_str_setting_t str;
fluid_num_setting_t num;
fluid_int_setting_t i;
fluid_set_setting_t set;
};
} fluid_setting_node_t;
static fluid_str_setting_t*
static fluid_setting_node_t*
new_fluid_str_setting(const char* value, const char* def, int hints, fluid_str_update_t fun, void* data)
{
fluid_setting_node_t* node;
fluid_str_setting_t* str;
node = FLUID_NEW(fluid_setting_node_t);
str = FLUID_NEW(fluid_str_setting_t);
if (!str)
if (!node)
{
FLUID_LOG(FLUID_ERR, "Out of memory");
return NULL;
}
str->node.type = FLUID_STR_TYPE;
node->type = FLUID_STR_TYPE;
str = &node->str;
str->value = value? FLUID_STRDUP(value) : NULL;
str->def = def? FLUID_STRDUP(def) : NULL;
str->hints = hints;
str->options = NULL;
str->update = fun;
str->data = data;
return str;
return node;
}
static void
delete_fluid_str_setting(fluid_str_setting_t* str)
delete_fluid_str_setting(fluid_setting_node_t* node)
{
if (!str) return;
if (!node) return;
FLUID_ASSERT(node->type, FLUID_STR_TYPE);
if (str->value) FLUID_FREE(str->value);
if (str->def) FLUID_FREE(str->def);
FLUID_FREE(node->str.value);
FLUID_FREE(node->str.def);
if (str->options) {
fluid_list_t* list = str->options;
if (node->str.options) {
fluid_list_t* list = node->str.options;
while (list) {
FLUID_FREE (list->data);
list = fluid_list_next(list);
}
delete_fluid_list(str->options);
delete_fluid_list(node->str.options);
}
FLUID_FREE(str);
FLUID_FREE(node);
}
static fluid_num_setting_t*
static fluid_setting_node_t*
new_fluid_num_setting(double min, double max, double def,
int hints, fluid_num_update_t fun, void* data)
{
fluid_num_setting_t* setting;
fluid_setting_node_t* node;
fluid_num_setting_t* num;
setting = FLUID_NEW(fluid_num_setting_t);
node = FLUID_NEW(fluid_setting_node_t);
if (!setting)
if (!node)
{
FLUID_LOG(FLUID_ERR, "Out of memory");
return NULL;
}
setting->node.type = FLUID_NUM_TYPE;
setting->value = def;
setting->def = def;
setting->min = min;
setting->max = max;
setting->hints = hints;
setting->update = fun;
setting->data = data;
return setting;
node->type = FLUID_NUM_TYPE;
num = &node->num;
num->value = def;
num->def = def;
num->min = min;
num->max = max;
num->hints = hints;
num->update = fun;
num->data = data;
return node;
}
static void
delete_fluid_num_setting(fluid_num_setting_t* setting)
delete_fluid_num_setting(fluid_setting_node_t* node)
{
if (setting) FLUID_FREE(setting);
if (!node) return;
FLUID_ASSERT (node->type, FLUID_NUM_TYPE);
FLUID_FREE(node);
}
static fluid_int_setting_t*
static fluid_setting_node_t*
new_fluid_int_setting(int min, int max, int def,
int hints, fluid_int_update_t fun, void* data)
{
fluid_int_setting_t* setting;
fluid_setting_node_t* node;
fluid_int_setting_t* i;
setting = FLUID_NEW(fluid_int_setting_t);
node = FLUID_NEW(fluid_setting_node_t);
if (!setting)
if (!node)
{
FLUID_LOG(FLUID_ERR, "Out of memory");
return NULL;
}
setting->node.type = FLUID_INT_TYPE;
setting->value = def;
setting->def = def;
setting->min = min;
setting->max = max;
setting->hints = hints;
setting->update = fun;
setting->data = data;
return setting;
node->type = FLUID_INT_TYPE;
i = &node->i;
i->value = def;
i->def = def;
i->min = min;
i->max = max;
i->hints = hints;
i->update = fun;
i->data = data;
return node;
}
static void
delete_fluid_int_setting(fluid_int_setting_t* setting)
delete_fluid_int_setting(fluid_setting_node_t* node)
{
if (setting) FLUID_FREE(setting);
if (!node) return;
FLUID_ASSERT (node->type, FLUID_INT_TYPE);
FLUID_FREE(node);
}
static fluid_set_setting_t*
static fluid_setting_node_t*
new_fluid_set_setting(void)
{
fluid_set_setting_t* setting;
fluid_setting_node_t* node;
fluid_set_setting_t* set;
setting = FLUID_NEW(fluid_set_setting_t);
node = FLUID_NEW(fluid_setting_node_t);
if (!setting)
if (!node)
{
FLUID_LOG(FLUID_ERR, "Out of memory");
return NULL;
}
setting->node.type = FLUID_SET_TYPE;
setting->hashtable = new_fluid_hashtable_full(fluid_str_hash, fluid_str_equal,
node->type = FLUID_SET_TYPE;
set = &node->set;
set->hashtable = new_fluid_hashtable_full(fluid_str_hash, fluid_str_equal,
fluid_settings_key_destroy_func,
fluid_settings_value_destroy_func);
if (!setting->hashtable)
if (!set->hashtable)
{
FLUID_FREE (setting);
FLUID_FREE (node);
return NULL;
}
return setting;
return node;
}
static void
delete_fluid_set_setting(fluid_set_setting_t* setting)
delete_fluid_set_setting(fluid_setting_node_t* node)
{
if (setting)
if (node)
{
delete_fluid_hashtable(setting->hashtable);
FLUID_FREE(setting);
FLUID_ASSERT (node->type, FLUID_SET_TYPE);
delete_fluid_hashtable(node->set.hashtable);
FLUID_FREE(node);
}
}
@ -274,16 +299,16 @@ fluid_settings_value_destroy_func(void* value)
switch (node->type) {
case FLUID_NUM_TYPE:
delete_fluid_num_setting((fluid_num_setting_t*) value);
delete_fluid_num_setting(node);
break;
case FLUID_INT_TYPE:
delete_fluid_int_setting((fluid_int_setting_t*) value);
delete_fluid_int_setting(node);
break;
case FLUID_STR_TYPE:
delete_fluid_str_setting((fluid_str_setting_t*) value);
delete_fluid_str_setting(node);
break;
case FLUID_SET_TYPE:
delete_fluid_set_setting((fluid_set_setting_t*) value);
delete_fluid_set_setting(node);
break;
}
}
@ -359,7 +384,7 @@ fluid_settings_get(fluid_settings_t* settings, const char *name,
node = fluid_hashtable_lookup(table, tokens[n]);
if (!node) return FLUID_FAILED;
table = (node->type == FLUID_SET_TYPE) ? ((fluid_set_setting_t *)node)->hashtable : NULL;
table = (node->type == FLUID_SET_TYPE) ? node->set.hashtable : NULL;
}
if (value) *value = node;
@ -376,7 +401,7 @@ fluid_settings_get(fluid_settings_t* settings, const char *name,
* @return #FLUID_OK if the value has been set, #FLUID_FAILED otherwise
*/
static int
fluid_settings_set(fluid_settings_t* settings, const char *name, void* value)
fluid_settings_set(fluid_settings_t* settings, const char *name, fluid_setting_node_t* value)
{
fluid_hashtable_t* table = settings;
fluid_setting_node_t *node;
@ -396,7 +421,7 @@ fluid_settings_set(fluid_settings_t* settings, const char *name, void* value)
if (node) {
if (node->type == FLUID_SET_TYPE) {
table = ((fluid_set_setting_t *)node)->hashtable;
table = node->set.hashtable;
} else {
/* path ends prematurely */
FLUID_LOG(FLUID_WARN, "'%s' is not a node", name[n]);
@ -405,7 +430,7 @@ fluid_settings_set(fluid_settings_t* settings, const char *name, void* value)
} else {
/* create a new node */
fluid_set_setting_t* setnode;
fluid_setting_node_t* setnode;
dupname = FLUID_STRDUP (tokens[n]);
setnode = new_fluid_set_setting ();
@ -421,7 +446,7 @@ fluid_settings_set(fluid_settings_t* settings, const char *name, void* value)
}
fluid_hashtable_insert(table, dupname, setnode);
table = setnode->hashtable;
table = setnode->set.hashtable;
}
}
@ -454,7 +479,6 @@ fluid_settings_register_str(fluid_settings_t* settings, const char* name, const
fluid_str_update_t fun, void* data)
{
fluid_setting_node_t *node;
fluid_str_setting_t* setting;
int retval = FLUID_FAILED;
fluid_return_val_if_fail (settings != NULL, retval);
@ -464,13 +488,13 @@ fluid_settings_register_str(fluid_settings_t* settings, const char* name, const
fluid_rec_mutex_lock (settings->mutex);
if (fluid_settings_get(settings, name, &node) != FLUID_OK) {
setting = new_fluid_str_setting(def, def, hints, fun, data);
retval = fluid_settings_set(settings, name, setting);
if (retval != FLUID_OK) delete_fluid_str_setting (setting);
node = new_fluid_str_setting(def, def, hints, fun, data);
retval = fluid_settings_set(settings, name, node);
if (retval != FLUID_OK) delete_fluid_str_setting (node);
} else {
/* if variable already exists, don't change its value. */
if (node->type == FLUID_STR_TYPE) {
setting = (fluid_str_setting_t*) node;
fluid_str_setting_t* setting = &node->str;
setting->update = fun;
setting->data = data;
setting->def = def? FLUID_STRDUP(def) : NULL;
@ -518,14 +542,13 @@ fluid_settings_register_num(fluid_settings_t* settings, const char* name, double
if (fluid_settings_get(settings, name, &node) != FLUID_OK) {
/* insert a new setting */
fluid_num_setting_t* setting;
setting = new_fluid_num_setting(min, max, def, hints, fun, data);
retval = fluid_settings_set(settings, name, setting);
if (retval != FLUID_OK) delete_fluid_num_setting (setting);
node = new_fluid_num_setting(min, max, def, hints, fun, data);
retval = fluid_settings_set(settings, name, node);
if (retval != FLUID_OK) delete_fluid_num_setting (node);
} else {
if (node->type == FLUID_NUM_TYPE) {
/* update the existing setting but don't change its value */
fluid_num_setting_t* setting = (fluid_num_setting_t*) node;
fluid_num_setting_t* setting = &node->num;
setting->update = fun;
setting->data = data;
setting->min = min;
@ -576,14 +599,13 @@ fluid_settings_register_int(fluid_settings_t* settings, const char* name, int de
if (fluid_settings_get(settings, name, &node) != FLUID_OK) {
/* insert a new setting */
fluid_int_setting_t* setting;
setting = new_fluid_int_setting(min, max, def, hints, fun, data);
retval = fluid_settings_set(settings, name, setting);
if (retval != FLUID_OK) delete_fluid_int_setting (setting);
node = new_fluid_int_setting(min, max, def, hints, fun, data);
retval = fluid_settings_set(settings, name, node);
if (retval != FLUID_OK) delete_fluid_int_setting (node);
} else {
if (node->type == FLUID_INT_TYPE) {
/* update the existing setting but don't change its value */
fluid_int_setting_t* setting = (fluid_int_setting_t*) node;
fluid_int_setting_t* setting = &node->i;
setting->update = fun;
setting->data = data;
setting->min = min;
@ -650,15 +672,15 @@ fluid_settings_get_hints(fluid_settings_t* settings, const char *name, int* hint
if (fluid_settings_get(settings, name, &node) == FLUID_OK) {
if (node->type == FLUID_NUM_TYPE) {
fluid_num_setting_t* setting = (fluid_num_setting_t*) node;
fluid_num_setting_t* setting = &node->num;
*hints = setting->hints;
retval = FLUID_OK;
} else if (node->type == FLUID_STR_TYPE) {
fluid_str_setting_t* setting = (fluid_str_setting_t*) node;
fluid_str_setting_t* setting = &node->str;
*hints = setting->hints;
retval = FLUID_OK;
} else if (node->type == FLUID_INT_TYPE) {
fluid_int_setting_t* setting = (fluid_int_setting_t*) node;
fluid_int_setting_t* setting = &node->i;
*hints = setting->hints;
retval = FLUID_OK;
}
@ -690,13 +712,13 @@ fluid_settings_is_realtime(fluid_settings_t* settings, const char *name)
if (fluid_settings_get(settings, name, &node) == FLUID_OK) {
if (node->type == FLUID_NUM_TYPE) {
fluid_num_setting_t* setting = (fluid_num_setting_t*) node;
fluid_num_setting_t* setting = &node->num;
isrealtime = setting->update != NULL;
} else if (node->type == FLUID_STR_TYPE) {
fluid_str_setting_t* setting = (fluid_str_setting_t*) node;
fluid_str_setting_t* setting = &node->str;
isrealtime = setting->update != NULL;
} else if (node->type == FLUID_INT_TYPE) {
fluid_int_setting_t* setting = (fluid_int_setting_t*) node;
fluid_int_setting_t* setting = &node->i;
isrealtime = setting->update != NULL;
}
}
@ -728,7 +750,7 @@ fluid_settings_setstr(fluid_settings_t* settings, const char *name, const char *
if (fluid_settings_get (settings, name, &node) == FLUID_OK) {
if (node->type == FLUID_STR_TYPE) {
fluid_str_setting_t *setting = (fluid_str_setting_t *)node;
fluid_str_setting_t *setting = &node->str;
if (setting->value) FLUID_FREE (setting->value);
setting->value = str ? FLUID_STRDUP (str) : NULL;
@ -739,7 +761,7 @@ fluid_settings_setstr(fluid_settings_t* settings, const char *name, const char *
}
else if (node->type == FLUID_INT_TYPE) /* Handle yes/no for boolean values for backwards compatibility */
{
fluid_int_setting_t *setting = (fluid_int_setting_t *)node;
fluid_int_setting_t *setting = &node->i;
if (setting->hints & FLUID_HINT_TOGGLED)
{
@ -759,10 +781,9 @@ fluid_settings_setstr(fluid_settings_t* settings, const char *name, const char *
}
} else {
/* insert a new setting */
fluid_str_setting_t* setting;
setting = new_fluid_str_setting(str, NULL, 0, NULL, NULL);
retval = fluid_settings_set(settings, name, setting);
if (retval != FLUID_OK) delete_fluid_str_setting (setting);
node = new_fluid_str_setting(str, NULL, 0, NULL, NULL);
retval = fluid_settings_set(settings, name, node);
if (retval != FLUID_OK) delete_fluid_str_setting (node);
}
fluid_rec_mutex_unlock (settings->mutex);
@ -803,7 +824,7 @@ fluid_settings_copystr(fluid_settings_t* settings, const char *name,
{
if (node->type == FLUID_STR_TYPE)
{
fluid_str_setting_t *setting = (fluid_str_setting_t *)node;
fluid_str_setting_t *setting = &node->str;
if (setting->value)
{
@ -815,7 +836,7 @@ fluid_settings_copystr(fluid_settings_t* settings, const char *name,
}
else if (node->type == FLUID_INT_TYPE) /* Handle boolean integers for backwards compatibility */
{
fluid_int_setting_t *setting = (fluid_int_setting_t *)node;
fluid_int_setting_t *setting = &node->i;
if (setting->hints & FLUID_HINT_TOGGLED)
{
@ -860,7 +881,7 @@ fluid_settings_dupstr(fluid_settings_t* settings, const char *name, char** str)
{
if (node->type == FLUID_STR_TYPE)
{
fluid_str_setting_t *setting = (fluid_str_setting_t *)node;
fluid_str_setting_t *setting = &node->str;
if (setting->value)
{
@ -872,7 +893,7 @@ fluid_settings_dupstr(fluid_settings_t* settings, const char *name, char** str)
}
else if (node->type == FLUID_INT_TYPE) /* Handle boolean integers for backwards compatibility */
{
fluid_int_setting_t *setting = (fluid_int_setting_t *)node;
fluid_int_setting_t *setting = &node->i;
if (setting->hints & FLUID_HINT_TOGGLED)
{
@ -915,13 +936,13 @@ fluid_settings_str_equal (fluid_settings_t* settings, const char *name, const ch
{
if (node->type == FLUID_STR_TYPE)
{
fluid_str_setting_t *setting = (fluid_str_setting_t *)node;
fluid_str_setting_t *setting = &node->str;
if (setting->value)
retval = FLUID_STRCMP (setting->value, s) == 0;
}
else if (node->type == FLUID_INT_TYPE) /* Handle boolean integers for backwards compatibility */
{
fluid_int_setting_t *setting = (fluid_int_setting_t *)node;
fluid_int_setting_t *setting = &node->i;
if (setting->hints & FLUID_HINT_TOGGLED)
retval = FLUID_STRCMP (setting->value ? "yes" : "no", s) == 0;
@ -957,12 +978,12 @@ fluid_settings_getstr_default(fluid_settings_t* settings, const char *name)
{
if (node->type == FLUID_STR_TYPE)
{
fluid_str_setting_t* setting = (fluid_str_setting_t*) node;
fluid_str_setting_t* setting = &node->str;
retval = setting->def;
}
else if (node->type == FLUID_INT_TYPE) /* Handle boolean integers for backwards compatibility */
{
fluid_int_setting_t *setting = (fluid_int_setting_t *)node;
fluid_int_setting_t *setting = &node->i;
if (setting->hints & FLUID_HINT_TOGGLED)
retval = setting->def ? "yes" : "no";
@ -998,7 +1019,7 @@ fluid_settings_add_option(fluid_settings_t* settings, const char *name, const ch
if (fluid_settings_get(settings, name, &node) == FLUID_OK
&& (node->type == FLUID_STR_TYPE)) {
fluid_str_setting_t* setting = (fluid_str_setting_t*) node;
fluid_str_setting_t* setting = &node->str;
char* copy = FLUID_STRDUP(s);
setting->options = fluid_list_append(setting->options, copy);
setting->hints |= FLUID_HINT_OPTIONLIST;
@ -1033,7 +1054,7 @@ fluid_settings_remove_option(fluid_settings_t* settings, const char *name, const
if (fluid_settings_get(settings, name, &node) == FLUID_OK
&& (node->type == FLUID_STR_TYPE)) {
fluid_str_setting_t* setting = (fluid_str_setting_t*) node;
fluid_str_setting_t* setting = &node->str;
fluid_list_t* list = setting->options;
while (list) {
@ -1065,7 +1086,6 @@ int
fluid_settings_setnum(fluid_settings_t* settings, const char *name, double val)
{
fluid_setting_node_t *node;
fluid_num_setting_t* setting;
int retval = FLUID_FAILED;
fluid_return_val_if_fail (settings != NULL, retval);
@ -1076,10 +1096,13 @@ fluid_settings_setnum(fluid_settings_t* settings, const char *name, double val)
if (fluid_settings_get(settings, name, &node) == FLUID_OK) {
if (node->type == FLUID_NUM_TYPE) {
setting = (fluid_num_setting_t*) node;
fluid_num_setting_t* setting = &node->num;
if (val < setting->min) val = setting->min;
else if (val > setting->max) val = setting->max;
if (val < setting->min || val > setting->max)
{
FLUID_LOG(FLUID_DBG, "requested set value for %s out of range", name);
return retval;
}
setting->value = val;
@ -1089,11 +1112,10 @@ fluid_settings_setnum(fluid_settings_t* settings, const char *name, double val)
}
} else {
/* insert a new setting */
fluid_num_setting_t* setting;
setting = new_fluid_num_setting(-1e10, 1e10, 0.0f, 0, NULL, NULL);
setting->value = val;
retval = fluid_settings_set(settings, name, setting);
if (retval != FLUID_OK) delete_fluid_num_setting (setting);
node = new_fluid_num_setting(-1e10, 1e10, 0.0f, 0, NULL, NULL);
node->num.value = val;
retval = fluid_settings_set(settings, name, node);
if (retval != FLUID_OK) delete_fluid_num_setting (node);
}
fluid_rec_mutex_unlock (settings->mutex);
@ -1124,7 +1146,7 @@ fluid_settings_getnum(fluid_settings_t* settings, const char *name, double* val)
if (fluid_settings_get(settings, name, &node) == FLUID_OK
&& (node->type == FLUID_NUM_TYPE)) {
fluid_num_setting_t* setting = (fluid_num_setting_t*) node;
fluid_num_setting_t* setting = &node->num;
*val = setting->value;
retval = FLUID_OK;
}
@ -1160,7 +1182,7 @@ fluid_settings_getnum_range(fluid_settings_t* settings, const char *name,
if (fluid_settings_get(settings, name, &node) == FLUID_OK
&& (node->type == FLUID_NUM_TYPE)) {
fluid_num_setting_t* setting = (fluid_num_setting_t*) node;
fluid_num_setting_t* setting = &node->num;
*min = setting->min;
*max = setting->max;
retval = FLUID_OK;
@ -1194,7 +1216,7 @@ fluid_settings_getnum_default(fluid_settings_t* settings, const char *name, doub
if (fluid_settings_get(settings, name, &node) == FLUID_OK
&& (node->type == FLUID_NUM_TYPE)) {
fluid_num_setting_t* setting = (fluid_num_setting_t*) node;
fluid_num_setting_t* setting = &node->num;
*val = setting->def;
retval = FLUID_OK;
}
@ -1216,7 +1238,6 @@ int
fluid_settings_setint(fluid_settings_t* settings, const char *name, int val)
{
fluid_setting_node_t *node;
fluid_int_setting_t* setting;
int retval = FLUID_FAILED;
fluid_return_val_if_fail (settings != NULL, retval);
@ -1227,10 +1248,13 @@ fluid_settings_setint(fluid_settings_t* settings, const char *name, int val)
if (fluid_settings_get(settings, name, &node) == FLUID_OK) {
if (node->type == FLUID_INT_TYPE) {
setting = (fluid_int_setting_t*) node;
fluid_int_setting_t* setting = &node->i;
if (val < setting->min) val = setting->min;
else if (val > setting->max) val = setting->max;
if (val < setting->min || val > setting->max)
{
FLUID_LOG(FLUID_DBG, "requested set value for %s out of range", name);
return retval;
}
setting->value = val;
@ -1240,11 +1264,10 @@ fluid_settings_setint(fluid_settings_t* settings, const char *name, int val)
}
} else {
/* insert a new setting */
fluid_int_setting_t* setting;
setting = new_fluid_int_setting(INT_MIN, INT_MAX, 0, 0, NULL, NULL);
setting->value = val;
retval = fluid_settings_set(settings, name, setting);
if (retval != FLUID_OK) delete_fluid_int_setting (setting);
node = new_fluid_int_setting(INT_MIN, INT_MAX, 0, 0, NULL, NULL);
node->i.value = val;
retval = fluid_settings_set(settings, name, node);
if (retval != FLUID_OK) delete_fluid_int_setting (node);
}
fluid_rec_mutex_unlock (settings->mutex);
@ -1275,7 +1298,7 @@ fluid_settings_getint(fluid_settings_t* settings, const char *name, int* val)
if (fluid_settings_get(settings, name, &node) == FLUID_OK
&& (node->type == FLUID_INT_TYPE)) {
fluid_int_setting_t* setting = (fluid_int_setting_t*) node;
fluid_int_setting_t* setting = &node->i;
*val = setting->value;
retval = FLUID_OK;
}
@ -1310,7 +1333,7 @@ fluid_settings_getint_range(fluid_settings_t* settings, const char *name,
if (fluid_settings_get(settings, name, &node) == FLUID_OK
&& (node->type == FLUID_INT_TYPE)) {
fluid_int_setting_t* setting = (fluid_int_setting_t*) node;
fluid_int_setting_t* setting = &node->i;
*min = setting->min;
*max = setting->max;
retval = FLUID_OK;
@ -1343,7 +1366,7 @@ int fluid_settings_getint_default(fluid_settings_t* settings, const char *name,
if (fluid_settings_get(settings, name, &node) == FLUID_OK
&& (node->type == FLUID_INT_TYPE)) {
fluid_int_setting_t* setting = (fluid_int_setting_t*) node;
fluid_int_setting_t* setting = &node->i;
*val = setting->def;
retval = FLUID_OK;
}
@ -1387,7 +1410,7 @@ fluid_settings_foreach_option (fluid_settings_t* settings, const char *name,
return;
}
setting = (fluid_str_setting_t*)node;
setting = &node->str;
/* Duplicate option list */
for (p = setting->options; p; p = p->next)
@ -1425,7 +1448,7 @@ fluid_settings_option_count (fluid_settings_t *settings, const char *name)
fluid_rec_mutex_lock (settings->mutex);
if (fluid_settings_get(settings, name, &node) == FLUID_OK
&& node->type == FLUID_STR_TYPE)
count = fluid_list_size (((fluid_str_setting_t *)node)->options);
count = fluid_list_size (node->str.options);
fluid_rec_mutex_unlock (settings->mutex);
return (count);
@ -1465,7 +1488,7 @@ fluid_settings_option_concat (fluid_settings_t *settings, const char *name,
return (NULL);
}
setting = (fluid_str_setting_t*)node;
setting = &node->str;
/* Duplicate option list, count options and get total string length */
for (p = setting->options, count = 0, len = 0; p; p = p->next, count++)
@ -1541,7 +1564,7 @@ fluid_settings_foreach_iter (void* key, void* value, void* data)
if (s) bag->names = fluid_list_append (bag->names, s);
break;
case FLUID_SET_TYPE:
fluid_hashtable_foreach(((fluid_set_setting_t *)value)->hashtable,
fluid_hashtable_foreach(node->set.hashtable,
fluid_settings_foreach_iter, bag);
break;
}