mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
pulse-server: fix weird property handling
There is no need to copy the properties, just pass ownership. Make sure to always have properties for the server. Ensure we clean up properties on error.
This commit is contained in:
parent
fa39cae9d3
commit
1c3a17362e
2 changed files with 17 additions and 18 deletions
|
|
@ -51,7 +51,6 @@ static const struct spa_dict_item module_props[] = {
|
|||
|
||||
struct impl {
|
||||
struct pw_context *context;
|
||||
struct pw_properties *properties;
|
||||
|
||||
struct spa_hook module_listener;
|
||||
|
||||
|
|
@ -63,8 +62,6 @@ static void impl_free(struct impl *impl)
|
|||
spa_hook_remove(&impl->module_listener);
|
||||
if (impl->pulse)
|
||||
pw_protocol_pulse_destroy(impl->pulse);
|
||||
if (impl->properties)
|
||||
pw_properties_free(impl->properties);
|
||||
free(impl);
|
||||
}
|
||||
|
||||
|
|
@ -101,10 +98,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
|
|||
else
|
||||
props = NULL;
|
||||
|
||||
impl->properties = props;
|
||||
|
||||
impl->pulse = pw_protocol_pulse_new(context,
|
||||
props ? pw_properties_copy(props) : NULL, 0);
|
||||
impl->pulse = pw_protocol_pulse_new(context, props, 0);
|
||||
if (impl->pulse == NULL) {
|
||||
res = -errno;
|
||||
goto error;
|
||||
|
|
|
|||
|
|
@ -5923,7 +5923,7 @@ static void impl_free(struct impl *impl)
|
|||
struct server *s;
|
||||
struct client *c;
|
||||
|
||||
if (impl->context)
|
||||
if (impl->context != NULL)
|
||||
spa_hook_remove(&impl->context_listener);
|
||||
spa_list_consume(c, &impl->cleanup_clients, link)
|
||||
client_free(c);
|
||||
|
|
@ -5931,10 +5931,9 @@ static void impl_free(struct impl *impl)
|
|||
server_free(s);
|
||||
pw_map_for_each(&impl->samples, impl_free_sample, impl);
|
||||
pw_map_clear(&impl->samples);
|
||||
if (impl->cleanup)
|
||||
if (impl->cleanup != NULL)
|
||||
pw_loop_destroy_source(impl->loop, impl->cleanup);
|
||||
if (impl->props)
|
||||
pw_properties_free(impl->props);
|
||||
pw_properties_free(impl->props);
|
||||
free(impl);
|
||||
}
|
||||
|
||||
|
|
@ -5968,21 +5967,25 @@ struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context,
|
|||
{
|
||||
struct impl *impl;
|
||||
const char *str;
|
||||
char *free_str = NULL;
|
||||
struct spa_json it[2];
|
||||
char value[512];
|
||||
|
||||
impl = calloc(1, sizeof(struct impl) + user_data_size);
|
||||
if (impl == NULL)
|
||||
return NULL;
|
||||
goto error_exit;
|
||||
|
||||
str = NULL;
|
||||
if (props != NULL)
|
||||
str = pw_properties_get(props, "server.address");
|
||||
if (props == NULL)
|
||||
props = pw_properties_new(NULL, NULL);
|
||||
if (props == NULL)
|
||||
goto error_free;
|
||||
|
||||
str = pw_properties_get(props, "server.address");
|
||||
if (str == NULL) {
|
||||
str = free_str = spa_aprintf("[ \"%s-%s\" ]",
|
||||
pw_properties_setf(props, "server.address",
|
||||
"[ \"%s-%s\" ]",
|
||||
PW_PROTOCOL_PULSE_DEFAULT_SERVER,
|
||||
get_server_name(context));
|
||||
str = pw_properties_get(props, "server.address");
|
||||
}
|
||||
if (str == NULL)
|
||||
goto error_free;
|
||||
|
|
@ -6017,7 +6020,6 @@ struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context,
|
|||
}
|
||||
}
|
||||
}
|
||||
free(free_str);
|
||||
|
||||
dbus_request_name(context, "org.pulseaudio.Server");
|
||||
|
||||
|
|
@ -6025,6 +6027,9 @@ struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context,
|
|||
|
||||
error_free:
|
||||
free(impl);
|
||||
error_exit:
|
||||
if (props != NULL)
|
||||
pw_properties_free(props);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue