4 This file is part of PulseAudio.
6 Copyright 2004-2006 Lennart Poettering
7 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
9 PulseAudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published
11 by the Free Software Foundation; either version 2 of the License,
12 or (at your option) any later version.
14 PulseAudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with PulseAudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
33 #include <pulse/xmalloc.h>
35 #include <pulsecore/core-subscribe.h>
36 #include <pulsecore/log.h>
37 #include <pulsecore/macro.h>
41 pa_client
*pa_client_new(pa_core
*core
, const char *driver
, const char *name
) {
44 pa_core_assert_ref(core
);
46 c
= pa_xnew(pa_client
, 1);
47 c
->name
= pa_xstrdup(name
);
48 c
->driver
= pa_xstrdup(driver
);
55 pa_assert_se(pa_idxset_put(core
->clients
, c
, &c
->index
) >= 0);
57 pa_log_info("Created %u \"%s\"", c
->index
, c
->name
);
58 pa_subscription_post(core
, PA_SUBSCRIPTION_EVENT_CLIENT
|PA_SUBSCRIPTION_EVENT_NEW
, c
->index
);
60 pa_core_check_quit(core
);
65 void pa_client_free(pa_client
*c
) {
69 pa_idxset_remove_by_data(c
->core
->clients
, c
, NULL
);
71 pa_core_check_quit(c
->core
);
73 pa_log_info("Freed %u \"%s\"", c
->index
, c
->name
);
74 pa_subscription_post(c
->core
, PA_SUBSCRIPTION_EVENT_CLIENT
|PA_SUBSCRIPTION_EVENT_REMOVE
, c
->index
);
80 void pa_client_kill(pa_client
*c
) {
84 pa_log_warn("kill() operation not implemented for client %u", c
->index
);
91 void pa_client_set_name(pa_client
*c
, const char *name
) {
94 pa_log_info("Client %u changed name from \"%s\" to \"%s\"", c
->index
, c
->name
, name
);
97 c
->name
= pa_xstrdup(name
);
99 pa_subscription_post(c
->core
, PA_SUBSCRIPTION_EVENT_CLIENT
|PA_SUBSCRIPTION_EVENT_CHANGE
, c
->index
);