mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
pod: add HARDWARE flag to spa_pod_prop
Add HARDWARE flag to mark a property that does some hardware control. Mark the device volume/mute property as HARDWARE or not. Use the HARDWARE property in pulse to set the right flags.
This commit is contained in:
parent
8e6b276d51
commit
cf8db93cd4
5 changed files with 25 additions and 11 deletions
|
|
@ -344,7 +344,7 @@ static void device_event_info(void *object, const struct pw_device_info *info)
|
|||
global_sync(g);
|
||||
}
|
||||
|
||||
static void parse_props(struct global *g, const struct spa_pod *param, bool hw)
|
||||
static void parse_props(struct global *g, const struct spa_pod *param, bool device)
|
||||
{
|
||||
struct spa_pod_prop *prop;
|
||||
struct spa_pod_object *obj = (struct spa_pod_object *) param;
|
||||
|
|
@ -353,11 +353,15 @@ static void parse_props(struct global *g, const struct spa_pod *param, bool hw)
|
|||
switch (prop->key) {
|
||||
case SPA_PROP_volume:
|
||||
spa_pod_get_float(&prop->value, &g->node_info.volume);
|
||||
SPA_FLAG_UPDATE(g->node_info.flags, NODE_FLAG_HW_VOLUME, hw);
|
||||
SPA_FLAG_UPDATE(g->node_info.flags, NODE_FLAG_DEVICE_VOLUME, device);
|
||||
SPA_FLAG_UPDATE(g->node_info.flags, NODE_FLAG_HW_VOLUME,
|
||||
prop->flags & SPA_POD_PROP_FLAG_HARDWARE);
|
||||
break;
|
||||
case SPA_PROP_mute:
|
||||
spa_pod_get_bool(&prop->value, &g->node_info.mute);
|
||||
SPA_FLAG_UPDATE(g->node_info.flags, NODE_FLAG_HW_MUTE, hw);
|
||||
SPA_FLAG_UPDATE(g->node_info.flags, NODE_FLAG_DEVICE_MUTE, device);
|
||||
SPA_FLAG_UPDATE(g->node_info.flags, NODE_FLAG_HW_MUTE,
|
||||
prop->flags & SPA_POD_PROP_FLAG_HARDWARE);
|
||||
break;
|
||||
case SPA_PROP_channelVolumes:
|
||||
{
|
||||
|
|
@ -375,7 +379,9 @@ static void parse_props(struct global *g, const struct spa_pod *param, bool hw)
|
|||
* params are updated */
|
||||
g->init = true;
|
||||
}
|
||||
SPA_FLAG_UPDATE(g->node_info.flags, NODE_FLAG_HW_VOLUME, hw);
|
||||
SPA_FLAG_UPDATE(g->node_info.flags, NODE_FLAG_DEVICE_VOLUME, device);
|
||||
SPA_FLAG_UPDATE(g->node_info.flags, NODE_FLAG_HW_VOLUME,
|
||||
prop->flags & SPA_POD_PROP_FLAG_HARDWARE);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -806,7 +812,7 @@ static void node_event_param(void *object, int seq,
|
|||
|
||||
switch (id) {
|
||||
case SPA_PARAM_Props:
|
||||
if (!SPA_FLAG_IS_SET(g->node_info.flags, NODE_FLAG_HW_VOLUME | NODE_FLAG_HW_MUTE))
|
||||
if (!SPA_FLAG_IS_SET(g->node_info.flags, NODE_FLAG_DEVICE_VOLUME | NODE_FLAG_DEVICE_MUTE))
|
||||
parse_props(g, param, false);
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -273,7 +273,9 @@ struct global {
|
|||
uint32_t client_id; /* if of owner client */
|
||||
uint32_t monitor;
|
||||
#define NODE_FLAG_HW_VOLUME (1 << 0)
|
||||
#define NODE_FLAG_DEVICE_VOLUME (1 << 1)
|
||||
#define NODE_FLAG_HW_MUTE (1 << 4)
|
||||
#define NODE_FLAG_DEVICE_MUTE (1 << 5)
|
||||
uint32_t flags;
|
||||
float volume;
|
||||
bool mute;
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ static int set_volume(pa_context *c, struct global *g, const pa_cvolume *volume,
|
|||
|
||||
pw_log_info("card:%u global:%u flags:%08x", card_id, g->id, g->node_info.flags);
|
||||
|
||||
if (SPA_FLAG_IS_SET(g->node_info.flags, NODE_FLAG_HW_VOLUME | NODE_FLAG_HW_MUTE) &&
|
||||
if (SPA_FLAG_IS_SET(g->node_info.flags, NODE_FLAG_DEVICE_VOLUME | NODE_FLAG_DEVICE_MUTE) &&
|
||||
(cg = pa_context_find_global(c, card_id)) != NULL) {
|
||||
if (mask & PA_SUBSCRIPTION_MASK_SINK)
|
||||
id = cg->card_info.active_port_output;
|
||||
|
|
|
|||
|
|
@ -194,6 +194,7 @@ struct spa_pod_fd {
|
|||
struct spa_pod_prop {
|
||||
uint32_t key; /**< key of property, list of valid keys depends on the
|
||||
* object type */
|
||||
#define SPA_POD_PROP_FLAG_HARDWARE (1u<<0) /**< property for some sort of hardware parameter */
|
||||
uint32_t flags; /**< flags for property */
|
||||
struct spa_pod value;
|
||||
/* value follows */
|
||||
|
|
|
|||
|
|
@ -354,11 +354,15 @@ static struct spa_pod *build_route(struct spa_pod_builder *b, uint32_t id,
|
|||
|
||||
spa_pod_builder_prop(b, SPA_PARAM_ROUTE_props, 0);
|
||||
spa_pod_builder_push_object(b, &f[1], SPA_TYPE_OBJECT_Props, id);
|
||||
spa_pod_builder_add(b,
|
||||
SPA_PROP_mute, SPA_POD_Bool(mute),
|
||||
SPA_PROP_channelVolumes, SPA_POD_Array(sizeof(float),
|
||||
SPA_TYPE_Float, channels, volumes),
|
||||
0);
|
||||
spa_pod_builder_prop(b, SPA_PROP_mute,
|
||||
SPA_FLAG_IS_SET(dev->flags, ACP_DEVICE_HW_MUTE) ?
|
||||
SPA_POD_PROP_FLAG_HARDWARE : 0);
|
||||
spa_pod_builder_bool(b, mute);
|
||||
spa_pod_builder_prop(b, SPA_PROP_channelVolumes,
|
||||
SPA_FLAG_IS_SET(dev->flags, ACP_DEVICE_HW_VOLUME) ?
|
||||
SPA_POD_PROP_FLAG_HARDWARE : 0);
|
||||
spa_pod_builder_array(b, sizeof(float), SPA_TYPE_Float,
|
||||
channels, volumes);
|
||||
spa_pod_builder_pop(b, &f[1]);
|
||||
}
|
||||
return spa_pod_builder_pop(b, &f[0]);
|
||||
|
|
@ -698,6 +702,7 @@ static void on_set_soft_mute(void *data, struct acp_device *dev,
|
|||
spa_pod_builder_prop(&b, SPA_EVENT_DEVICE_Object, 0);
|
||||
spa_pod_builder_int(&b, dev->index);
|
||||
spa_pod_builder_prop(&b, SPA_EVENT_DEVICE_Props, 0);
|
||||
|
||||
spa_pod_builder_add_object(&b,
|
||||
SPA_TYPE_OBJECT_Props, SPA_EVENT_DEVICE_Props,
|
||||
SPA_PROP_mute, SPA_POD_Bool(mute));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue