Commit bfaf8988 authored by nedko's avatar nedko
Browse files

Transform range bool into flags

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2992 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 5f19deec
......@@ -915,12 +915,12 @@ EXPORT const char * jackctl_parameter_get_long_description(jackctl_parameter *pa
EXPORT bool jackctl_parameter_has_range_constraint(jackctl_parameter *parameter_ptr)
{
return parameter_ptr->constraint_ptr != NULL && parameter_ptr->constraint_ptr->range;
return parameter_ptr->constraint_ptr != NULL && (parameter_ptr->constraint_ptr->flags & JACK_CONSTRAINT_FLAG_RANGE) != 0;
}
EXPORT bool jackctl_parameter_has_enum_constraint(jackctl_parameter *parameter_ptr)
{
return parameter_ptr->constraint_ptr != NULL && !parameter_ptr->constraint_ptr->range;
return parameter_ptr->constraint_ptr != NULL && (parameter_ptr->constraint_ptr->flags & JACK_CONSTRAINT_FLAG_RANGE) == 0;
}
EXPORT uint32_t jackctl_parameter_get_enum_constraints_count(jackctl_parameter *parameter_ptr)
......@@ -985,6 +985,16 @@ EXPORT void jackctl_parameter_get_range_constraint(jackctl_parameter *parameter_
}
}
EXPORT bool jackctl_parameter_constraint_is_strict(jackctl_parameter_t * parameter_ptr)
{
return parameter_ptr->constraint_ptr != NULL && (parameter_ptr->constraint_ptr->flags & JACK_CONSTRAINT_FLAG_STRICT) != 0;
}
EXPORT bool jackctl_parameter_constraint_is_fake_value(jackctl_parameter_t * parameter_ptr)
{
return parameter_ptr->constraint_ptr != NULL && (parameter_ptr->constraint_ptr->flags & JACK_CONSTRAINT_FLAG_FAKE_VALUE) != 0;
}
EXPORT jackctl_param_type_t jackctl_parameter_get_type(jackctl_parameter *parameter_ptr)
{
return parameter_ptr->type;
......
......@@ -192,6 +192,14 @@ jackctl_parameter_get_range_constraint(
union jackctl_parameter_value * min_ptr,
union jackctl_parameter_value * max_ptr);
EXPORT bool
jackctl_parameter_constraint_is_strict(
jackctl_parameter_t * parameter_ptr);
EXPORT bool
jackctl_parameter_constraint_is_fake_value(
jackctl_parameter_t * parameter_ptr);
EXPORT const JSList *
jackctl_server_get_internals_list(
jackctl_server *server_ptr);
......
......@@ -37,6 +37,10 @@ extern "C"
#define JACK_DRIVER_PARAM_DESC 255
#define JACK_PATH_MAX 511
#define JACK_CONSTRAINT_FLAG_RANGE ((uint32_t)1) /**< if set, constraint is a range (min-max) */
#define JACK_CONSTRAINT_FLAG_STRICT ((uint32_t)2) /**< if set, constraint is strict, i.e. supplying non-matching value will not work */
#define JACK_CONSTRAINT_FLAG_FAKE_VALUE ((uint32_t)2) /**< if set, values have no user meaningful meaning */
/** Driver parameter types */
typedef enum
{
......@@ -62,18 +66,18 @@ extern "C"
} jack_driver_param_value_enum_t;
typedef struct {
uint32_t range; /**< if not 0 - constraint is a range (min-max), if zero - it is an enumeration */
uint32_t flags; /**< JACK_CONSTRAINT_FLAG_XXX */
union {
struct {
jack_driver_param_value_t min;
jack_driver_param_value_t max;
} range;
} range; /**< valid when JACK_CONSTRAINT_FLAG_RANGE flag is set */
struct {
uint32_t count;
jack_driver_param_value_enum_t * possible_values_array;
} enumeration;
} enumeration; /**< valid when JACK_CONSTRAINT_FLAG_RANGE flag is not set */
} constraint;
} jack_driver_param_constraint_desc_t;
......
......@@ -339,6 +339,14 @@ jackctl_parameter_get_range_constraint(
union jackctl_parameter_value * min_ptr,
union jackctl_parameter_value * max_ptr);
bool
jackctl_parameter_constraint_is_strict(
jackctl_parameter_t * parameter_ptr);
bool
jackctl_parameter_constraint_is_fake_value(
jackctl_parameter_t * parameter_ptr);
/**
* Call this function to get list of available internal clients. List node data
* pointers is a internal client object handle (::jackctl_internal_t).
......
......@@ -424,8 +424,7 @@ jack_controller_get_parameter_constraint(
const char * descr;
jackctl_param_type_t type;
message_arg_t value;
jack_info("jack_controller_get_parameter_constraint() called.");
bool is_range;
call->reply = dbus_message_new_method_return(call->message);
if (!call->reply)
......@@ -435,15 +434,26 @@ jack_controller_get_parameter_constraint(
dbus_message_iter_init_append(call->reply, &iter);
value.boolean = jackctl_parameter_has_range_constraint(parameter);
is_range = jackctl_parameter_has_range_constraint(parameter);
value.boolean = is_range;
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &value))
{
goto fail_unref;
}
/* Append the is_set argument. */
value.boolean = jackctl_parameter_constraint_is_strict(parameter);
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &value))
{
goto fail_unref;
}
value.boolean = jackctl_parameter_constraint_is_fake_value(parameter);
if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &value))
{
goto fail_unref;
}
if (value.boolean)
if (is_range)
{
jack_info("parameter with range constraint");
......@@ -515,7 +525,7 @@ fail:
static
void
jack_controller_dbus_get_driver_parameter_constrinat(
jack_controller_dbus_get_driver_parameter_constraint(
struct jack_dbus_method_call * call)
{
const char * parameter_name;
......@@ -1165,7 +1175,7 @@ JACK_DBUS_METHOD_ARGUMENTS_END
JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetDriverParameterConstraint)
JACK_DBUS_METHOD_ARGUMENT("parameter", "s", false)
JACK_DBUS_METHOD_ARGUMENT("parameter_info", "ba(vs)", true)
JACK_DBUS_METHOD_ARGUMENT("parameter_info", "bbba(vs)", true)
JACK_DBUS_METHOD_ARGUMENTS_END
JACK_DBUS_METHOD_ARGUMENTS_BEGIN(GetDriverParameterValue)
......@@ -1236,7 +1246,7 @@ JACK_DBUS_METHODS_BEGIN
JACK_DBUS_METHOD_DESCRIBE(SelectDriver, jack_controller_dbus_select_driver)
JACK_DBUS_METHOD_DESCRIBE(GetDriverParametersInfo, jack_controller_dbus_get_driver_parameters_info)
JACK_DBUS_METHOD_DESCRIBE(GetDriverParameterInfo, jack_controller_dbus_get_driver_parameter_info)
JACK_DBUS_METHOD_DESCRIBE(GetDriverParameterConstraint, jack_controller_dbus_get_driver_parameter_constrinat)
JACK_DBUS_METHOD_DESCRIBE(GetDriverParameterConstraint, jack_controller_dbus_get_driver_parameter_constraint)
JACK_DBUS_METHOD_DESCRIBE(GetDriverParameterValue, jack_controller_dbus_get_driver_parameter_value)
JACK_DBUS_METHOD_DESCRIBE(SetDriverParameterValue, jack_controller_dbus_set_driver_parameter_value)
JACK_DBUS_METHOD_DESCRIBE(GetEngineParametersInfo, jack_controller_dbus_get_engine_parameters_info)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment