summaryrefslogtreecommitdiffstats
path: root/src/pulse
diff options
context:
space:
mode:
authorJyri Sarha <jyri.sarha@nokia.com>2011-04-08 17:18:12 +0300
committerColin Guthrie <colin@mageia.org>2011-05-15 14:58:12 +0100
commit47b7ca830e132ee585f9df6efb4aef82f2713d09 (patch)
treec89c367b7067c196d8306aea4fd1c8b235cee285 /src/pulse
parentd5cb59a8d676f2487fa7448f778f608ec3f6d3b8 (diff)
protocol-native: Stop auto timing updates if connected to suspended sink or source
This quite is an old patch. It was added to N900 to avoid unnecessary wake-ups when the phone is in power save mode (= blank screen and no user interaction). In this situation if the user had a browser window with flash animation open pulseaudio kept waking up every 10 seconds, causing a severe hit to use times. Anyway I do not see any reason to send timing updates if the sink or source where the stream is connected to is suspended.
Diffstat (limited to 'src/pulse')
-rw-r--r--src/pulse/stream.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index 6c055a5c..cd5182ab 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -389,12 +389,18 @@ static void request_auto_timing_update(pa_stream *s, pa_bool_t force) {
}
if (s->auto_timing_update_event) {
- if (force)
- s->auto_timing_interval_usec = AUTO_TIMING_INTERVAL_START_USEC;
+ if (s->suspended && !force) {
+ pa_assert(s->mainloop);
+ s->mainloop->time_free(s->auto_timing_update_event);
+ s->auto_timing_update_event = NULL;
+ } else {
+ if (force)
+ s->auto_timing_interval_usec = AUTO_TIMING_INTERVAL_START_USEC;
- pa_context_rttime_restart(s->context, s->auto_timing_update_event, pa_rtclock_now() + s->auto_timing_interval_usec);
+ pa_context_rttime_restart(s->context, s->auto_timing_update_event, pa_rtclock_now() + s->auto_timing_interval_usec);
- s->auto_timing_interval_usec = PA_MIN(AUTO_TIMING_INTERVAL_END_USEC, s->auto_timing_interval_usec*2);
+ s->auto_timing_interval_usec = PA_MIN(AUTO_TIMING_INTERVAL_END_USEC, s->auto_timing_interval_usec*2);
+ }
}
}
@@ -475,6 +481,8 @@ static void check_smoother_status(pa_stream *s, pa_bool_t aposteriori, pa_bool_t
* if prebuf is non-zero! */
}
+static void auto_timing_update_callback(pa_mainloop_api *m, pa_time_event *e, const struct timeval *t, void *userdata);
+
void pa_command_stream_moved(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
pa_context *c = userdata;
pa_stream *s;
@@ -562,6 +570,12 @@ void pa_command_stream_moved(pa_pdispatch *pd, uint32_t command, uint32_t tag, p
s->suspended = suspended;
+ if ((s->flags & PA_STREAM_AUTO_TIMING_UPDATE) && !suspended && !s->auto_timing_update_event) {
+ s->auto_timing_interval_usec = AUTO_TIMING_INTERVAL_START_USEC;
+ s->auto_timing_update_event = pa_context_rttime_new(s->context, pa_rtclock_now() + s->auto_timing_interval_usec, &auto_timing_update_callback, s);
+ request_auto_timing_update(s, TRUE);
+ }
+
check_smoother_status(s, TRUE, FALSE, FALSE);
request_auto_timing_update(s, TRUE);
@@ -680,6 +694,12 @@ void pa_command_stream_suspended(pa_pdispatch *pd, uint32_t command, uint32_t ta
s->suspended = suspended;
+ if ((s->flags & PA_STREAM_AUTO_TIMING_UPDATE) && !suspended && !s->auto_timing_update_event) {
+ s->auto_timing_interval_usec = AUTO_TIMING_INTERVAL_START_USEC;
+ s->auto_timing_update_event = pa_context_rttime_new(s->context, pa_rtclock_now() + s->auto_timing_interval_usec, &auto_timing_update_callback, s);
+ request_auto_timing_update(s, TRUE);
+ }
+
check_smoother_status(s, TRUE, FALSE, FALSE);
request_auto_timing_update(s, TRUE);