add some more properties to globals

Add the global serial and name
This commit is contained in:
Wim Taymans 2022-01-15 17:21:22 +01:00
parent b1fb4a2660
commit 7336f380a5
2 changed files with 17 additions and 3 deletions

View file

@ -379,6 +379,10 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
struct pw_properties *props; struct pw_properties *props;
struct impl *impl; struct impl *impl;
struct pw_loop *main_loop = pw_context_get_main_loop(context); struct pw_loop *main_loop = pw_context_get_main_loop(context);
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
NULL
};
PW_LOG_TOPIC_INIT(mod_topic); PW_LOG_TOPIC_INIT(mod_topic);
@ -409,9 +413,14 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
free(impl); free(impl);
return -errno; return -errno;
} }
pw_properties_setf(impl->properties, PW_KEY_OBJECT_ID, "%d", impl->global->id);
pw_properties_setf(impl->properties, PW_KEY_OBJECT_SERIAL, "%"PRIu64,
pw_global_get_serial(impl->global));
impl->flush_timeout = pw_loop_add_timer(main_loop, flush_timeout, impl); impl->flush_timeout = pw_loop_add_timer(main_loop, flush_timeout, 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_add_listener(module, &impl->module_listener, &module_events, impl);
pw_impl_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props)); pw_impl_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));

View file

@ -171,6 +171,11 @@ pw_context_load_module(struct pw_context *context,
const char *state = NULL, *p; const char *state = NULL, *p;
size_t len; size_t len;
char path_part[PATH_MAX]; char path_part[PATH_MAX];
static const char * const keys[] = {
PW_KEY_OBJECT_SERIAL,
PW_KEY_MODULE_NAME,
NULL
};
module_dir = getenv("PIPEWIRE_MODULE_DIR"); module_dir = getenv("PIPEWIRE_MODULE_DIR");
if (module_dir == NULL) { if (module_dir == NULL) {
@ -234,9 +239,7 @@ pw_context_load_module(struct pw_context *context,
this->global = pw_global_new(context, this->global = pw_global_new(context,
PW_TYPE_INTERFACE_Module, PW_TYPE_INTERFACE_Module,
PW_VERSION_MODULE, PW_VERSION_MODULE,
pw_properties_new( NULL,
PW_KEY_MODULE_NAME, name,
NULL),
global_bind, global_bind,
this); this);
@ -251,6 +254,8 @@ pw_context_load_module(struct pw_context *context,
pw_global_get_serial(this->global)); pw_global_get_serial(this->global));
this->info.props = &this->properties->dict; this->info.props = &this->properties->dict;
pw_global_update_keys(this->global, &this->properties->dict, keys);
pw_impl_module_emit_initialized(this); pw_impl_module_emit_initialized(this);
pw_global_add_listener(this->global, &this->global_listener, &global_events, this); pw_global_add_listener(this->global, &this->global_listener, &global_events, this);