mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
pulse-server: manager: add mechanism to query object data
Add `pw_manager_object_get_data()` which can fetch linked data by its id. And use it in the zeroconf-publish module.
This commit is contained in:
parent
fd111da507
commit
987c7fc1e4
3 changed files with 13 additions and 3 deletions
|
|
@ -853,6 +853,14 @@ done:
|
|||
return SPA_PTROFF(d, sizeof(struct object_data), void);
|
||||
}
|
||||
|
||||
void *pw_manager_object_get_data(struct pw_manager_object *obj, const char *id)
|
||||
{
|
||||
struct object *o = SPA_CONTAINER_OF(obj, struct object, this);
|
||||
struct object_data *d = object_find_data(o, id);
|
||||
|
||||
return d ? SPA_PTROFF(d, sizeof(*d), void) : NULL;
|
||||
}
|
||||
|
||||
int pw_manager_sync(struct pw_manager *manager)
|
||||
{
|
||||
struct manager *m = SPA_CONTAINER_OF(manager, struct manager, this);
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ int pw_manager_for_each_object(struct pw_manager *manager,
|
|||
void *data);
|
||||
|
||||
void *pw_manager_object_add_data(struct pw_manager_object *o, const char *id, size_t size);
|
||||
void *pw_manager_object_get_data(struct pw_manager_object *obj, const char *id);
|
||||
|
||||
bool pw_manager_object_is_client(struct pw_manager_object *o);
|
||||
bool pw_manager_object_is_module(struct pw_manager_object *o);
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ static int service_free(void *d, struct pw_manager_object *o)
|
|||
if (!pw_manager_object_is_sink(o) && !pw_manager_object_is_source(o))
|
||||
return 0;
|
||||
|
||||
s = pw_manager_object_add_data(o, SERVICE_DATA_ID, sizeof(*s));
|
||||
s = pw_manager_object_get_data(o, SERVICE_DATA_ID);
|
||||
if (s == NULL) {
|
||||
pw_log_error("Could not find service to remove");
|
||||
return 0;
|
||||
|
|
@ -153,14 +153,15 @@ static int service_free(void *d, struct pw_manager_object *o)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int unpublish_service(void *data, struct pw_manager_object *o) {
|
||||
static int unpublish_service(void *data, struct pw_manager_object *o)
|
||||
{
|
||||
struct module_zeroconf_publish_data *d = data;
|
||||
struct service *s;
|
||||
|
||||
if (!pw_manager_object_is_sink(o) && !pw_manager_object_is_source(o))
|
||||
return 0;
|
||||
|
||||
s = pw_manager_object_add_data(o, SERVICE_DATA_ID, sizeof(*s));
|
||||
s = pw_manager_object_get_data(o, SERVICE_DATA_ID);
|
||||
if (s == NULL) {
|
||||
pw_log_error("Could not find service to remove");
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue