Commit 37623888 authored by George Kiagiadakis's avatar George Kiagiadakis
Browse files

spa-type: refactor

* Use a more complete API to introspect SPA types
* Avoid the need for the Tables enumeration; the tables
  are now registered with a string
* Avoid the need for initialization, work directly on spa_types
  and other static data
* Allow working with Object pods that are not Params;
  the PARAMS table was previously hardcoded in the pod implementation
* Add a different dynamic type registration system, closer to
  how spa type works. The only regression is that we can no longer
  register additional custom object fields (custom SPA_PROP_* for example),
  but this feature can be re-added later
parent 7488ec0e
......@@ -535,19 +535,20 @@ wp_impl_endpoint_stream_set_param (gpointer instance, guint32 id, guint32 flags,
WpImplEndpointStream *self = WP_IMPL_ENDPOINT_STREAM (instance);
g_autoptr (WpPipewireObject) node = wp_session_item_get_associated_proxy (
WP_SESSION_ITEM (self->item), WP_TYPE_NODE);
const gchar *idstr = NULL;
if (!node) {
wp_warning_object (self, "associated node is no longer available");
return -EPIPE;
}
if (!wp_spa_type_get_by_id (WP_SPA_TYPE_TABLE_PARAM, id, NULL, &idstr, NULL)) {
WpSpaIdValue idval = wp_spa_id_value_from_number ("Spa:Enum:ParamId", id);
if (!idval) {
wp_critical_object (self, "invalid param id: %u", id);
return -EINVAL;
}
return wp_pipewire_object_set_param (node, idstr, flags, param) ? 0 : -EIO;
return wp_pipewire_object_set_param (node, wp_spa_id_value_short_name (idval),
flags, param) ? 0 : -EIO;
}
#define pw_endpoint_stream_emit(hooks,method,version,...) \
......
......@@ -1081,19 +1081,20 @@ wp_impl_endpoint_set_param (gpointer instance, guint32 id, guint32 flags,
WpImplEndpoint *self = WP_IMPL_ENDPOINT (instance);
g_autoptr (WpPipewireObject) node = wp_session_item_get_associated_proxy (
WP_SESSION_ITEM (self->item), WP_TYPE_NODE);
const gchar *idstr = NULL;
if (!node) {
wp_warning_object (self, "associated node is no longer available");
return -EPIPE;
}
if (!wp_spa_type_get_by_id (WP_SPA_TYPE_TABLE_PARAM, id, NULL, &idstr, NULL)) {
WpSpaIdValue idval = wp_spa_id_value_from_number ("Spa:Enum:ParamId", id);
if (!idval) {
wp_critical_object (self, "invalid param id: %u", id);
return -EINVAL;
}
return wp_pipewire_object_set_param (node, idstr, flags, param) ? 0 : -EIO;
return wp_pipewire_object_set_param (node, wp_spa_id_value_short_name (idval),
flags, param) ? 0 : -EIO;
}
#define pw_endpoint_emit(hooks,method,version,...) \
......
......@@ -83,12 +83,13 @@ wp_pw_object_mixin_get_param_info (WpPipewireObject * obj)
g_variant_builder_init (&b, G_VARIANT_TYPE ("a{ss}"));
for (guint i = 0; i < n_params; i++) {
WpSpaIdValue idval;
const gchar *nick = NULL;
gchar flags[3];
guint flags_idx = 0;
wp_spa_type_get_by_id (WP_SPA_TYPE_TABLE_PARAM, info[i].id, NULL, &nick,
NULL);
idval = wp_spa_id_value_from_number ("Spa:Enum:ParamId", info[i].id);
nick = wp_spa_id_value_short_name (idval);
g_return_val_if_fail (nick != NULL, NULL);
if (info[i].flags & SPA_PARAM_INFO_READ)
......@@ -170,8 +171,8 @@ wp_pw_object_mixin_enum_params_unchecked (gpointer obj,
/* debug */
if (wp_log_level_is_enabled (G_LOG_LEVEL_DEBUG)) {
const gchar *name = NULL;
wp_spa_type_get_by_id (WP_SPA_TYPE_TABLE_PARAM, id, &name, NULL, NULL);
name = wp_spa_id_value_short_name (
wp_spa_id_value_from_number ("Spa:Enum:ParamId", id));
wp_debug_object (obj, "enum id %u (%s), seq 0x%x (%u), task "
WP_OBJECT_FORMAT "%s", id, name, seq, seq, WP_OBJECT_ARGS (task),
iface->enum_params_sync ? ", sync" : "");
......@@ -199,7 +200,7 @@ wp_pw_object_mixin_enum_params (WpPipewireObject * obj, const gchar * id,
GAsyncReadyCallback callback, gpointer user_data)
{
WpPwObjectMixinPrivInterface *iface = WP_PW_OBJECT_MIXIN_PRIV_GET_IFACE (obj);
guint32 param_id = 0;
WpSpaIdValue param_id;
if (!(iface->enum_params || iface->enum_params_sync)) {
g_task_report_new_error (obj, callback, user_data, NULL,
......@@ -209,13 +210,14 @@ wp_pw_object_mixin_enum_params (WpPipewireObject * obj, const gchar * id,
}
/* translate the id */
if (!wp_spa_type_get_by_nick (WP_SPA_TYPE_TABLE_PARAM, id, &param_id,
NULL, NULL)) {
param_id = wp_spa_id_value_from_short_name ("Spa:Enum:ParamId", id);
if (!param_id) {
wp_critical_object (obj, "invalid param id: %s", id);
return;
}
wp_pw_object_mixin_enum_params_unchecked (obj, param_id, filter,
wp_pw_object_mixin_enum_params_unchecked (obj,
wp_spa_id_value_number (param_id), filter,
cancellable, callback, user_data);
}
......@@ -238,22 +240,24 @@ wp_pw_object_mixin_enum_params_sync (WpPipewireObject * obj, const gchar * id,
{
WpPwObjectMixinPrivInterface *iface = WP_PW_OBJECT_MIXIN_PRIV_GET_IFACE (obj);
GPtrArray *params = NULL;
guint32 param_id = 0;
WpSpaIdValue param_id;
/* translate the id */
if (!wp_spa_type_get_by_nick (WP_SPA_TYPE_TABLE_PARAM, id, &param_id,
NULL, NULL)) {
param_id = wp_spa_id_value_from_short_name ("Spa:Enum:ParamId", id);
if (!param_id) {
wp_critical_object (obj, "invalid param id: %s", id);
return NULL;
}
if (iface->enum_params_sync) {
/* use enum_params_sync if supported */
params = iface->enum_params_sync (obj, param_id, 0, -1, filter);
params = iface->enum_params_sync (obj, wp_spa_id_value_number (param_id),
0, -1, filter);
} else {
/* otherwise, find and return the cached params */
WpPwObjectMixinData *data = wp_pw_object_mixin_get_data (obj);
params = wp_pw_object_mixin_get_stored_params (data, param_id);
params = wp_pw_object_mixin_get_stored_params (data,
wp_spa_id_value_number (param_id));
/* TODO filter */
}
......@@ -265,7 +269,7 @@ wp_pw_object_mixin_set_param (WpPipewireObject * obj, const gchar * id,
guint32 flags, WpSpaPod * param)
{
WpPwObjectMixinPrivInterface *iface = WP_PW_OBJECT_MIXIN_PRIV_GET_IFACE (obj);
guint32 param_id = 0;
WpSpaIdValue param_id;
gint ret;
if (!iface->set_param) {
......@@ -273,14 +277,14 @@ wp_pw_object_mixin_set_param (WpPipewireObject * obj, const gchar * id,
return FALSE;
}
if (!wp_spa_type_get_by_nick (WP_SPA_TYPE_TABLE_PARAM, id, &param_id,
NULL, NULL)) {
param_id = wp_spa_id_value_from_short_name ("Spa:Enum:ParamId", id);
if (!param_id) {
wp_critical_object (obj, "invalid param id: %s", id);
wp_spa_pod_unref (param);
return FALSE;
}
ret = iface->set_param (obj, param_id, flags, param);
ret = iface->set_param (obj, wp_spa_id_value_number (param_id), flags, param);
if (G_UNLIKELY (SPA_RESULT_IS_ERROR (ret))) {
wp_message_object (obj, "set_param failed: %s", spa_strerror (ret));
......@@ -940,7 +944,8 @@ wp_pw_object_mixin_notify_params_changed (gpointer instance, guint32 id)
if (wp_log_level_is_enabled (G_LOG_LEVEL_DEBUG)) {
const gchar *name = NULL;
wp_spa_type_get_by_id (WP_SPA_TYPE_TABLE_PARAM, id, &name, NULL, NULL);
name = wp_spa_id_value_short_name (wp_spa_id_value_from_number (
"Spa:Enum:ParamId", id));
wp_debug_object (instance, "notify param id:%u (%s)", id, name);
}
......
This diff is collapsed.
......@@ -13,6 +13,7 @@
#include "defs.h"
#include "iterator.h"
#include "spa-type.h"
G_BEGIN_DECLS
......@@ -45,19 +46,16 @@ WP_API
const struct spa_pod * wp_spa_pod_get_spa_pod (const WpSpaPod *self);
WP_API
const char *wp_spa_pod_get_type_name (WpSpaPod *self);
WpSpaType wp_spa_pod_get_spa_type (WpSpaPod *self);
WP_API
const char *wp_spa_pod_get_choice_type_name (WpSpaPod *self);
WP_API
const char *wp_spa_pod_get_object_type_name (WpSpaPod *self);
WpSpaIdValue wp_spa_pod_get_choice_type (WpSpaPod *self);
WP_API
WpSpaPod *wp_spa_pod_copy (WpSpaPod *other);
WP_API
gboolean wp_spa_pod_is_unique_owner ( WpSpaPod *self);
gboolean wp_spa_pod_is_unique_owner (WpSpaPod *self);
WP_API
WpSpaPod *wp_spa_pod_ensure_unique_owner (WpSpaPod *self);
......@@ -102,11 +100,11 @@ WP_API
WpSpaPod *wp_spa_pod_new_fraction (guint32 num, guint32 denom);
WP_API
WpSpaPod *wp_spa_pod_new_choice (const char *type_name, ...)
WpSpaPod *wp_spa_pod_new_choice (const char *choice_type, ...)
G_GNUC_NULL_TERMINATED;
WP_API
WpSpaPod *wp_spa_pod_new_choice_valist (const char *type_name, va_list args);
WpSpaPod *wp_spa_pod_new_choice_valist (const char *choice_type, va_list args);
WP_API
WpSpaPod *wp_spa_pod_new_object (const char *type_name, const char *id_name,
......@@ -208,8 +206,7 @@ gboolean wp_spa_pod_get_bytes (WpSpaPod *self, gconstpointer *value,
guint32 *len);
WP_API
gboolean wp_spa_pod_get_pointer (WpSpaPod *self, const char **type_name,
gconstpointer *value);
gboolean wp_spa_pod_get_pointer (WpSpaPod *self, gconstpointer *value);
WP_API
gboolean wp_spa_pod_get_fd (WpSpaPod *self, gint64 *value);
......@@ -260,11 +257,11 @@ WP_API
gboolean wp_spa_pod_equal (WpSpaPod *self, WpSpaPod *pod);
WP_API
gboolean wp_spa_pod_get_object (WpSpaPod *self, const char *type_name,
gboolean wp_spa_pod_get_object (WpSpaPod *self,
const char **id_name, ...) G_GNUC_NULL_TERMINATED;
WP_API
gboolean wp_spa_pod_get_object_valist (WpSpaPod *self, const char *type_name,
gboolean wp_spa_pod_get_object_valist (WpSpaPod *self,
const char **id_name, va_list args);
WP_API
......@@ -279,7 +276,7 @@ gboolean wp_spa_pod_get_property (WpSpaPod *self, const char **key,
WP_API
gboolean wp_spa_pod_get_control (WpSpaPod *self, guint32 *offset,
const char **type_name, WpSpaPod **value);
const char **ctl_type, WpSpaPod **value);
WP_API
WpSpaPod *wp_spa_pod_get_choice_child (WpSpaPod *self);
......@@ -314,7 +311,7 @@ WP_API
WpSpaPodBuilder *wp_spa_pod_builder_new_array (void);
WP_API
WpSpaPodBuilder *wp_spa_pod_builder_new_choice (const char *type_name);
WpSpaPodBuilder *wp_spa_pod_builder_new_choice (const char *choice_type);
WP_API
WpSpaPodBuilder *wp_spa_pod_builder_new_object (const char *type_name,
......@@ -380,7 +377,7 @@ void wp_spa_pod_builder_add_property_id (WpSpaPodBuilder *self, guint32 id);
WP_API
void wp_spa_pod_builder_add_control (WpSpaPodBuilder *self, guint32 offset,
const char *type_name);
const char *ctl_type);
WP_API
void wp_spa_pod_builder_add (WpSpaPodBuilder *self, ...) G_GNUC_NULL_TERMINATED;
......@@ -413,7 +410,7 @@ void wp_spa_pod_parser_unref (WpSpaPodParser *self);
WP_API
WpSpaPodParser *wp_spa_pod_parser_new_object (WpSpaPod *pod,
const char *type_name, const char **id_name);
const char **id_name);
WP_API
WpSpaPodParser *wp_spa_pod_parser_new_struct (WpSpaPod *pod);
......@@ -446,7 +443,7 @@ gboolean wp_spa_pod_parser_get_bytes (WpSpaPodParser *self,
WP_API
gboolean wp_spa_pod_parser_get_pointer (WpSpaPodParser *self,
const char **type_name, gconstpointer *value);
gconstpointer *value);
WP_API
gboolean wp_spa_pod_parser_get_fd (WpSpaPodParser *self, gint64 *value);
......
This diff is collapsed.
......@@ -9,63 +9,121 @@
#ifndef __WIREPLUMBER_SPA_TYPE_H__
#define __WIREPLUMBER_SPA_TYPE_H__
#include <gio/gio.h>
#include "defs.h"
#include "iterator.h"
G_BEGIN_DECLS
/**
* WpSpaTypeTable:
* @WP_SPA_TYPE_TABLE_BASIC: The basic type table
* @WP_SPA_TYPE_TABLE_PARAM: The param type table (used as object id)
* @WP_SPA_TYPE_TABLE_PROPS: The object properties type table
* @WP_SPA_TYPE_TABLE_PROP_INFO: The object property info type table
* @WP_SPA_TYPE_TABLE_CONTROL: The sequence control type table
* @WP_SPA_TYPE_TABLE_CHOICE: The choice type table
* @WP_SPA_TYPE_TABLE_FORMAT: The object format type table
* @WP_SPA_TYPE_TABLE_PARAM_PORT_CONFIG: The object param port config type table
* @WP_SPA_TYPE_TABLE_PARAM_PROFILE: The sequence control type table
* @WP_SPA_TYPE_TABLE_AUDIO_CHANNEL: The audio channel type table
*
* The diferent tables (namespaces) the registry has.
*/
typedef enum {
WP_SPA_TYPE_TABLE_BASIC = 0,
WP_SPA_TYPE_TABLE_PARAM,
WP_SPA_TYPE_TABLE_PROPS,
WP_SPA_TYPE_TABLE_PROP_INFO,
WP_SPA_TYPE_TABLE_CONTROL,
WP_SPA_TYPE_TABLE_CHOICE,
WP_SPA_TYPE_TABLE_FORMAT,
WP_SPA_TYPE_TABLE_PARAM_PORT_CONFIG,
WP_SPA_TYPE_TABLE_PARAM_PROFILE,
WP_SPA_TYPE_TABLE_AUDIO_CHANNEL,
WP_SPA_TYPE_TABLE_LAST,
} WpSpaTypeTable;
typedef guint32 WpSpaType;
typedef gconstpointer WpSpaIdTable;
typedef gconstpointer WpSpaIdValue;
struct spa_type_info;
/* WpSpaType */
#define WP_TYPE_SPA_TYPE (wp_spa_type_get_type ())
WP_API
GType wp_spa_type_get_type (void);
static const WpSpaType WP_SPA_TYPE_INVALID = 0xffffffff;
WP_API
WpSpaType wp_spa_type_from_name (const gchar *name);
WP_API
WpSpaType wp_spa_type_parent (WpSpaType type);
WP_API
const gchar * wp_spa_type_name (WpSpaType type);
WP_API
gboolean wp_spa_type_is_fundamental (WpSpaType type);
WP_API
gboolean wp_spa_type_is_id (WpSpaType type);
WP_API
gboolean wp_spa_type_is_object (WpSpaType type);
WP_API
WpSpaIdTable wp_spa_type_get_object_id_values_table (WpSpaType type);
WP_API
WpSpaIdTable wp_spa_type_get_values_table (WpSpaType type);
/* WpSpaIdTable */
#define WP_TYPE_SPA_ID_TABLE (wp_spa_id_table_get_type ())
WP_API
GType wp_spa_id_table_get_type (void);
WP_API
void wp_spa_type_init (gboolean register_spa);
WpSpaIdTable wp_spa_id_table_from_name (const gchar *name);
WP_API
void wp_spa_type_deinit (void);
WpIterator * wp_spa_id_table_iterate (WpSpaIdTable table);
WP_API
size_t wp_spa_type_get_table_size (WpSpaTypeTable table);
WpSpaIdValue wp_spa_id_table_find_value (WpSpaIdTable table, guint value);
WP_API
WpSpaIdValue wp_spa_id_table_find_value_from_name (WpSpaIdTable table,
const gchar * name);
WP_API
WpSpaIdValue wp_spa_id_table_find_value_from_short_name (WpSpaIdTable table,
const gchar * short_name);
/* WpSpaIdValue */
#define WP_TYPE_SPA_ID_VALUE (wp_spa_id_value_get_type ())
WP_API
GType wp_spa_id_value_get_type (void);
WP_API
WpSpaIdValue wp_spa_id_value_from_name (const gchar * name);
WP_API
WpSpaIdValue wp_spa_id_value_from_short_name (const gchar * table_name,
const gchar * short_name);
WP_API
WpSpaIdValue wp_spa_id_value_from_number (const gchar * table_name, guint id);
WP_API
guint wp_spa_id_value_number (WpSpaIdValue id);
WP_API
const gchar * wp_spa_id_value_name (WpSpaIdValue id);
WP_API
const gchar * wp_spa_id_value_short_name (WpSpaIdValue id);
WP_API
WpSpaType wp_spa_id_value_get_value_type (WpSpaIdValue id, WpSpaIdTable *table);
WP_API
WpSpaType wp_spa_id_value_array_get_item_type (WpSpaIdValue id,
WpSpaIdTable *table);
/* Dynamic type registration */
WP_API
gboolean wp_spa_type_register (WpSpaTypeTable table, const char *name,
const char *nick);
void wp_spa_dynamic_type_init (void);
WP_API
void wp_spa_type_unregister (WpSpaTypeTable table, const char *nick);
void wp_spa_dynamic_type_deinit (void);
WP_API
gboolean wp_spa_type_get_by_nick (WpSpaTypeTable table, const char *nick,
guint32 *id, const char **name, WpSpaTypeTable *values_table);
WpSpaType wp_spa_dynamic_type_register (const gchar *name, WpSpaType parent,
const struct spa_type_info * values);
WP_API
gboolean wp_spa_type_get_by_id (WpSpaTypeTable table, guint32 id,
const char **name, const char **nick, WpSpaTypeTable *values_table);
WpSpaIdTable wp_spa_dynamic_id_table_register (const gchar *name,
const struct spa_type_info * values);
G_END_DECLS
......
......@@ -63,7 +63,7 @@ wp_init (WpInitFlags flags)
pw_log_set_level (lvl);
if (flags & WP_INIT_SPA_TYPES)
wp_spa_type_init (TRUE);
wp_spa_dynamic_type_init ();
/* ensure WpProxy subclasses are loaded, which is needed to be able
to autodetect the GType of proxies created through wp_proxy_new_global() */
......
......@@ -42,7 +42,7 @@ set_device_profile (WpPipewireObject *device, gint index)
{
g_return_if_fail (device);
g_autoptr (WpSpaPod) profile = wp_spa_pod_new_object (
"Profile", "Profile",
"Spa:Pod:Object:Param:Profile", "Profile",
"index", "i", index,
NULL);
wp_debug_object (device, "set profile %d", index);
......
......@@ -63,8 +63,7 @@ find_device_profile (WpPipewireObject *device, const gchar *lookup_name)
const gchar *name = NULL;
/* Parse */
if (!wp_spa_pod_get_object (pod,
"Profile", NULL,
if (!wp_spa_pod_get_object (pod, NULL,
"index", "i", &index,
"name", "s", &name,
NULL)) {
......@@ -191,8 +190,7 @@ on_device_profile_notified (WpPipewireObject *device, GAsyncResult *res,
/* Parse the profile */
WpSpaPod *pod = g_value_get_boxed (&item);
if (!wp_spa_pod_get_object (pod,
"Profile", NULL,
if (!wp_spa_pod_get_object (pod, NULL,
"index", "i", &index,
"name", "s", &name,
NULL)) {
......
......@@ -34,7 +34,7 @@ set_device_profile (WpDeviceActivation *self,
/* Set profile */
wp_pipewire_object_set_param (device, "Profile", 0,
wp_spa_pod_new_object (
"Profile", "Profile",
"Spa:Pod:Object:Param:Profile", "Profile",
"index", "i", index,
NULL));
......@@ -72,8 +72,7 @@ on_device_enum_profile_done (WpPipewireObject *proxy, GAsyncResult *res,
const gchar *n = NULL;
/* Parse */
if (!wp_spa_pod_get_object (pod,
"Profile", NULL,
if (!wp_spa_pod_get_object (pod, NULL,
"index", "i", &i,
"name", "s", &n,
NULL)) {
......
......@@ -207,8 +207,7 @@ on_device_enum_profile_done (WpPipewireObject *proxy, GAsyncResult *res,
/* Parse profile */
{
g_autoptr (WpSpaPodParser) pp = wp_spa_pod_parser_new_object (pod,
"Profile", NULL);
g_autoptr (WpSpaPodParser) pp = wp_spa_pod_parser_new_object (pod, NULL);
g_return_if_fail (pp);
g_return_if_fail (wp_spa_pod_parser_get (pp, "index", "i", &index, NULL));
if (index == 0) {
......
......@@ -259,7 +259,7 @@ static WpSpaPod *
format_audio_raw_build (const struct spa_audio_info_raw *info)
{
g_autoptr (WpSpaPodBuilder) builder = wp_spa_pod_builder_new_object (
"Format", "Format");
"Spa:Pod:Object:Param:Format", "Format");
wp_spa_pod_builder_add (builder,
"mediaType", "I", SPA_MEDIA_TYPE_audio,
"mediaSubtype", "I", SPA_MEDIA_SUBTYPE_raw,
......@@ -327,7 +327,8 @@ si_adapter_activate_execute_step (WpSessionItem * item,
self->format.channels, self->format.rate);
port_format = format_audio_raw_build (&self->format);
pod = wp_spa_pod_new_object ("PortConfig", "PortConfig",
pod = wp_spa_pod_new_object (
"Spa:Pod:Object:Param:PortConfig", "PortConfig",
"direction", "I", self->direction,
"mode", "I", SPA_PARAM_PORT_CONFIG_MODE_dsp,
"monitor", "b", self->monitor,
......@@ -543,8 +544,12 @@ si_adapter_get_ports (WpSiPortInfo * item, const gchar * context)
/* try to find the audio channel; if channel is NULL, this will silently
leave the channel_id to its default value, 0 */
channel = wp_properties_get (props, PW_KEY_AUDIO_CHANNEL);
wp_spa_type_get_by_nick (WP_SPA_TYPE_TABLE_AUDIO_CHANNEL, channel,
&channel_id, NULL, NULL);
if (channel) {
WpSpaIdValue idval = wp_spa_id_value_from_short_name (
"Spa:Enum:AudioChannel", channel);
if (idval)
channel_id = wp_spa_id_value_number (idval);
}
g_variant_builder_add (&b, "(uuu)", node_id, port_id, channel_id);
}
......
......@@ -84,16 +84,17 @@ select_format (WpSpaPod *value)
return ret;
}
const gchar * choice_type_name = wp_spa_pod_get_choice_type_name (value);
guint32 choice_type =
wp_spa_id_value_number (wp_spa_pod_get_choice_type (value));
/* None */
if (g_strcmp0 ("None", choice_type_name) == 0) {
if (choice_type == SPA_CHOICE_None) {
g_autoptr (WpSpaPod) child = wp_spa_pod_get_choice_child (value);
wp_spa_pod_get_id (child, &ret);
}
/* Enum */
else if (g_strcmp0 ("Enum", choice_type_name) == 0) {
else if (choice_type == SPA_CHOICE_Enum) {
g_autoptr (WpIterator) it = wp_spa_pod_iterate (value);
GValue next = G_VALUE_INIT;
while (wp_iterator_next (it, &next)) {
......@@ -125,16 +126,17 @@ select_rate (WpSpaPod *value)
return ret;
}
const gchar * choice_type_name = wp_spa_pod_get_choice_type_name (value);
guint32 choice_type =
wp_spa_id_value_number (wp_spa_pod_get_choice_type (value));
/* None */
if (g_strcmp0 ("None", choice_type_name) == 0) {
if (choice_type == SPA_CHOICE_None) {
g_autoptr (WpSpaPod) child = wp_spa_pod_get_choice_child (value);
wp_spa_pod_get_int (child, &ret);
}
/* Enum */
else if (g_strcmp0 ("Enum", choice_type_name) == 0) {
else if (choice_type == SPA_CHOICE_Enum) {
/* pick the one closest to 48Khz */
g_autoptr (WpIterator) it = wp_spa_pod_iterate (value);
GValue next = G_VALUE_INIT;
......@@ -147,7 +149,7 @@ select_rate (WpSpaPod *value)
}
/* Range */
else if (g_strcmp0 ("Range", choice_type_name) == 0) {
else if (choice_type == SPA_CHOICE_Range) {
/* a range is typically 3 items: default, min, max;
however, sometimes ALSA drivers give bad min & max values
and pipewire picks a bad default... try to fix that here;
......@@ -180,16 +182,17 @@ select_channels (WpSpaPod *value, gint preference)
return ret;
}
const gchar * choice_type_name = wp_spa_pod_get_choice_type_name (value);
guint32 choice_type =
wp_spa_id_value_number (wp_spa_pod_get_choice_type (value));
/* None */
if (g_strcmp0 ("None", choice_type_name) == 0) {
if (choice_type == SPA_CHOICE_None