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.
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;
84
86
d->userdata->core->mainloop->time_restart(d->time_event, NULL);
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);
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);
170
180
static pa_hook_result_t source_output_unlink_hook_cb(pa_core *c, pa_source_output *s, struct userdata *u) {
172
pa_source_output_assert_ref(s);
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)))
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;
191
if ((d = pa_hashmap_get(u->device_infos, data->destination)))
194
if (pa_sink_used_by(data->sink_input->sink) <= 1)
195
if ((d = pa_hashmap_get(u->device_infos, data->sink_input->sink)))
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;
208
if ((d = pa_hashmap_get(u->device_infos, data->destination)))
211
if (pa_source_used_by(data->source_output->source) <= 1)
212
if ((d = pa_hashmap_get(u->device_infos, data->source_output->source)))
181
struct device_info *d = NULL;
184
pa_source_output_assert_ref(s);
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);
194
if (pa_source_check_suspend(s->source) <= 0)
195
d = pa_hashmap_get(u->device_infos, s->source);
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;
208
pa_sink_input_assert_ref(s);
211
if (pa_sink_check_suspend(s->sink) <= 1)
212
if ((d = pa_hashmap_get(u->device_infos, s->sink)))
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;
222
pa_sink_input_assert_ref(s);
225
if ((d = pa_hashmap_get(u->device_infos, s->sink)))
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;
235
pa_source_output_assert_ref(s);
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);
242
if (pa_source_check_suspend(s->source) <= 1)
243
d = pa_hashmap_get(u->device_infos, s->source);
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;
256
pa_source_output_assert_ref(s);
259
if (s->source->monitor_of)
260
d = pa_hashmap_get(u->device_infos, s->source->monitor_of);
262
d = pa_hashmap_get(u->device_infos, s->source);
215
267
return PA_HOOK_OK;
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;
237
289
pa_source_output_assert_ref(s);
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)))
294
if (state == PA_SOURCE_OUTPUT_RUNNING) {
295
struct device_info *d;
297
if (s->source->monitor_of)
298
d = pa_hashmap_get(u->device_infos, s->source->monitor_of);
300
d = pa_hashmap_get(u->device_infos, s->source);
245
306
return PA_HOOK_OK;
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);
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))
273
338
return PA_HOOK_OK;
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);
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);
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);