mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-11 13:30:02 -05:00
* decouple suspending of monitor sources and their sinks
* implement resume-on-uncork git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1902 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
0e3e9e2274
commit
609ad12f29
1 changed files with 48 additions and 13 deletions
|
|
@ -66,7 +66,9 @@ struct userdata {
|
||||||
*sink_input_move_slot,
|
*sink_input_move_slot,
|
||||||
*source_output_move_slot,
|
*source_output_move_slot,
|
||||||
*sink_input_move_post_slot,
|
*sink_input_move_post_slot,
|
||||||
*source_output_move_post_slot;
|
*source_output_move_post_slot,
|
||||||
|
*sink_input_state_changed_slot,
|
||||||
|
*source_output_state_changed_slot;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct device_info {
|
struct device_info {
|
||||||
|
|
@ -86,13 +88,12 @@ static void timeout_cb(pa_mainloop_api*a, pa_time_event* e, const struct timeval
|
||||||
|
|
||||||
if (d->sink && pa_sink_used_by(d->sink) <= 0 && pa_sink_get_state(d->sink) != PA_SINK_SUSPENDED) {
|
if (d->sink && pa_sink_used_by(d->sink) <= 0 && pa_sink_get_state(d->sink) != PA_SINK_SUSPENDED) {
|
||||||
pa_log_info("Sink %s idle for too long, suspending ...", d->sink->name);
|
pa_log_info("Sink %s idle for too long, suspending ...", d->sink->name);
|
||||||
pa_sink_suspend(d->sink, 1);
|
pa_sink_suspend(d->sink, TRUE);
|
||||||
pa_source_suspend(d->sink->monitor_source, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->source && pa_source_used_by(d->source) <= 0 && pa_source_get_state(d->source) != PA_SOURCE_SUSPENDED) {
|
if (d->source && pa_source_used_by(d->source) <= 0 && pa_source_get_state(d->source) != PA_SOURCE_SUSPENDED) {
|
||||||
pa_log_info("Source %s idle for too long, suspending ...", d->source->name);
|
pa_log_info("Source %s idle for too long, suspending ...", d->source->name);
|
||||||
pa_source_suspend(d->source, 1);
|
pa_source_suspend(d->source, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,16 +118,13 @@ static void resume(struct device_info *d) {
|
||||||
d->userdata->core->mainloop->time_restart(d->time_event, NULL);
|
d->userdata->core->mainloop->time_restart(d->time_event, NULL);
|
||||||
|
|
||||||
if (d->sink) {
|
if (d->sink) {
|
||||||
pa_sink_suspend(d->sink, 0);
|
pa_sink_suspend(d->sink, FALSE);
|
||||||
pa_source_suspend(d->sink->monitor_source, 0);
|
|
||||||
|
|
||||||
pa_log_debug("Sink %s becomes busy.", d->sink->name);
|
pa_log_debug("Sink %s becomes busy.", d->sink->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->source) {
|
if (d->source) {
|
||||||
pa_source_suspend(d->source, 0);
|
pa_source_suspend(d->source, FALSE);
|
||||||
if (d->source->monitor_of)
|
|
||||||
pa_sink_suspend(d->source->monitor_of, 0);
|
|
||||||
|
|
||||||
pa_log_debug("Source %s becomes busy.", d->source->name);
|
pa_log_debug("Source %s becomes busy.", d->source->name);
|
||||||
}
|
}
|
||||||
|
|
@ -239,6 +237,36 @@ static pa_hook_result_t source_output_move_post_hook_cb(pa_core *c, pa_source_ou
|
||||||
return PA_HOOK_OK;
|
return PA_HOOK_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static pa_hook_result_t sink_input_state_changed_hook_cb(pa_core *c, pa_sink_input *s, struct userdata *u) {
|
||||||
|
struct device_info *d;
|
||||||
|
pa_sink_input_state_t state;
|
||||||
|
pa_assert(c);
|
||||||
|
pa_sink_input_assert_ref(s);
|
||||||
|
pa_assert(u);
|
||||||
|
|
||||||
|
state = pa_sink_input_get_state(s);
|
||||||
|
if (state == PA_SINK_INPUT_RUNNING || state == PA_SINK_INPUT_DRAINED)
|
||||||
|
if ((d = pa_hashmap_get(u->device_infos, s->sink)))
|
||||||
|
resume(d);
|
||||||
|
|
||||||
|
return PA_HOOK_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static pa_hook_result_t source_output_state_changed_hook_cb(pa_core *c, pa_source_output *s, struct userdata *u) {
|
||||||
|
struct device_info *d;
|
||||||
|
pa_source_output_state_t state;
|
||||||
|
pa_assert(c);
|
||||||
|
pa_source_output_assert_ref(s);
|
||||||
|
pa_assert(u);
|
||||||
|
|
||||||
|
state = pa_source_output_get_state(s);
|
||||||
|
if (state == PA_SOURCE_OUTPUT_RUNNING)
|
||||||
|
if ((d = pa_hashmap_get(u->device_infos, s->source)))
|
||||||
|
resume(d);
|
||||||
|
|
||||||
|
return PA_HOOK_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static pa_hook_result_t device_new_hook_cb(pa_core *c, pa_object *o, struct userdata *u) {
|
static pa_hook_result_t device_new_hook_cb(pa_core *c, pa_object *o, struct userdata *u) {
|
||||||
struct device_info *d;
|
struct device_info *d;
|
||||||
pa_source *source;
|
pa_source *source;
|
||||||
|
|
@ -305,21 +333,22 @@ static pa_hook_result_t device_state_changed_hook_cb(pa_core *c, pa_object *o, s
|
||||||
|
|
||||||
if (pa_sink_isinstance(o)) {
|
if (pa_sink_isinstance(o)) {
|
||||||
pa_sink *s = PA_SINK(o);
|
pa_sink *s = PA_SINK(o);
|
||||||
|
|
||||||
if (pa_sink_used_by(s) <= 0) {
|
|
||||||
pa_sink_state_t state = pa_sink_get_state(s);
|
pa_sink_state_t state = pa_sink_get_state(s);
|
||||||
|
|
||||||
if (state == PA_SINK_RUNNING || state == PA_SINK_IDLE)
|
if (pa_sink_used_by(s) <= 0) {
|
||||||
|
|
||||||
|
if (PA_SINK_OPENED(state))
|
||||||
restart(d);
|
restart(d);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (pa_source_isinstance(o)) {
|
} else if (pa_source_isinstance(o)) {
|
||||||
pa_source *s = PA_SOURCE(o);
|
pa_source *s = PA_SOURCE(o);
|
||||||
|
pa_source_state_t state = pa_source_get_state(s);
|
||||||
|
|
||||||
if (pa_source_used_by(s) <= 0) {
|
if (pa_source_used_by(s) <= 0) {
|
||||||
pa_sink_state_t state = pa_source_get_state(s);
|
|
||||||
|
|
||||||
if (state == PA_SINK_RUNNING || state == PA_SINK_IDLE)
|
if (PA_SOURCE_OPENED(state))
|
||||||
restart(d);
|
restart(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -373,6 +402,8 @@ int pa__init(pa_module*m) {
|
||||||
u->source_output_move_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE], (pa_hook_cb_t) source_output_move_hook_cb, u);
|
u->source_output_move_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE], (pa_hook_cb_t) source_output_move_hook_cb, u);
|
||||||
u->sink_input_move_post_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_POST], (pa_hook_cb_t) sink_input_move_post_hook_cb, u);
|
u->sink_input_move_post_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_POST], (pa_hook_cb_t) sink_input_move_post_hook_cb, u);
|
||||||
u->source_output_move_post_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_POST], (pa_hook_cb_t) source_output_move_post_hook_cb, u);
|
u->source_output_move_post_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_POST], (pa_hook_cb_t) source_output_move_post_hook_cb, u);
|
||||||
|
u->sink_input_state_changed_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED], (pa_hook_cb_t) sink_input_state_changed_hook_cb, u);
|
||||||
|
u->source_output_state_changed_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_STATE_CHANGED], (pa_hook_cb_t) source_output_state_changed_hook_cb, u);
|
||||||
|
|
||||||
|
|
||||||
pa_modargs_free(ma);
|
pa_modargs_free(ma);
|
||||||
|
|
@ -419,6 +450,8 @@ void pa__done(pa_module*m) {
|
||||||
pa_hook_slot_free(u->sink_input_move_slot);
|
pa_hook_slot_free(u->sink_input_move_slot);
|
||||||
if (u->sink_input_move_post_slot)
|
if (u->sink_input_move_post_slot)
|
||||||
pa_hook_slot_free(u->sink_input_move_post_slot);
|
pa_hook_slot_free(u->sink_input_move_post_slot);
|
||||||
|
if (u->sink_input_state_changed_slot)
|
||||||
|
pa_hook_slot_free(u->sink_input_state_changed_slot);
|
||||||
|
|
||||||
if (u->source_output_new_slot)
|
if (u->source_output_new_slot)
|
||||||
pa_hook_slot_free(u->source_output_new_slot);
|
pa_hook_slot_free(u->source_output_new_slot);
|
||||||
|
|
@ -428,6 +461,8 @@ void pa__done(pa_module*m) {
|
||||||
pa_hook_slot_free(u->source_output_move_slot);
|
pa_hook_slot_free(u->source_output_move_slot);
|
||||||
if (u->source_output_move_post_slot)
|
if (u->source_output_move_post_slot)
|
||||||
pa_hook_slot_free(u->source_output_move_post_slot);
|
pa_hook_slot_free(u->source_output_move_post_slot);
|
||||||
|
if (u->source_output_state_changed_slot)
|
||||||
|
pa_hook_slot_free(u->source_output_state_changed_slot);
|
||||||
|
|
||||||
while ((d = pa_hashmap_steal_first(u->device_infos)))
|
while ((d = pa_hashmap_steal_first(u->device_infos)))
|
||||||
device_info_free(d);
|
device_info_free(d);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue