mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
proxy: never free a proxy automatically
Never free a proxy without the application doing a pw_proxy_destroy. It's hard to use when proxies are freed randomly when the server removes the ids. You have to add destroy notify to all proxies and deal with the arbirary order in which proxies can be freed. Instead notify the client of the remove and let it destroy the proxies itself in the right order. This is in line with how wayland handles proxies. A pw_proxy_destroy() will now send a destroy to the server and mark the proxy as a zombie, waiting for the remove_id confirmation and then destroy the proxy. A server remove_id will mark the proxy as removed and emits the removed event. The app should then pw_proxy_destroy the proxy to free it. Leaks all proxies in the session manager because cleanup now needs to be handled by the app correctly.
This commit is contained in:
parent
f391353c7f
commit
d3db9d12bc
5 changed files with 67 additions and 27 deletions
|
|
@ -237,9 +237,14 @@ int sm_object_remove_data(struct sm_object *obj, const char *id)
|
|||
int sm_object_destroy(struct sm_object *obj)
|
||||
{
|
||||
pw_log_debug(NAME" %p: object %d", obj->session, obj->id);
|
||||
pw_proxy_destroy(obj->proxy);
|
||||
if (obj->handle)
|
||||
if (obj->proxy) {
|
||||
pw_proxy_destroy(obj->proxy);
|
||||
obj->proxy = NULL;
|
||||
}
|
||||
if (obj->handle) {
|
||||
pw_proxy_destroy(obj->handle);
|
||||
obj->handle = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -958,10 +963,10 @@ static void bound_proxy(void *data, uint32_t id)
|
|||
}
|
||||
|
||||
static const struct pw_proxy_events proxy_events = {
|
||||
PW_VERSION_PROXY_EVENTS,
|
||||
.destroy = destroy_proxy,
|
||||
.done = done_proxy,
|
||||
.bound = bound_proxy,
|
||||
PW_VERSION_PROXY_EVENTS,
|
||||
.destroy = destroy_proxy,
|
||||
.done = done_proxy,
|
||||
.bound = bound_proxy,
|
||||
};
|
||||
|
||||
int sm_object_sync_update(struct sm_object *obj)
|
||||
|
|
@ -1617,7 +1622,8 @@ static void core_error(void *data, uint32_t id, int seq, int res, const char *me
|
|||
id, seq, res, spa_strerror(res), message);
|
||||
|
||||
if (id == 0) {
|
||||
pw_main_loop_quit(impl->loop);
|
||||
if (res == -EPIPE)
|
||||
pw_main_loop_quit(impl->loop);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1673,6 +1679,9 @@ static void session_shutdown(struct impl *impl)
|
|||
sm_media_session_emit_remove(impl, obj);
|
||||
|
||||
sm_media_session_emit_destroy(impl);
|
||||
|
||||
pw_proxy_destroy((struct pw_proxy*)impl->registry);
|
||||
pw_core_disconnect(impl->policy_core);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue