mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
media-session: improve shutdown
First emit a remove of all objects. Then signal a session destroy and then destroy the context.
This commit is contained in:
parent
24ab22db12
commit
686a5cf47e
3 changed files with 22 additions and 5 deletions
|
|
@ -405,6 +405,7 @@ static void proxy_destroy(void *data)
|
|||
spa_list_remove(&endpoint->link);
|
||||
spa_hook_remove(&endpoint->proxy_listener);
|
||||
spa_hook_remove(&endpoint->client_endpoint_listener);
|
||||
endpoint->client_endpoint = NULL;
|
||||
}
|
||||
|
||||
static void proxy_bound(void *data, uint32_t id)
|
||||
|
|
@ -537,7 +538,8 @@ static struct endpoint *create_endpoint(struct node *node, struct endpoint *moni
|
|||
|
||||
static void destroy_endpoint(struct endpoint *endpoint)
|
||||
{
|
||||
pw_proxy_destroy((struct pw_proxy*)endpoint->client_endpoint);
|
||||
if (endpoint->client_endpoint)
|
||||
pw_proxy_destroy((struct pw_proxy*)endpoint->client_endpoint);
|
||||
}
|
||||
|
||||
/** fallback, one stream for each node */
|
||||
|
|
|
|||
|
|
@ -1672,6 +1672,16 @@ static int start_policy(struct impl *impl)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void session_shutdown(struct impl *impl)
|
||||
{
|
||||
struct sm_object *obj;
|
||||
|
||||
spa_list_for_each(obj, &impl->global_list, link)
|
||||
sm_media_session_emit_remove(impl, obj);
|
||||
|
||||
sm_media_session_emit_destroy(impl);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct impl impl = { 0, };
|
||||
|
|
@ -1714,8 +1724,9 @@ int main(int argc, char *argv[])
|
|||
goto exit;
|
||||
|
||||
pw_main_loop_run(impl.loop);
|
||||
|
||||
exit:
|
||||
sm_media_session_emit_destroy(&impl);
|
||||
session_shutdown(&impl);
|
||||
|
||||
pw_context_destroy(impl.this.context);
|
||||
pw_main_loop_destroy(impl.loop);
|
||||
|
|
|
|||
|
|
@ -355,6 +355,7 @@ static void proxy_destroy(void *data)
|
|||
spa_list_remove(&endpoint->link);
|
||||
spa_hook_remove(&endpoint->proxy_listener);
|
||||
spa_hook_remove(&endpoint->client_endpoint_listener);
|
||||
endpoint->client_endpoint = NULL;
|
||||
}
|
||||
|
||||
static void proxy_bound(void *data, uint32_t id)
|
||||
|
|
@ -473,7 +474,7 @@ static struct endpoint *create_endpoint(struct node *node)
|
|||
return endpoint;
|
||||
}
|
||||
|
||||
static void destroy_endpoint(struct endpoint *endpoint)
|
||||
static void destroy_endpoint(struct impl *impl, struct endpoint *endpoint)
|
||||
{
|
||||
pw_log_debug("endpoint %p: destroy", endpoint);
|
||||
if (endpoint->client_endpoint) {
|
||||
|
|
@ -513,10 +514,13 @@ static int activate_device(struct device *device)
|
|||
|
||||
static int deactivate_device(struct device *device)
|
||||
{
|
||||
struct impl *impl = device->impl;
|
||||
struct endpoint *e;
|
||||
pw_log_debug("device %p: deactivate", device->device);
|
||||
|
||||
pw_log_debug(NAME" %p: device %p deactivate", impl, device->device);
|
||||
spa_list_consume(e, &device->endpoint_list, link)
|
||||
destroy_endpoint(e);
|
||||
destroy_endpoint(impl, e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue