Ensure all globals have PW_KEY_OBJECT_SERIAL prop

This avoids the caller having to set this property.
This commit is contained in:
Demi Marie Obenour 2024-01-16 13:25:39 -05:00 committed by Wim Taymans
parent ac28abbadf
commit 30419c37df
17 changed files with 9 additions and 69 deletions

View file

@ -441,10 +441,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
struct pw_context *context = pw_impl_module_get_context(module);
struct pw_properties *props;
struct impl *impl;
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
NULL
};
PW_LOG_TOPIC_INIT(mod_topic);
@ -483,8 +479,6 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
impl->flush_event = pw_loop_add_event(impl->main_loop, do_flush_event, impl);
pw_global_update_keys(impl->global, &impl->properties->dict, keys);
pw_impl_module_add_listener(module, &impl->module_listener, &module_events, impl);
pw_impl_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));

View file

@ -299,7 +299,6 @@ int endpoint_init(struct endpoint *this,
struct pw_properties *properties)
{
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
PW_KEY_FACTORY_ID,
PW_KEY_CLIENT_ID,
PW_KEY_DEVICE_ID,

View file

@ -269,7 +269,6 @@ int session_init(struct session *this,
struct pw_properties *properties)
{
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
PW_KEY_FACTORY_ID,
PW_KEY_CLIENT_ID,
NULL

View file

@ -371,15 +371,6 @@ static void *link_new(struct pw_context *context,
struct pw_properties *properties)
{
struct impl *impl;
char serial_str[32];
struct spa_dict_item items[1] = {
SPA_DICT_ITEM_INIT(PW_KEY_OBJECT_SERIAL, serial_str),
};
struct spa_dict extra_props = SPA_DICT_INIT_ARRAY(items);
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
NULL
};
impl = calloc(1, sizeof(*impl));
if (impl == NULL) {
@ -399,10 +390,6 @@ static void *link_new(struct pw_context *context,
}
impl->resource = resource;
spa_scnprintf(serial_str, sizeof(serial_str), "%"PRIu64,
pw_global_get_serial(impl->global));
pw_global_update_keys(impl->global, &extra_props, keys);
spa_list_init(&impl->cached_params);
/* handle destroy events */

View file

@ -362,15 +362,6 @@ static void *stream_new(struct pw_context *context,
struct pw_properties *properties)
{
struct impl *impl;
char serial_str[32];
struct spa_dict_item items[1] = {
SPA_DICT_ITEM_INIT(PW_KEY_OBJECT_SERIAL, serial_str),
};
struct spa_dict extra_props = SPA_DICT_INIT_ARRAY(items);
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
NULL
};
impl = calloc(1, sizeof(*impl));
if (impl == NULL) {
@ -390,10 +381,6 @@ static void *stream_new(struct pw_context *context,
}
impl->resource = resource;
spa_scnprintf(serial_str, sizeof(serial_str), "%"PRIu64,
pw_global_get_serial(impl->global));
pw_global_update_keys(impl->global, &extra_props, keys);
spa_list_init(&impl->cached_params);
/* handle destroy events */

View file

@ -371,15 +371,6 @@ static void *endpoint_new(struct pw_context *context,
struct pw_properties *properties)
{
struct impl *impl;
char serial_str[32];
struct spa_dict_item items[1] = {
SPA_DICT_ITEM_INIT(PW_KEY_OBJECT_SERIAL, serial_str),
};
struct spa_dict extra_props = SPA_DICT_INIT_ARRAY(items);
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
NULL
};
impl = calloc(1, sizeof(*impl));
if (impl == NULL) {
@ -399,10 +390,6 @@ static void *endpoint_new(struct pw_context *context,
}
impl->resource = resource;
spa_scnprintf(serial_str, sizeof(serial_str), "%"PRIu64,
pw_global_get_serial(impl->global));
pw_global_update_keys(impl->global, &extra_props, keys);
spa_list_init(&impl->cached_params);
/* handle destroy events */

View file

@ -360,15 +360,6 @@ static void *session_new(struct pw_context *context,
struct pw_properties *properties)
{
struct impl *impl;
char serial_str[32];
struct spa_dict_item items[1] = {
SPA_DICT_ITEM_INIT(PW_KEY_OBJECT_SERIAL, serial_str),
};
struct spa_dict extra_props = SPA_DICT_INIT_ARRAY(items);
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
NULL
};
impl = calloc(1, sizeof(*impl));
if (impl == NULL) {
@ -388,10 +379,6 @@ static void *session_new(struct pw_context *context,
}
impl->resource = resource;
spa_scnprintf(serial_str, sizeof(serial_str), "%"PRIu64,
pw_global_get_serial(impl->global));
pw_global_update_keys(impl->global, &extra_props, keys);
spa_list_init(&impl->cached_params);
/* handle destroy events */

View file

@ -54,6 +54,7 @@ pw_global_new(struct pw_context *context,
{
struct impl *impl;
struct pw_global *this;
uint64_t serial;
int res;
if (properties == NULL)
@ -87,6 +88,14 @@ pw_global_new(struct pw_context *context,
spa_list_init(&this->resource_list);
spa_hook_list_init(&this->listener_list);
serial = pw_global_get_serial(this);
res = pw_properties_setf(properties, PW_KEY_OBJECT_SERIAL, "%" PRIu64, serial);
if (res < 0) {
pw_global_destroy(this);
errno = -res;
return NULL;
}
pw_log_debug("%p: new %s %d", this, this->type, this->id);
return this;

View file

@ -519,7 +519,6 @@ int pw_impl_client_register(struct pw_impl_client *client,
struct pw_properties *properties)
{
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
PW_KEY_MODULE_ID,
PW_KEY_PROTOCOL,
PW_KEY_SEC_PID,

View file

@ -573,7 +573,6 @@ int pw_impl_core_register(struct pw_impl_core *core,
struct pw_properties *properties)
{
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
PW_KEY_USER_NAME,
PW_KEY_HOST_NAME,
PW_KEY_CORE_NAME,

View file

@ -538,7 +538,6 @@ int pw_impl_device_register(struct pw_impl_device *device,
struct pw_properties *properties)
{
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
PW_KEY_OBJECT_PATH,
PW_KEY_MODULE_ID,
PW_KEY_FACTORY_ID,

View file

@ -158,7 +158,6 @@ int pw_impl_factory_register(struct pw_impl_factory *factory,
struct pw_properties *properties)
{
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
PW_KEY_MODULE_ID,
PW_KEY_FACTORY_NAME,
PW_KEY_FACTORY_TYPE_NAME,

View file

@ -1496,7 +1496,6 @@ int pw_impl_link_register(struct pw_impl_link *link,
struct pw_properties *properties)
{
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
PW_KEY_OBJECT_PATH,
PW_KEY_MODULE_ID,
PW_KEY_FACTORY_ID,

View file

@ -506,7 +506,6 @@ int pw_impl_metadata_register(struct pw_impl_metadata *metadata,
{
struct pw_context *context = metadata->context;
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
PW_KEY_MODULE_ID,
PW_KEY_FACTORY_ID,
PW_KEY_METADATA_NAME,

View file

@ -149,7 +149,6 @@ pw_context_load_module(struct pw_context *context,
size_t len;
char path_part[PATH_MAX];
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
PW_KEY_MODULE_NAME,
NULL
};

View file

@ -739,7 +739,6 @@ int pw_impl_node_register(struct pw_impl_node *this,
struct pw_properties *properties)
{
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
PW_KEY_OBJECT_PATH,
PW_KEY_MODULE_ID,
PW_KEY_FACTORY_ID,

View file

@ -1014,7 +1014,6 @@ int pw_impl_port_register(struct pw_impl_port *port,
struct pw_properties *properties)
{
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
PW_KEY_OBJECT_PATH,
PW_KEY_FORMAT_DSP,
PW_KEY_NODE_ID,