[pulseaudio-commits] r1902 - /branches/lennart/src/modules/module-suspend-on-idle.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Mon Sep 24 16:32:54 PDT 2007
Author: lennart
Date: Tue Sep 25 01:32:52 2007
New Revision: 1902
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1902&root=pulseaudio&view=rev
Log:
* decouple suspending of monitor sources and their sinks
* implement resume-on-uncork
Modified:
branches/lennart/src/modules/module-suspend-on-idle.c
Modified: branches/lennart/src/modules/module-suspend-on-idle.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/module-suspend-on-idle.c?rev=1902&root=pulseaudio&r1=1901&r2=1902&view=diff
==============================================================================
--- branches/lennart/src/modules/module-suspend-on-idle.c (original)
+++ branches/lennart/src/modules/module-suspend-on-idle.c Tue Sep 25 01:32:52 2007
@@ -66,7 +66,9 @@
*sink_input_move_slot,
*source_output_move_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 {
@@ -86,13 +88,12 @@
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_sink_suspend(d->sink, 1);
- pa_source_suspend(d->sink->monitor_source, 1);
+ pa_sink_suspend(d->sink, TRUE);
}
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_source_suspend(d->source, 1);
+ pa_source_suspend(d->source, TRUE);
}
}
@@ -117,16 +118,13 @@
d->userdata->core->mainloop->time_restart(d->time_event, NULL);
if (d->sink) {
- pa_sink_suspend(d->sink, 0);
- pa_source_suspend(d->sink->monitor_source, 0);
+ pa_sink_suspend(d->sink, FALSE);
pa_log_debug("Sink %s becomes busy.", d->sink->name);
}
if (d->source) {
- pa_source_suspend(d->source, 0);
- if (d->source->monitor_of)
- pa_sink_suspend(d->source->monitor_of, 0);
+ pa_source_suspend(d->source, FALSE);
pa_log_debug("Source %s becomes busy.", d->source->name);
}
@@ -235,6 +233,36 @@
if ((d = pa_hashmap_get(u->device_infos, s->source)))
resume(d);
+
+ 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;
}
@@ -305,21 +333,22 @@
if (pa_sink_isinstance(o)) {
pa_sink *s = PA_SINK(o);
+ pa_sink_state_t state = pa_sink_get_state(s);
if (pa_sink_used_by(s) <= 0) {
- pa_sink_state_t state = pa_sink_get_state(s);
-
- if (state == PA_SINK_RUNNING || state == PA_SINK_IDLE)
+
+ if (PA_SINK_OPENED(state))
restart(d);
+
}
} else if (pa_source_isinstance(o)) {
pa_source *s = PA_SOURCE(o);
+ pa_source_state_t state = pa_source_get_state(s);
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);
}
}
@@ -373,6 +402,8 @@
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->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);
@@ -419,6 +450,8 @@
pa_hook_slot_free(u->sink_input_move_slot);
if (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)
pa_hook_slot_free(u->source_output_new_slot);
@@ -428,6 +461,8 @@
pa_hook_slot_free(u->source_output_move_slot);
if (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)))
device_info_free(d);
More information about the pulseaudio-commits
mailing list