~diwic/ubuntu/lucid/pulseaudio/bugfixes

« back to all changes in this revision

Viewing changes to src/pulsecore/client.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2009-05-05 14:18:20 UTC
  • mfrom: (1.2.4 upstream) (1.1.8 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090505141820-rrr2mtdd1jkllvr8
Tags: 1:0.9.15-1ubuntu1
* Merge from unreleased Debian pulseaudio git, remaining changes:
  - epoch (my stupid fault :S)
  - Don't build against, and create jack package. Jack is not in main
  - use linear resampler to work better with lack of PREEMPT in jaunty's
    -generic kernel config, also change buffer size
  - Add alsa configuration files to route alsa applications via pulseaudio
  - Move libasound2-plugins from Recommends to Depends
  - Add pm-utils sleep hook to suspend (and resume) users' pulseaudio
    daemons
  - patch to fix source/sink and suspend-on-idle race
  - Make initscript more informative in the default case of per-user
    sessions
  - create /var/run/pulse, and make restart more robust
  - add status check for system wide pulseaudio instance
  - LSB {Required-*,Should-*} should specify hal instead of dbus,
    since hal is required (and already requires dbus)
  - indicate that the system pulseaudio instance is being started from the init
    script
  - Install more upstream man pages
  - Link to pacat for parec man page
  - check whether pulseaudio is running before preloading the padsp library
  - Add DEB_OPT_FLAG = -O3 as per recommendation from
    pulseaudio-discuss/2007-December/001017.html
  - cache /usr/share/sounds/ubuntu/stereo/ wav files on pulseaudio load
  - disable glitch free (use tsched=0)
  - Generate a PO template on build
  - add special case to disable pulseaudio loading if accessibility/speech
    is being used
  - the sd wrapper script should not load pulseaudio if pulseaudio is being
    used as a system service
  - add a pulseaudio apport hook
  - fix some typos in README.Debian
  - demote paprefs to suggests
  - drop padevchooser(Recommends) and pavucontrol (Suggests)
  - drop libasyncns-dev build dependency, its in universe
* add libudev-dev as a build-dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
  PulseAudio is free software; you can redistribute it and/or modify
8
8
  it under the terms of the GNU Lesser General Public License as published
9
 
  by the Free Software Foundation; either version 2 of the License,
 
9
  by the Free Software Foundation; either version 2.1 of the License,
10
10
  or (at your option) any later version.
11
11
 
12
12
  PulseAudio is distributed in the hope that it will be useful, but
29
29
#include <string.h>
30
30
 
31
31
#include <pulse/xmalloc.h>
 
32
#include <pulse/util.h>
32
33
 
33
34
#include <pulsecore/core-subscribe.h>
34
35
#include <pulsecore/log.h>
37
38
 
38
39
#include "client.h"
39
40
 
40
 
pa_client *pa_client_new(pa_core *core, const char *driver, const char *name) {
 
41
pa_client_new_data* pa_client_new_data_init(pa_client_new_data *data) {
 
42
    pa_assert(data);
 
43
 
 
44
    memset(data, 0, sizeof(*data));
 
45
    data->proplist = pa_proplist_new();
 
46
 
 
47
    return data;
 
48
}
 
49
 
 
50
void pa_client_new_data_done(pa_client_new_data *data) {
 
51
    pa_assert(data);
 
52
 
 
53
    pa_proplist_free(data->proplist);
 
54
}
 
55
 
 
56
pa_client *pa_client_new(pa_core *core, pa_client_new_data *data) {
41
57
    pa_client *c;
42
58
 
43
59
    pa_core_assert_ref(core);
 
60
    pa_assert(data);
 
61
 
 
62
    if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_CLIENT_NEW], data) < 0)
 
63
        return NULL;
44
64
 
45
65
    c = pa_xnew(pa_client, 1);
46
66
    c->core = core;
47
 
    c->proplist = pa_proplist_new();
48
 
    if (name)
49
 
        pa_proplist_sets(c->proplist, PA_PROP_APPLICATION_NAME, name);
50
 
    c->driver = pa_xstrdup(driver);
51
 
    c->module = NULL;
52
 
 
 
67
    c->proplist = pa_proplist_copy(data->proplist);
 
68
    c->driver = pa_xstrdup(pa_path_get_filename(data->driver));
 
69
    c->module = data->module;
 
70
 
 
71
    c->sink_inputs = pa_idxset_new(NULL, NULL);
 
