mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
fix some leaks
Make pw_get_client_name() return a static string. Unload the dbus interface. Rename the method to make it more obvious that the interface needs to be unloaded. Free module properties Free remote objects and types Free stream params and the array
This commit is contained in:
parent
4fd72eaee0
commit
627dfa3da2
9 changed files with 31 additions and 19 deletions
|
|
@ -751,7 +751,7 @@ gst_pipewire_device_provider_set_property (GObject * object,
|
||||||
GST_WARNING_OBJECT (self,
|
GST_WARNING_OBJECT (self,
|
||||||
"Empty PipeWire client name not allowed. "
|
"Empty PipeWire client name not allowed. "
|
||||||
"Resetting to default value");
|
"Resetting to default value");
|
||||||
self->client_name = pw_get_client_name ();
|
self->client_name = g_strdup(pw_get_client_name ());
|
||||||
} else
|
} else
|
||||||
self->client_name = g_value_dup_string (value);
|
self->client_name = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
|
|
@ -792,7 +792,6 @@ gst_pipewire_device_provider_class_init (GstPipeWireDeviceProviderClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
GstDeviceProviderClass *dm_class = GST_DEVICE_PROVIDER_CLASS (klass);
|
GstDeviceProviderClass *dm_class = GST_DEVICE_PROVIDER_CLASS (klass);
|
||||||
gchar *client_name;
|
|
||||||
|
|
||||||
gobject_class->set_property = gst_pipewire_device_provider_set_property;
|
gobject_class->set_property = gst_pipewire_device_provider_set_property;
|
||||||
gobject_class->get_property = gst_pipewire_device_provider_get_property;
|
gobject_class->get_property = gst_pipewire_device_provider_get_property;
|
||||||
|
|
@ -802,14 +801,12 @@ gst_pipewire_device_provider_class_init (GstPipeWireDeviceProviderClass * klass)
|
||||||
dm_class->start = gst_pipewire_device_provider_start;
|
dm_class->start = gst_pipewire_device_provider_start;
|
||||||
dm_class->stop = gst_pipewire_device_provider_stop;
|
dm_class->stop = gst_pipewire_device_provider_stop;
|
||||||
|
|
||||||
client_name = pw_get_client_name ();
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_CLIENT_NAME,
|
PROP_CLIENT_NAME,
|
||||||
g_param_spec_string ("client-name", "Client Name",
|
g_param_spec_string ("client-name", "Client Name",
|
||||||
"The PipeWire client_name_to_use", client_name,
|
"The PipeWire client_name_to_use", pw_get_client_name (),
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||||
GST_PARAM_MUTABLE_READY));
|
GST_PARAM_MUTABLE_READY));
|
||||||
g_free (client_name);
|
|
||||||
|
|
||||||
gst_device_provider_class_set_static_metadata (dm_class,
|
gst_device_provider_class_set_static_metadata (dm_class,
|
||||||
"PipeWire Device Provider", "Sink/Source/Audio/Video",
|
"PipeWire Device Provider", "Sink/Source/Audio/Video",
|
||||||
|
|
@ -820,5 +817,5 @@ gst_pipewire_device_provider_class_init (GstPipeWireDeviceProviderClass * klass)
|
||||||
static void
|
static void
|
||||||
gst_pipewire_device_provider_init (GstPipeWireDeviceProvider * self)
|
gst_pipewire_device_provider_init (GstPipeWireDeviceProvider * self)
|
||||||
{
|
{
|
||||||
self->client_name = pw_get_client_name ();
|
self->client_name = g_strdup(pw_get_client_name ());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,7 @@ static void
|
||||||
gst_pipewire_sink_init (GstPipeWireSink * sink)
|
gst_pipewire_sink_init (GstPipeWireSink * sink)
|
||||||
{
|
{
|
||||||
sink->pool = gst_pipewire_pool_new ();
|
sink->pool = gst_pipewire_pool_new ();
|
||||||
sink->client_name = pw_get_client_name();
|
sink->client_name = g_strdup(pw_get_client_name());
|
||||||
sink->mode = DEFAULT_PROP_MODE;
|
sink->mode = DEFAULT_PROP_MODE;
|
||||||
sink->fd = -1;
|
sink->fd = -1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,7 @@ gst_pipewire_src_init (GstPipeWireSrc * src)
|
||||||
|
|
||||||
g_queue_init (&src->queue);
|
g_queue_init (&src->queue);
|
||||||
|
|
||||||
src->client_name = pw_get_client_name ();
|
src->client_name = g_strdup(pw_get_client_name ());
|
||||||
|
|
||||||
src->pool = gst_pipewire_pool_new ();
|
src->pool = gst_pipewire_pool_new ();
|
||||||
src->loop = pw_loop_new (NULL);
|
src->loop = pw_loop_new (NULL);
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
/** \cond */
|
/** \cond */
|
||||||
struct impl {
|
struct impl {
|
||||||
struct pw_core this;
|
struct pw_core this;
|
||||||
|
void *dbus_iface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -375,11 +376,13 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop, struct pw_properties *pro
|
||||||
|
|
||||||
pw_map_init(&this->globals, 128, 32);
|
pw_map_init(&this->globals, 128, 32);
|
||||||
|
|
||||||
|
impl->dbus_iface = pw_load_spa_dbus_interface(this->main_loop);
|
||||||
|
|
||||||
this->support[0] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DataLoop, this->data_loop->loop);
|
this->support[0] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DataLoop, this->data_loop->loop);
|
||||||
this->support[1] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_MainLoop, this->main_loop->loop);
|
this->support[1] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_MainLoop, this->main_loop->loop);
|
||||||
this->support[2] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_LoopUtils, this->main_loop->utils);
|
this->support[2] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_LoopUtils, this->main_loop->utils);
|
||||||
this->support[3] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Log, pw_log_get());
|
this->support[3] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_Log, pw_log_get());
|
||||||
this->support[4] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DBus, pw_get_spa_dbus(this->main_loop));
|
this->support[4] = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_DBus, impl->dbus_iface);
|
||||||
this->n_support = 5;
|
this->n_support = 5;
|
||||||
|
|
||||||
pw_data_loop_start(this->data_loop_impl);
|
pw_data_loop_start(this->data_loop_impl);
|
||||||
|
|
@ -449,6 +452,7 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop, struct pw_properties *pro
|
||||||
*/
|
*/
|
||||||
void pw_core_destroy(struct pw_core *core)
|
void pw_core_destroy(struct pw_core *core)
|
||||||
{
|
{
|
||||||
|
struct impl *impl = SPA_CONTAINER_OF(core, struct impl, this);
|
||||||
struct pw_global *global, *t;
|
struct pw_global *global, *t;
|
||||||
struct pw_module *module, *tm;
|
struct pw_module *module, *tm;
|
||||||
struct pw_remote *remote, *tr;
|
struct pw_remote *remote, *tr;
|
||||||
|
|
@ -479,6 +483,8 @@ void pw_core_destroy(struct pw_core *core)
|
||||||
|
|
||||||
pw_map_clear(&core->globals);
|
pw_map_clear(&core->globals);
|
||||||
|
|
||||||
|
pw_unload_spa_interface(impl->dbus_iface);
|
||||||
|
|
||||||
pw_log_debug("core %p: free", core);
|
pw_log_debug("core %p: free", core);
|
||||||
free(core);
|
free(core);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -310,6 +310,8 @@ void pw_module_destroy(struct pw_module *module)
|
||||||
if (module->info.args)
|
if (module->info.args)
|
||||||
free((char *) module->info.args);
|
free((char *) module->info.args);
|
||||||
|
|
||||||
|
pw_properties_free(module->properties);
|
||||||
|
|
||||||
dlclose(impl->hnd);
|
dlclose(impl->hnd);
|
||||||
free(impl);
|
free(impl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -377,7 +377,7 @@ int pw_unload_spa_interface(void *iface)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pw_get_spa_dbus(struct pw_loop *loop)
|
void *pw_load_spa_dbus_interface(struct pw_loop *loop)
|
||||||
{
|
{
|
||||||
struct spa_support support = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_LoopUtils, loop->utils);
|
struct spa_support support = SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_LoopUtils, loop->utils);
|
||||||
|
|
||||||
|
|
@ -511,19 +511,20 @@ const char *pw_get_host_name(void)
|
||||||
*
|
*
|
||||||
* \memberof pw_pipewire
|
* \memberof pw_pipewire
|
||||||
*/
|
*/
|
||||||
char *pw_get_client_name(void)
|
const char *pw_get_client_name(void)
|
||||||
{
|
{
|
||||||
char *c;
|
|
||||||
const char *cc;
|
const char *cc;
|
||||||
|
static char cname[256];
|
||||||
|
|
||||||
if ((cc = pw_get_application_name()))
|
if ((cc = pw_get_application_name()))
|
||||||
return strdup(cc);
|
return cc;
|
||||||
else if ((cc = pw_get_prgname()))
|
else if ((cc = pw_get_prgname()))
|
||||||
return strdup(cc);
|
return cc;
|
||||||
else {
|
else {
|
||||||
if (asprintf(&c, "pipewire-pid-%zd", (size_t) getpid()) < 0)
|
if (snprintf(cname, sizeof(cname), "pipewire-pid-%zd", (size_t) getpid()) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
return c;
|
cname[255] = 0;
|
||||||
|
return cname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ pw_get_user_name(void);
|
||||||
const char *
|
const char *
|
||||||
pw_get_host_name(void);
|
pw_get_host_name(void);
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
pw_get_client_name(void);
|
pw_get_client_name(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -137,9 +137,11 @@ void *pw_load_spa_interface(const char *lib, const char *factory_name, uint32_t
|
||||||
const struct spa_dict *info,
|
const struct spa_dict *info,
|
||||||
uint32_t n_support,
|
uint32_t n_support,
|
||||||
struct spa_support support[n_support]);
|
struct spa_support support[n_support]);
|
||||||
|
|
||||||
|
void *pw_load_spa_dbus_interface(struct pw_loop *loop);
|
||||||
|
|
||||||
int pw_unload_spa_interface(void *iface);
|
int pw_unload_spa_interface(void *iface);
|
||||||
|
|
||||||
void *pw_get_spa_dbus(struct pw_loop *loop);
|
|
||||||
|
|
||||||
const struct spa_handle_factory *
|
const struct spa_handle_factory *
|
||||||
pw_get_support_factory(const char *factory_name);
|
pw_get_support_factory(const char *factory_name);
|
||||||
|
|
|
||||||
|
|
@ -303,6 +303,9 @@ void pw_remote_destroy(struct pw_remote *remote)
|
||||||
|
|
||||||
spa_list_remove(&remote->link);
|
spa_list_remove(&remote->link);
|
||||||
|
|
||||||
|
pw_map_clear(&remote->objects);
|
||||||
|
pw_map_clear(&remote->types);
|
||||||
|
|
||||||
if (remote->properties)
|
if (remote->properties)
|
||||||
pw_properties_free(remote->properties);
|
pw_properties_free(remote->properties);
|
||||||
free(remote->error);
|
free(remote->error);
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ static void clear_params(struct pw_stream *stream, int type)
|
||||||
|
|
||||||
p = pw_array_first(&impl->params);
|
p = pw_array_first(&impl->params);
|
||||||
while (pw_array_check(&impl->params, p)) {
|
while (pw_array_check(&impl->params, p)) {
|
||||||
if (SPA_FLAG_CHECK(p->type, type)) {
|
if ((p->type & type) != 0) {
|
||||||
free(p->param);
|
free(p->param);
|
||||||
pw_array_remove(&impl->params, p);
|
pw_array_remove(&impl->params, p);
|
||||||
}
|
}
|
||||||
|
|
@ -948,6 +948,7 @@ void pw_stream_destroy(struct pw_stream *stream)
|
||||||
spa_list_remove(&stream->link);
|
spa_list_remove(&stream->link);
|
||||||
|
|
||||||
clear_params(stream, PARAM_TYPE_INIT | PARAM_TYPE_OTHER | PARAM_TYPE_FORMAT);
|
clear_params(stream, PARAM_TYPE_INIT | PARAM_TYPE_OTHER | PARAM_TYPE_FORMAT);
|
||||||
|
pw_array_clear(&impl->params);
|
||||||
|
|
||||||
if (stream->error)
|
if (stream->error)
|
||||||
free(stream->error);
|
free(stream->error);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue