summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Dalleau <frederic.dalleau@linux.intel.com>2012-09-20 14:28:33 +0200
committerJaska Uimonen <jaska.uimonen@intel.com>2013-01-24 09:29:36 +0200
commit4f3e2b85141460f37d6c23ab893a0ba26f4bb07a (patch)
tree900aac59f5ac3acc295bd9eb9dcfccaf63ebd2ca
parent1aa262d0471026f887cd072875dcce743a5fab3b (diff)
downloadpulseaudio-panda-4f3e2b85141460f37d6c23ab893a0ba26f4bb07a.tar.gz
pulseaudio-panda-4f3e2b85141460f37d6c23ab893a0ba26f4bb07a.tar.bz2
pulseaudio-panda-4f3e2b85141460f37d6c23ab893a0ba26f4bb07a.zip
loopback: Cork source-output if sink is suspended
During initialization, the approach avoids having a needless short period of corked state in case the sink is suspended, by always creating the source-output corked and uncorking it immediately afterwards when the sink is not suspended.
-rw-r--r--src/modules/module-loopback.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/modules/module-loopback.c b/src/modules/module-loopback.c
index 25a2ba82..ad038164 100644
--- a/src/modules/module-loopback.c
+++ b/src/modules/module-loopback.c
@@ -655,6 +655,17 @@ static pa_bool_t sink_input_may_move_to_cb(pa_sink_input *i, pa_sink *dest) {
return dest != u->source_output->source->monitor_of;
}
+/* Called from main thread */
+static void sink_input_suspend_cb(pa_sink_input *i, pa_bool_t suspended) {
+ struct userdata *u;
+
+ pa_sink_input_assert_ref(i);
+ pa_assert_ctl_context();
+ pa_assert_se(u = i->userdata);
+
+ pa_source_output_cork(u->source_output, suspended);
+}
+
int pa__init(pa_module *m) {
pa_modargs *ma = NULL;
struct userdata *u;
@@ -817,6 +828,7 @@ int pa__init(pa_module *m) {
u->sink_input->update_max_request = sink_input_update_max_request_cb;
u->sink_input->may_move_to = sink_input_may_move_to_cb;
u->sink_input->moving = sink_input_moving_cb;
+ u->sink_input->suspend = sink_input_suspend_cb;
u->sink_input->userdata = u;
pa_sink_input_set_requested_latency(u->sink_input, u->latency/3);
@@ -838,6 +850,7 @@ int pa__init(pa_module *m) {
pa_source_output_new_data_set_sample_spec(&source_output_data, &ss);
pa_source_output_new_data_set_channel_map(&source_output_data, &map);
+ source_output_data.flags = PA_SOURCE_OUTPUT_START_CORKED;
if (!remix)
source_output_data.flags |= PA_SOURCE_OUTPUT_NO_REMIX;
@@ -917,6 +930,9 @@ int pa__init(pa_module *m) {
if (pa_source_get_state(u->source_output->source) != PA_SOURCE_SUSPENDED)
pa_sink_input_cork(u->sink_input, FALSE);
+ if (pa_sink_get_state(u->sink_input->sink) != PA_SINK_SUSPENDED)
+ pa_source_output_cork(u->source_output, FALSE);
+
if (u->adjust_time > 0)
u->time_event = pa_core_rttime_new(m->core, pa_rtclock_now() + u->adjust_time, time_callback, u);