mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-04 13:30:12 -05:00
param: improve pw_param
Add a sequence number to pw_param. Add param_info to param_update to filter out the params of the latest sequence number. This can be used to track params from a certain sequence number. Update node, port and device.
This commit is contained in:
parent
a2278a5f70
commit
c5f7d3a728
5 changed files with 38 additions and 22 deletions
|
|
@ -235,7 +235,7 @@ static void remove_busy_resource(struct resource_data *d)
|
||||||
|
|
||||||
if (d->end != -1) {
|
if (d->end != -1) {
|
||||||
if (d->pi && d->data.cache) {
|
if (d->pi && d->data.cache) {
|
||||||
pw_param_update(&impl->param_list, &impl->pending_list);
|
pw_param_update(&impl->param_list, &impl->pending_list, 0, NULL);
|
||||||
d->pi->user = 1;
|
d->pi->user = 1;
|
||||||
d->pi = NULL;
|
d->pi = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -281,8 +281,8 @@ static void result_device_params(void *data, int seq, int res, uint32_t type, co
|
||||||
if (d->cache) {
|
if (d->cache) {
|
||||||
pw_log_debug("%p: add param %d", impl, r->id);
|
pw_log_debug("%p: add param %d", impl, r->id);
|
||||||
if (d->count++ == 0)
|
if (d->count++ == 0)
|
||||||
pw_param_add(&impl->pending_list, r->id, NULL);
|
pw_param_add(&impl->pending_list, seq, r->id, NULL);
|
||||||
pw_param_add(&impl->pending_list, r->id, r->param);
|
pw_param_add(&impl->pending_list, seq, r->id, r->param);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -367,7 +367,7 @@ int pw_impl_device_for_each_param(struct pw_impl_device *device,
|
||||||
spa_hook_remove(&listener);
|
spa_hook_remove(&listener);
|
||||||
|
|
||||||
if (!SPA_RESULT_IS_ASYNC(res) && user_data.cache) {
|
if (!SPA_RESULT_IS_ASYNC(res) && user_data.cache) {
|
||||||
pw_param_update(&impl->param_list, &impl->pending_list);
|
pw_param_update(&impl->param_list, &impl->pending_list, 0, NULL);
|
||||||
pi->user = 1;
|
pi->user = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1967,8 +1967,8 @@ static void result_node_params(void *data, int seq, int res, uint32_t type, cons
|
||||||
d->callback(d->data, seq, r->id, r->index, r->next, r->param);
|
d->callback(d->data, seq, r->id, r->index, r->next, r->param);
|
||||||
if (d->cache) {
|
if (d->cache) {
|
||||||
if (d->count++ == 0)
|
if (d->count++ == 0)
|
||||||
pw_param_add(&impl->pending_list, r->id, NULL);
|
pw_param_add(&impl->pending_list, seq, r->id, NULL);
|
||||||
pw_param_add(&impl->pending_list, r->id, r->param);
|
pw_param_add(&impl->pending_list, seq, r->id, r->param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -2055,7 +2055,7 @@ int pw_impl_node_for_each_param(struct pw_impl_node *node,
|
||||||
spa_hook_remove(&listener);
|
spa_hook_remove(&listener);
|
||||||
|
|
||||||
if (user_data.cache) {
|
if (user_data.cache) {
|
||||||
pw_param_update(&impl->param_list, &impl->pending_list);
|
pw_param_update(&impl->param_list, &impl->pending_list, 0, NULL);
|
||||||
pi->user = 1;
|
pi->user = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1199,8 +1199,8 @@ static void result_port_params(void *data, int seq, int res, uint32_t type, cons
|
||||||
d->callback(d->data, seq, r->id, r->index, r->next, r->param);
|
d->callback(d->data, seq, r->id, r->index, r->next, r->param);
|
||||||
if (d->cache) {
|
if (d->cache) {
|
||||||
if (d->count++ == 0)
|
if (d->count++ == 0)
|
||||||
pw_param_add(&impl->pending_list, r->id, NULL);
|
pw_param_add(&impl->pending_list, seq, r->id, NULL);
|
||||||
pw_param_add(&impl->pending_list, r->id, r->param);
|
pw_param_add(&impl->pending_list, seq, r->id, r->param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -1289,7 +1289,7 @@ int pw_impl_port_for_each_param(struct pw_impl_port *port,
|
||||||
spa_hook_remove(&listener);
|
spa_hook_remove(&listener);
|
||||||
|
|
||||||
if (user_data.cache) {
|
if (user_data.cache) {
|
||||||
pw_param_update(&impl->param_list, &impl->pending_list);
|
pw_param_update(&impl->param_list, &impl->pending_list, 0, NULL);
|
||||||
pi->user = 1;
|
pi->user = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,7 @@ static inline bool ratelimit_test(struct ratelimit *r, uint64_t now, enum spa_lo
|
||||||
|
|
||||||
struct pw_param {
|
struct pw_param {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
int32_t seq;
|
||||||
struct spa_list link;
|
struct spa_list link;
|
||||||
struct spa_pod *param;
|
struct spa_pod *param;
|
||||||
};
|
};
|
||||||
|
|
@ -123,7 +124,7 @@ static inline uint32_t pw_param_clear(struct spa_list *param_list, uint32_t id)
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct pw_param *pw_param_add(struct spa_list *params,
|
static inline struct pw_param *pw_param_add(struct spa_list *params, int32_t seq,
|
||||||
uint32_t id, const struct spa_pod *param)
|
uint32_t id, const struct spa_pod *param)
|
||||||
{
|
{
|
||||||
struct pw_param *p;
|
struct pw_param *p;
|
||||||
|
|
@ -140,6 +141,7 @@ static inline struct pw_param *pw_param_add(struct spa_list *params,
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
p->id = id;
|
p->id = id;
|
||||||
|
p->seq = seq;
|
||||||
if (param != NULL) {
|
if (param != NULL) {
|
||||||
p->param = SPA_PTROFF(p, sizeof(*p), struct spa_pod);
|
p->param = SPA_PTROFF(p, sizeof(*p), struct spa_pod);
|
||||||
memcpy(p->param, param, SPA_POD_SIZE(param));
|
memcpy(p->param, param, SPA_POD_SIZE(param));
|
||||||
|
|
@ -151,10 +153,22 @@ static inline struct pw_param *pw_param_add(struct spa_list *params,
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void pw_param_update(struct spa_list *param_list, struct spa_list *pending_list)
|
static inline void pw_param_update(struct spa_list *param_list, struct spa_list *pending_list,
|
||||||
|
uint32_t n_params, struct spa_param_info *params)
|
||||||
{
|
{
|
||||||
struct pw_param *p;
|
struct pw_param *p, *t;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < n_params; i++) {
|
||||||
|
spa_list_for_each_safe(p, t, pending_list, link) {
|
||||||
|
if (p->id == params[i].id &&
|
||||||
|
p->seq != params[i].seq &&
|
||||||
|
p->param != NULL) {
|
||||||
|
spa_list_remove(&p->link);
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
spa_list_consume(p, pending_list, link) {
|
spa_list_consume(p, pending_list, link) {
|
||||||
spa_list_remove(&p->link);
|
spa_list_remove(&p->link);
|
||||||
if (p->param == NULL) {
|
if (p->param == NULL) {
|
||||||
|
|
|
||||||
|
|
@ -192,15 +192,16 @@ static struct object *find_object(struct data *d, uint32_t id)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void object_update_params(struct object *o)
|
static void object_update_params(struct spa_list *param_list, struct spa_list *pending_list,
|
||||||
|
uint32_t n_params, struct spa_param_info *params)
|
||||||
{
|
{
|
||||||
struct param *p, *t;
|
struct param *p, *t;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
for (i = 0; i < o->n_params; i++) {
|
for (i = 0; i < n_params; i++) {
|
||||||
spa_list_for_each_safe(p, t, &o->pending_list, link) {
|
spa_list_for_each_safe(p, t, pending_list, link) {
|
||||||
if (p->id == o->params[i].id &&
|
if (p->id == params[i].id &&
|
||||||
p->seq != o->params[i].seq &&
|
p->seq != params[i].seq &&
|
||||||
p->param != NULL) {
|
p->param != NULL) {
|
||||||
spa_list_remove(&p->link);
|
spa_list_remove(&p->link);
|
||||||
free(p);
|
free(p);
|
||||||
|
|
@ -208,13 +209,13 @@ static void object_update_params(struct object *o)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spa_list_consume(p, &o->pending_list, link) {
|
spa_list_consume(p, pending_list, link) {
|
||||||
spa_list_remove(&p->link);
|
spa_list_remove(&p->link);
|
||||||
if (p->param == NULL) {
|
if (p->param == NULL) {
|
||||||
clear_params(&o->param_list, p->id);
|
clear_params(param_list, p->id);
|
||||||
free(p);
|
free(p);
|
||||||
} else {
|
} else {
|
||||||
spa_list_append(&o->param_list, &p->link);
|
spa_list_append(param_list, &p->link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1503,7 +1504,8 @@ static void on_core_done(void *data, uint32_t id, int seq)
|
||||||
pw_log_debug("sync end %u/%u", d->sync_seq, seq);
|
pw_log_debug("sync end %u/%u", d->sync_seq, seq);
|
||||||
|
|
||||||
spa_list_for_each(o, &d->object_list, link)
|
spa_list_for_each(o, &d->object_list, link)
|
||||||
object_update_params(o);
|
object_update_params(&o->param_list, &o->pending_list,
|
||||||
|
o->n_params, o->params);
|
||||||
|
|
||||||
dump_objects(d);
|
dump_objects(d);
|
||||||
if (!d->monitor)
|
if (!d->monitor)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue