~diwic/ubuntu/lucid/pulseaudio/bugfixes

« back to all changes in this revision

Viewing changes to src/modules/module-suspend-on-idle.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:
5
5
 
6
6
  PulseAudio is free software; you can redistribute it and/or modify
7
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,
 
8
  by the Free Software Foundation; either version 2.1 of the License,
9
9
  or (at your option) any later version.
10
10
 
11
11
  PulseAudio is distributed in the hope that it will be useful, but
62
62
        *source_output_new_slot,
63
63
        *sink_input_unlink_slot,
64
64
        *source_output_unlink_slot,
65
 
        *sink_input_move_slot,
66
 
        *source_output_move_slot,
 
65
        *sink_input_move_start_slot,
 
66
        *source_output_move_start_slot,
 
67
        *sink_input_move_finish_slot,
 
68
        *source_output_move_finish_slot,
67
69
        *sink_input_state_changed_slot,
68
70
        *source_output_state_changed_slot;
69
71
};
83
85
 
84
86
    d->userdata->core->mainloop->time_restart(d->time_event, NULL);
85
87
 
86
 
    if (d->sink && pa_sink_used_by(d->sink) <= 0 && pa_sink_get_state(d->sink) != PA_SINK_SUSPENDED) {
 
88
    if (d->sink && pa_sink_check_suspend(d->sink) <= 0 && pa_sink_get_state(d->sink) != PA_SINK_SUSPENDED) {
87
89
        pa_log_info("Sink %s idle for too long, suspending ...", d->sink->name);
88
90
        pa_sink_suspend(d->sink, TRUE);
89
91
    }
90
92
 
91
 
    if (d->source && pa_source_used_by(d->source) <= 0 && pa_source_get_state(d->source) != PA_SOURCE_SUSPENDED) {
 
93
    if (d->source && pa_source_check_suspend(d->source) <= 0 && pa_source_get_state(d->source) != PA_SOURCE_SUSPENDED) {
92
94
        pa_log_info("Source %s idle for too long, suspending ...", d->source->name);
93
95
        pa_source_suspend(d->source, TRUE);
94
96
    }
147
149
    pa_assert(data);
148
150
    pa_assert(u);
149
151
 
150
 
    if ((d = pa_hashmap_get(u->device_infos, data->source)))
 
152
    if (data->source->monitor_of)
 
153
        d = pa_hashmap_get(u->device_infos, data->source->monitor_of);
 
154
    else
 
155
        d = pa_hashmap_get(u->device_infos, data->source);
 
156
 
 
157
    if (d)
151
158
        resume(d);
152
159
 
153
160
    return PA_HOOK_OK;
158
165
    pa_sink_input_assert_ref(s);
159
166
    pa_assert(u);
160
167
 
161
 
    if (pa_sink_used_by(s->sink) <= 0) {
 
168
    if (!s->sink)
 
169
        return PA_HOOK_OK;
 
170
 
 
171
    if (pa_sink_check_suspend(s->sink) <= 0) {
162
172
        struct device_info *d;
163
173
        if ((d = pa_hashmap_get(u->device_infos, s->sink)))
164
174
            restart(d);
168
178
}
169
179
 
170
180
static pa_hook_result_t source_output_unlink_hook_cb(pa_core *c, pa_source_output *s, struct userdata *u) {
171
 
    pa_assert(c);
172
 
    pa_source_output_assert_ref(s);
173
 
    pa_assert(u);
174
 
 
175
 
    if (pa_source_used_by(s->source) <= 0) {
176
 
        struct device_info *d;
177
 
        if ((d = pa_hashmap_get(u->device_infos, s->source)))
178
 
            restart(d);
179
 
    }
180
 
 
181
 
    return PA_HOOK_OK;
182
 
}
183
 
 
184
 
static pa_hook_result_t sink_input_move_hook_cb(pa_core *c, pa_sink_input_move_hook_data *data, struct userdata *u) {
185
 
    struct device_info *d;
186
 
 
187
 
    pa_assert(c);
188
 
    pa_assert(data);
189
 
    pa_assert(u);
190
 
 
191
 
    if ((d = pa_hashmap_get(u->device_infos, data->destination)))
192
 
        resume(d);
193
 
 
194
 
    if (pa_sink_used_by(data->sink_input->sink) <= 1)
195
 
        if ((d = pa_hashmap_get(u->device_infos, data->sink_input->sink)))
196
 
            restart(d);
197
 
 
198
 
    return PA_HOOK_OK;
199
 
}
200
 
 
201
 
static pa_hook_result_t source_output_move_hook_cb(pa_core *c, pa_source_output_move_hook_data *data, struct userdata *u) {
202
 
    struct device_info *d;
203
 
 
204
 
    pa_assert(c);
205
 
    pa_assert(data);
206
 
    pa_assert(u);
207
 
 
208
 
    if ((d = pa_hashmap_get(u->device_infos, data->destination)))
209
 
        resume(d);
210
 
 
211
 
    if (pa_source_used_by(data->source_output->source) <= 1)
212
 
        if ((d = pa_hashmap_get(u->device_infos, data->source_output->source)))
213
 
            restart(d);
 
181
    struct device_info *d = NULL;
 
182
 
 
183
    pa_assert(c);
 
184
    pa_source_output_assert_ref(s);
 
185
    pa_assert(u);
 
186
 
 
187
    if (!s->source)
 
188
        return PA_HOOK_OK;
 
189
 
 
190
    if (s->source->monitor_of) {
 
191
        if (pa_sink_check_suspend(s->source->monitor_of) <= 0)
 
192
            d = pa_hashmap_get(u->device_infos, s->source->monitor_of);
 
193
    } else {
 
194
        if (pa_source_check_suspend(s->source) <= 0)
 
195
            d = pa_hashmap_get(u->device_infos, s->source);
 
196
    }
 
197
 
 
198
    if (d)
 
199
        restart(d);
 
200
 
 
201
    return PA_HOOK_OK;
 
202
}
 
203
 
 
204
static pa_hook_result_t sink_input_move_start_hook_cb(pa_core *c, pa_sink_input *s, struct userdata *u) {
 
205
    struct device_info *d;
 
206
 
 
207
    pa_assert(c);
 
208
    pa_sink_input_assert_ref(s);
 
209
    pa_assert(u);
 
210
 
 
211
    if (pa_sink_check_suspend(s->sink) <= 1)
 
212
        if ((d = pa_hashmap_get(u->device_infos, s->sink)))
 
213
            restart(d);
 
214
 
 
215
    return PA_HOOK_OK;
 
216
}
 
217
 
 
218
static pa_hook_result_t sink_input_move_finish_hook_cb(pa_core *c, pa_sink_input *s, struct userdata *u) {
 
219
    struct device_info *d;
 
220
 
 
221
    pa_assert(c);
 
222
    pa_sink_input_assert_ref(s);
 
223
    pa_assert(u);
 
224
 
 
225
    if ((d = pa_hashmap_get(u->device_infos, s->sink)))
 
226
        resume(d);
 
227
 
 
228
    return PA_HOOK_OK;
 
229
}
 
230
 
 
231
static pa_hook_result_t source_output_move_start_hook_cb(pa_core *c, pa_source_output *s, struct userdata *u) {
 
232
    struct device_info *d = NULL;
 
233
 
 
234
    pa_assert(c);
 
235
    pa_source_output_assert_ref(s);
 
236
    pa_assert(u);
 
237
 
 
238
    if (s->source->monitor_of) {
 
239
        if (pa_sink_check_suspend(s->source->monitor_of) <= 1)
 
240
            d = pa_hashmap_get(u->device_infos, s->source->monitor_of);
 
241
    } else {
 
242
        if (pa_source_check_suspend(s->source) <= 1)
 
243
            d = pa_hashmap_get(u->device_infos, s->source);
 
244
    }
 
245
 
 
246
    if (d)
 
247
        restart(d);
 
248
 
 
249
    return PA_HOOK_OK;
 
250
}
 
251
 
 
252
static pa_hook_result_t source_output_move_finish_hook_cb(pa_core *c, pa_source_output *s, struct userdata *u) {
 
253
    struct device_info *d;
 
254
 
 
255
    pa_assert(c);
 
256
    pa_source_output_assert_ref(s);
 
257
    pa_assert(u);
 
258
 
 
259
    if (s->source->monitor_of)
 
260
        d = pa_hashmap_get(u->device_infos, s->source->monitor_of);
 
261
    else
 
262
        d = pa_hashmap_get(u->device_infos, s->source);
 
263
 
 
264
    if (d)
 
265
        resume(d);
214
266
 
215
267
    return PA_HOOK_OK;
216
268
}
231
283
}
232
284
 
233
285
static pa_hook_result_t source_output_state_changed_hook_cb(pa_core *c, pa_source_output *s, struct userdata *u) {
234
 
    struct device_info *d;
235
286
    pa_source_output_state_t state;
 
287
 
236
288
    pa_assert(c);
237
289
    pa_source_output_assert_ref(s);
238
290
    pa_assert(u);
239
291
 
240
292
    state = pa_source_output_get_state(s);
241
 
    if (state == PA_SOURCE_OUTPUT_RUNNING)
242
 
        if ((d = pa_hashmap_get(u->device_infos, s->source)))
 
293
 
 
294
    if (state == PA_SOURCE_OUTPUT_RUNNING) {
 
295
        struct device_info *d;
 
296
 
 
297
        if (s->source->monitor_of)
 
298
            d = pa_hashmap_get(u->device_infos, s->source->monitor_of);
 
299
        else
 
300
            d = pa_hashmap_get(u->device_infos, s->source);
 
301
 
 
302
        if (d)
243
303
            resume(d);
 
304
    }
244
305
 
245
306
    return PA_HOOK_OK;
246
307
}
257
318
    source = pa_source_isinstance(o) ? PA_SOURCE(o) : NULL;
258
319
    sink = pa_sink_isinstance(o) ? PA_SINK(o) : NULL;
259
320
 
 
321
    /* Never suspend monitors */
 
322
    if (source && source->monitor_of)
 
323
        return PA_HOOK_OK;
 
324
 
260
325
    pa_assert(source || sink);
261
326
 
262
327
    d = pa_xnew(struct device_info, 1);
266
331
    d->time_event = c->mainloop->time_new(c->mainloop, NULL, timeout_cb, d);
267
332
    pa_hashmap_put(u->device_infos, o, d);
268
333
 
269
 
    if ((d->sink && pa_sink_used_by(d->sink) <= 0) ||
270
 
        (d->source && pa_source_used_by(d->source) <= 0))
 
334
    if ((d->sink && pa_sink_check_suspend(d->sink) <= 0) ||
 
335
        (d->source && pa_source_check_suspend(d->source) <= 0))
271
336
        restart(d);
272
337
 
273
338
    return PA_HOOK_OK;
313
378
        pa_sink *s = PA_SINK(o);
314
379
        pa_sink_state_t state = pa_sink_get_state(s);
315
380
 
316
 
        if (pa_sink_used_by(s) <= 0) {
 
381
        if (pa_sink_check_suspend(s) <= 0) {
317
382
 
318
383
            if (PA_SINK_IS_OPENED(state))
319
384
                restart(d);
324
389
        pa_source *s = PA_SOURCE(o);
325
390
        pa_source_state_t state = pa_source_get_state(s);
326
391
 
327
 
        if (pa_source_used_by(s) <= 0) {
 
392
        if (pa_source_check_suspend(s) <= 0) {
328
393
 
329
394
            if (PA_SOURCE_IS_OPENED(state))
330
395
                restart(d);
376
441
    u->source_output_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_FIXATE], PA_HOOK_NORMAL, (pa_hook_cb_t) source_output_fixate_hook_cb, u);
377
442
    u->sink_input_unlink_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_UNLINK_POST], PA_HOOK_NORMAL, (pa_hook_cb_t) sink_input_unlink_hook_cb, u);
378
443
    u->source_output_unlink_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK_POST], PA_HOOK_NORMAL, (pa_hook_cb_t) source_output_unlink_hook_cb, u);
379
 
    u->sink_input_move_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE], PA_HOOK_NORMAL, (pa_hook_cb_t) sink_input_move_hook_cb, u);
380
 
    u->source_output_move_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE], PA_HOOK_NORMAL, (pa_hook_cb_t) source_output_move_hook_cb, u);
 
444
    u->sink_input_move_start_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_START], PA_HOOK_NORMAL, (pa_hook_cb_t) sink_input_move_start_hook_cb, u);
 
445
    u->source_output_move_start_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_START], PA_HOOK_NORMAL, (pa_hook_cb_t) source_output_move_start_hook_cb, u);
 
446
    u->sink_input_move_finish_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_FINISH], PA_HOOK_NORMAL, (pa_hook_cb_t) sink_input_move_finish_hook_cb, u);
 
447
    u->source_output_move_finish_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FINISH], PA_HOOK_NORMAL, (pa_hook_cb_t) source_output_move_finish_hook_cb, u);
381
448
    u->sink_input_state_changed_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) sink_input_state_changed_hook_cb, u);
382
449
    u->source_output_state_changed_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_STATE_CHANGED], PA_HOOK_NORMAL, (pa_hook_cb_t) source_output_state_changed_hook_cb, u);
383
450
 
421
488
        pa_hook_slot_free(u->sink_input_new_slot);
422
489
    if (u->sink_input_unlink_slot)
423
490
        pa_hook_slot_free(u->sink_input_unlink_slot);
424
 
    if (u->sink_input_move_slot)
425
 
        pa_hook_slot_free(u->sink_input_move_slot);
 
491
    if (u->sink_input_move_start_slot)
 
492
        pa_hook_slot_free(u->sink_input_move_start_slot);
 
493
    if (u->sink_input_move_finish_slot)
 
494
        pa_hook_slot_free(u->sink_input_move_finish_slot);
426
495
    if (u->sink_input_state_changed_slot)
427
496
        pa_hook_slot_free(u->sink_input_state_changed_slot);
428
497
 
430
499
        pa_hook_slot_free(u->source_output_new_slot);
431
500
    if (u->source_output_unlink_slot)
432
501
        pa_hook_slot_free(u->source_output_unlink_slot);
433
 
    if (u->source_output_move_slot)
434
 
        pa_hook_slot_free(u->source_output_move_slot);
 
502
    if (u->source_output_move_start_slot)
 
503
        pa_hook_slot_free(u->source_output_move_start_slot);
 
504
    if (u->source_output_move_finish_slot)
 
505
        pa_hook_slot_free(u->source_output_move_finish_slot);
435
506
    if (u->source_output_state_changed_slot)
436
507
        pa_hook_slot_free(u->source_output_state_changed_slot);
437
508