summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanu Kaskinen <tanu.kaskinen@linux.intel.com>2014-12-30 00:33:05 +0200
committerTanu Kaskinen <tanu.kaskinen@linux.intel.com>2015-01-02 14:33:05 +0200
commite0e0ebb03f949eef446305a2966b288382a27398 (patch)
tree42266d089136d92c5a1a5fd3b73bc119ceafb8ad
parentab830d887c5b69927a6eb4db9576beaf3411a6e8 (diff)
tunnel-sink-new: Fix stale audio on resume
I noticed that when resuming the tunnel sink, there was a small amount of previously played audio before the new audio started to play. Normally that probably wouldn't be noticeable, because there would be a few seconds of silence played before suspending the sink due to inactivity, so the unwanted old audio would be just silence, but in my configuration sinks are suspended immediately when there's nothing playing to them, so the glitch becomes audible.
-rw-r--r--src/modules/module-tunnel-sink-new.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/modules/module-tunnel-sink-new.c b/src/modules/module-tunnel-sink-new.c
index 7d3bd9989..1b3858d32 100644
--- a/src/modules/module-tunnel-sink-new.c
+++ b/src/modules/module-tunnel-sink-new.c
@@ -109,6 +109,15 @@ static void cork_stream(struct userdata *u, bool cork) {
pa_assert(u);
pa_assert(u->stream);
+ if (cork) {
+ /* When the sink becomes suspended (which is the only case where we
+ * cork the stream), we don't want to keep any old data around, because
+ * the old data is most likely unrelated to the audio that will be
+ * played at the time when the sink starts running again. */
+ if ((operation = pa_stream_flush(u->stream, NULL, NULL)))
+ pa_operation_unref(operation);
+ }
+
if ((operation = pa_stream_cork(u->stream, cork, NULL, NULL)))
pa_operation_unref(operation);
}