1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
From f7bd6ce2a684a3ec6158ee0990587bd4b3b6deda Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Marc-Andr=C3=A9=20Lureau?= <marc-andre.lureau@nokia.com>
Date: Tue, 12 May 2009 01:48:05 +0300
Subject: [PATCH 38/85] suspend-on-idle: add per-device timeout property
---
src/modules/module-suspend-on-idle.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/modules/module-suspend-on-idle.c b/src/modules/module-suspend-on-idle.c
index 5200f19..8883780 100644
--- a/src/modules/module-suspend-on-idle.c
+++ b/src/modules/module-suspend-on-idle.c
@@ -28,6 +28,7 @@
#include <pulse/rtclock.h>
#include <pulsecore/core.h>
+#include <pulsecore/core-util.h>
#include <pulsecore/sink-input.h>
#include <pulsecore/source-output.h>
#include <pulsecore/modargs.h>
@@ -99,16 +100,24 @@ static void timeout_cb(pa_mainloop_api*a, pa_time_event* e, pa_usec_t t, void *u
static void restart(struct device_info *d) {
pa_usec_t now;
+ const char *s;
+ uint32_t timeout;
pa_assert(d);
+ pa_assert(d->sink || d->source);
d->last_use = now = pa_rtclock_now();
- d->userdata->core->mainloop->rtclock_time_restart(d->time_event, now + d->userdata->timeout * PA_USEC_PER_SEC);
+
+ s = pa_proplist_gets(d->sink ? d->sink->proplist : d->source->proplist, "module-suspend-on-idle.timeout");
+ if (!s || pa_atou(s, &timeout) < 0)
+ timeout = d->userdata->timeout;
+
+ d->userdata->core->mainloop->rtclock_time_restart(d->time_event, now + timeout * PA_USEC_PER_SEC);
if (d->sink)
- pa_log_debug("Sink %s becomes idle.", d->sink->name);
+ pa_log_debug("Sink %s becomes idle, timeout in %u seconds.", d->sink->name, timeout);
if (d->source)
- pa_log_debug("Source %s becomes idle.", d->source->name);
+ pa_log_debug("Source %s becomes idle, timeout in %u seconds.", d->source->name, timeout);
}
static void resume(struct device_info *d) {
--
1.6.3.3
|