4fd38b9
From dd682d6f96fe7133b866c97b72edcb6136a9737c Mon Sep 17 00:00:00 2001
4fd38b9
From: Lennart Poettering <lennart@poettering.net>
4fd38b9
Date: Mon, 22 Feb 2010 04:54:24 +0100
4fd38b9
Subject: [PATCH 59/62] alsa: reset max_rewind/max_request while suspending
4fd38b9
4fd38b9
---
4fd38b9
 src/modules/alsa/alsa-sink.c |   11 ++++++++++-
4fd38b9
 1 files changed, 10 insertions(+), 1 deletions(-)
4fd38b9
4fd38b9
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
4fd38b9
index 690480f..60c10c4 100644
4fd38b9
--- a/src/modules/alsa/alsa-sink.c
4fd38b9
+++ b/src/modules/alsa/alsa-sink.c
4fd38b9
@@ -79,7 +79,7 @@
4fd38b9
 #define TSCHED_MIN_WAKEUP_USEC (4*PA_USEC_PER_MSEC)                /* 4ms   -- Wakeup at least this long before the buffer runs empty*/
4fd38b9
 
4fd38b9
 #define SMOOTHER_MIN_INTERVAL (2*PA_USEC_PER_MSEC)                 /* 2ms   -- min smoother update interval */
4fd38b9
-#define SMOOTHER_MAX_INTERVAL (200*PA_USEC_PER_MSEC)               /* 200ms -- max smoother update inteval */
4fd38b9
+#define SMOOTHER_MAX_INTERVAL (200*PA_USEC_PER_MSEC)               /* 200ms -- max smoother update interval */
4fd38b9
 
4fd38b9
 #define VOLUME_ACCURACY (PA_VOLUME_NORM/100)  /* don't require volume adjustments to be perfectly correct. don't necessarily extend granularity in software unless the differences get greater than this level */
4fd38b9
 
4fd38b9
@@ -876,6 +876,14 @@ static int suspend(struct userdata *u) {
4fd38b9
         u->alsa_rtpoll_item = NULL;
4fd38b9
     }
4fd38b9
 
4fd38b9
+    /* We reset max_rewind/max_request here to make sure that while we
4fd38b9
+     * are suspended the old max_request/max_rewind values set before
4fd38b9
+     * the suspend can influence the per-stream buffer of newly
4fd38b9
+     * created streams, without their requirements having any
4fd38b9
+     * influence on them. */
4fd38b9
+    pa_sink_set_max_rewind_within_thread(u->sink, 0);
4fd38b9
+    pa_sink_set_max_request_within_thread(u->sink, 0);
4fd38b9
+
4fd38b9
     pa_log_info("Device suspended...");
4fd38b9
 
4fd38b9
     return 0;
4fd38b9
@@ -933,6 +941,7 @@ static int update_sw_params(struct userdata *u) {
4fd38b9
     }
4fd38b9
 
4fd38b9
     pa_sink_set_max_request_within_thread(u->sink, u->hwbuf_size - u->hwbuf_unused);
4fd38b9
+    pa_sink_set_max_rewind_within_thread(u->sink, u->hwbuf_size);
4fd38b9
 
4fd38b9
     return 0;
4fd38b9
 }
4fd38b9
-- 
4fd38b9
1.7.0
4fd38b9