72
    c->source_outputs = pa_idxset_new(NULL, NULL);
 
73
 
 
74
    c->userdata = NULL;
53
75
    c->kill = NULL;
54
 
    c->userdata = NULL;
 
76
    c->send_event = NULL;
55
77
 
56
78
    pa_assert_se(pa_idxset_put(core->clients, c, &c->index) >= 0);
57
79
 
58
 
    pa_log_info("Created %u \"%s\"", c->index, pa_strnull(name));
 
80
    pa_log_info("Created %u \"%s\"", c->index, pa_strnull(pa_proplist_gets(c->proplist, PA_PROP_APPLICATION_NAME)));
59
81
    pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_CLIENT|PA_SUBSCRIPTION_EVENT_NEW, c->index);
60
82
 
 
83
    pa_hook_fire(&core->hooks[PA_CORE_HOOK_CLIENT_PUT], c);
 
84
 
61
85
    pa_core_check_idle(core);
62
86
 
63
87
    return c;
70
94
    pa_assert(c->core);
71
95
 
72
96
    core = c->core;
 
97
 
 
98
    pa_hook_fire(&core->hooks[PA_CORE_HOOK_CLIENT_UNLINK], c);
 
99
 
73
100
    pa_idxset_remove_by_data(c->core->clients, c, NULL);
74
101
 
75
102
    pa_log_info("Freed %u \"%s\"", c->index, pa_strnull(pa_proplist_gets(c->proplist, PA_PROP_APPLICATION_NAME)));
76
103
    pa_subscription_post(c->core, PA_SUBSCRIPTION_EVENT_CLIENT|PA_SUBSCRIPTION_EVENT_REMOVE, c->index);
 
104
 
 
105
    pa_assert(pa_idxset_isempty(c->sink_inputs));
 
106
    pa_idxset_free(c->sink_inputs, NULL, NULL);
 
107
    pa_assert(pa_idxset_isempty(c->source_outputs));
 
108
    pa_idxset_free(c->source_outputs, NULL, NULL);
 
109
 
77
110
    pa_proplist_free(c->proplist);
78
111
    pa_xfree(c->driver);
79
112
    pa_xfree(c);
94
127
 
95
128
void pa_client_set_name(pa_client *c, const char *name) {
96
129
    pa_assert(c);
 
130
    pa_assert(name);
97
131
 
98
132
    pa_log_info("Client %u changed name from \"%s\" to \"%s\"", c->index, pa_strnull(pa_proplist_gets(c->proplist, PA_PROP_APPLICATION_NAME)), name);
99
133
    pa_proplist_sets(c->proplist, PA_PROP_APPLICATION_NAME, name);
 
134
 
 
135
    pa_client_update_proplist(c, 0, NULL);
 
136
}
 
137
 
 
138
void pa_client_update_proplist(pa_client *c, pa_update_mode_t mode, pa_proplist *p) {
 
139
    pa_assert(c);
 
140
 
 
141
    if (p)
 
142
        pa_proplist_update(c->proplist, mode, p);
 
143
 
 
144
    pa_hook_fire(&c->core->hooks[PA_CORE_HOOK_CLIENT_PROPLIST_CHANGED], c);
100
145
    pa_subscription_post(c->core, PA_SUBSCRIPTION_EVENT_CLIENT|PA_SUBSCRIPTION_EVENT_CHANGE, c->index);
101
146
}
 
147
 
 
148
void pa_client_send_event(pa_client *c, const char *event, pa_proplist *data) {
 
149
    pa_proplist *pl = NULL;
 
150
    pa_client_send_event_hook_data hook_data;
 
151
 
 
152
    pa_assert(c);
 
153
    pa_assert(event);
 
154
 
 
155
    if (!c->send_event)
 
156
        return;
 
157
 
 
158
    if (!data)
 
159
        data = pl = pa_proplist_new();
 
160
 
 
161
    hook_data.client = c;
 
162
    hook_data.data = data;
 
163
    hook_data.event = event;
 
164
 
 
165
    if (pa_hook_fire(&c->core->hooks[PA_CORE_HOOK_CLIENT_SEND_EVENT], &hook_data) < 0)
 
166
        goto finish;
 
167
 
 
168
    c->send_event(c, event, data);
 
169
 
 
170
finish:
 
171
 
 
172
    if (pl)
 
173
        pa_proplist_free(pl);
 
174
}