From: Jyri Sarha <jyri.sarha@xxxxxxxxx> 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. --- src/pulse/stream.c | 28 ++++++++++++++++++++++++---- 1 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/pulse/stream.c b/src/pulse/stream.c index aac18a3..cd33bc1 100644 --- a/src/pulse/stream.c +++ b/src/pulse/stream.c @@ -328,12 +328,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); + } } } @@ -414,6 +420,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; @@ -501,6 +509,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); @@ -619,6 +633,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); -- 1.7.1