~ubuntu-branches/ubuntu/jaunty/pulseaudio/jaunty-updates

« back to all changes in this revision

Viewing changes to src/pulsecore/client.c

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2006-11-12 20:00:18 UTC
  • Revision ID: james.westby@ubuntu.com-20061112200018-oji9njq7rr3te53k
Tags: upstream-0.9.5
ImportĀ upstreamĀ versionĀ 0.9.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: client.c 1272 2006-08-18 21:38:40Z lennart $ */
 
2
 
 
3
/***
 
4
  This file is part of PulseAudio.
 
5
 
 
6
  PulseAudio is free software; you can redistribute it and/or modify
 
7
  it under the terms of the GNU Lesser General Public License as published
 
8
  by the Free Software Foundation; either version 2 of the License,
 
9
  or (at your option) any later version.
 
10
 
 
11
  PulseAudio is distributed in the hope that it will be useful, but
 
12
  WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
14
  General Public License for more details.
 
15
 
 
16
  You should have received a copy of the GNU Lesser General Public License
 
17
  along with PulseAudio; if not, write to the Free Software
 
18
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 
19
  USA.
 
20
***/
 
21
 
 
22
#ifdef HAVE_CONFIG_H
 
23
#include <config.h>
 
24
#endif
 
25
 
 
26
#include <stdio.h>
 
27
#include <assert.h>
 
28
#include <stdlib.h>
 
29
#include <string.h>
 
30
 
 
31
#include <pulse/xmalloc.h>
 
32
 
 
33
#include <pulsecore/core-subscribe.h>
 
34
#include <pulsecore/log.h>
 
35
 
 
36
#include "client.h"
 
37
 
 
38
pa_client *pa_client_new(pa_core *core, const char *driver, const char *name) {
 
39
    pa_client *c;
 
40
    int r;
 
41
    assert(core);
 
42
 
 
43
    c = pa_xmalloc(sizeof(pa_client));
 
44
    c->name = pa_xstrdup(name);
 
45
    c->driver = pa_xstrdup(driver);
 
46
    c->owner = NULL;
 
47
    c->core = core;
 
48
 
 
49
    c->kill = NULL;
 
50
    c->userdata = NULL;
 
51
 
 
52
    r = pa_idxset_put(core->clients, c, &c->index);
 
53
    assert(c->index != PA_IDXSET_INVALID && r >= 0);
 
54
 
 
55
    pa_log_info("created %u \"%s\"", c->index, c->name);
 
56
    pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_CLIENT|PA_SUBSCRIPTION_EVENT_NEW, c->index);
 
57
 
 
58
    pa_core_check_quit(core);
 
59
    
 
60
    return c;
 
61
}
 
62
 
 
63
void pa_client_free(pa_client *c) {
 
64
    assert(c && c->core);
 
65
 
 
66
    pa_idxset_remove_by_data(c->core->clients, c, NULL);
 
67
 
 
68
    pa_core_check_quit(c->core);
 
69
 
 
70
    pa_log_info("freed %u \"%s\"", c->index, c->name);
 
71
    pa_subscription_post(c->core, PA_SUBSCRIPTION_EVENT_CLIENT|PA_SUBSCRIPTION_EVENT_REMOVE, c->index);
 
72
    pa_xfree(c->name);
 
73
    pa_xfree(c->driver);
 
74
    pa_xfree(c);
 
75
}
 
76
 
 
77
void pa_client_kill(pa_client *c) {
 
78
    assert(c);
 
79
    if (!c->kill) {
 
80
        pa_log_warn("kill() operation not implemented for client %u", c->index);
 
81
        return;
 
82
    }
 
83
 
 
84
    c->kill(c);
 
85
}
 
86
 
 
87
void pa_client_set_name(pa_client *c, const char *name) {
 
88
    assert(c);
 
89
 
 
90
    pa_log_info("client %u changed name from \"%s\" to \"%s\"", c->index, c->name, name);
 
91
 
 
92
    pa_xfree(c->name);
 
93
    c->name = pa_xstrdup(name);
 
94
 
 
95
    pa_subscription_post(c->core, PA_SUBSCRIPTION_EVENT_CLIENT|PA_SUBSCRIPTION_EVENT_CHANGE, c->index);
 
96
}