mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-05 13:30:02 -05:00
pulse-server: move parts of client creation
Move some portions of the client creation logic into client.c so that it is easier to keep it in sync with `client_free()`, etc.
This commit is contained in:
parent
9c218b2d08
commit
6d2e6fde75
3 changed files with 26 additions and 13 deletions
|
|
@ -29,6 +29,7 @@
|
|||
#include <sys/socket.h>
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/hook.h>
|
||||
#include <spa/utils/list.h>
|
||||
#include <pipewire/core.h>
|
||||
#include <pipewire/log.h>
|
||||
|
|
@ -48,6 +49,29 @@
|
|||
#include "server.h"
|
||||
#include "stream.h"
|
||||
|
||||
struct client *client_new(struct server *server)
|
||||
{
|
||||
struct client *client = calloc(1, sizeof(*client));
|
||||
if (client == NULL)
|
||||
return NULL;
|
||||
|
||||
client->ref = 1;
|
||||
client->server = server;
|
||||
client->impl = server->impl;
|
||||
client->connect_tag = SPA_ID_INVALID;
|
||||
|
||||
pw_map_init(&client->streams, 16, 16);
|
||||
spa_list_init(&client->out_messages);
|
||||
spa_list_init(&client->operations);
|
||||
spa_list_init(&client->pending_samples);
|
||||
spa_list_init(&client->pending_streams);
|
||||
|
||||
spa_list_append(&server->clients, &client->link);
|
||||
server->n_clients++;
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
static int client_free_stream(void *item, void *data)
|
||||
{
|
||||
struct stream *s = item;
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ struct client {
|
|||
struct pw_manager_object *prev_default_source;
|
||||
};
|
||||
|
||||
struct client *client_new(struct server *server);
|
||||
bool client_detach(struct client *client);
|
||||
void client_disconnect(struct client *client);
|
||||
void client_free(struct client *client);
|
||||
|
|
|
|||
|
|
@ -379,22 +379,10 @@ on_connect(void *data, int fd, uint32_t mask)
|
|||
goto error;
|
||||
}
|
||||
|
||||
client = calloc(1, sizeof(*client));
|
||||
client = client_new(server);
|
||||
if (client == NULL)
|
||||
goto error;
|
||||
|
||||
client->impl = impl;
|
||||
client->ref = 1;
|
||||
client->connect_tag = SPA_ID_INVALID;
|
||||
client->server = server;
|
||||
spa_list_append(&server->clients, &client->link);
|
||||
server->n_clients++;
|
||||
pw_map_init(&client->streams, 16, 16);
|
||||
spa_list_init(&client->out_messages);
|
||||
spa_list_init(&client->operations);
|
||||
spa_list_init(&client->pending_samples);
|
||||
spa_list_init(&client->pending_streams);
|
||||
|
||||
pw_log_debug("server %p: new client %p fd:%d", server, client, client_fd);
|
||||
|
||||
client->source = pw_loop_add_io(impl->loop,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue