pulse-server: client: add 'disconnect' event

Have the clients emit a 'disconnect' event when they are
being disconnected.
This commit is contained in:
Barnabás Pőcze 2021-11-13 14:14:19 +01:00 committed by Wim Taymans
parent 2d4febaba1
commit 043934655a
2 changed files with 22 additions and 0 deletions

View file

@ -49,6 +49,8 @@
#include "server.h"
#include "stream.h"
#define client_emit_disconnect(c) spa_hook_list_call(&(c)->listener_list, struct client_events, disconnect, 0)
struct client *client_new(struct server *server)
{
struct client *client = calloc(1, sizeof(*client));
@ -65,6 +67,7 @@ struct client *client_new(struct server *server)
spa_list_init(&client->operations);
spa_list_init(&client->pending_samples);
spa_list_init(&client->pending_streams);
spa_hook_list_init(&client->listener_list);
spa_list_append(&server->clients, &client->link);
server->n_clients++;
@ -116,6 +119,8 @@ void client_disconnect(struct client *client)
if (client->disconnect)
return;
client_emit_disconnect(client);
/* the client must be detached from the server to disconnect */
spa_assert(client->server == NULL);
@ -171,6 +176,8 @@ void client_free(struct client *client)
pw_properties_free(client->props);
pw_properties_free(client->routes);
spa_hook_list_clean(&client->listener_list);
free(client);
}