mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@18 fefdeb5f-60dc-0310-8127-8f9354f1896f
44 lines
946 B
C
44 lines
946 B
C
#include <stdio.h>
|
|
#include <assert.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "client.h"
|
|
|
|
struct client *client_new(struct core *core, const char *protocol_name, char *name) {
|
|
struct client *c;
|
|
int r;
|
|
assert(core);
|
|
|
|
c = malloc(sizeof(struct client));
|
|
assert(c);
|
|
c->name = name ? strdup(name) : NULL;
|
|
c->core = core;
|
|
c->protocol_name = protocol_name;
|
|
|
|
c->kill = NULL;
|
|
c->userdata = NULL;
|
|
|
|
r = idxset_put(core->clients, c, &c->index);
|
|
assert(c->index != IDXSET_INVALID && r >= 0);
|
|
|
|
fprintf(stderr, "client: created %u \"%s\"\n", c->index, c->name);
|
|
|
|
return c;
|
|
}
|
|
|
|
void client_free(struct client *c) {
|
|
assert(c && c->core);
|
|
|
|
idxset_remove_by_data(c->core->clients, c, NULL);
|
|
fprintf(stderr, "client: freed %u \"%s\"\n", c->index, c->name);
|
|
free(c->name);
|
|
free(c);
|
|
}
|
|
|
|
void client_kill(struct client *c) {
|
|
assert(c);
|
|
if (c->kill)
|
|
c->kill(c);
|
|
}
|
|
|