summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/sink.c
diff options
context:
space:
mode:
authorJyri Sarha <jyri.sarha@nokia.com>2011-01-13 16:44:42 +0200
committerColin Guthrie <cguthrie@mandriva.org>2011-01-15 13:23:02 +0000
commit6fd138f66998b4c62a1acea7ba55ea6c7b854b48 (patch)
tree7c62a436b054e784a90720e20fd625f834110718 /src/pulsecore/sink.c
parent34d022c16e654975c771f76511ef0d89bef6bec2 (diff)
core: Use volume_change_safety_margin when rewinding sync-volume events
After this patch the volume changes are applied immediately after sink rewind before processing streams and monitor source.
Diffstat (limited to 'src/pulsecore/sink.c')
-rw-r--r--src/pulsecore/sink.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 7b4e626d..acaed15e 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -751,8 +751,11 @@ void pa_sink_process_rewind(pa_sink *s, size_t nbytes) {
if (s->thread_info.state == PA_SINK_SUSPENDED)
return;
- if (nbytes > 0)
+ if (nbytes > 0) {
pa_log_debug("Processing rewind...");
+ if (s->flags & PA_SINK_SYNC_VOLUME)
+ pa_sink_volume_change_rewind(s, nbytes);
+ }
PA_HASHMAP_FOREACH(i, s->thread_info.inputs, state) {
pa_sink_input_assert_ref(i);
@@ -762,8 +765,6 @@ void pa_sink_process_rewind(pa_sink *s, size_t nbytes) {
if (nbytes > 0) {
if (s->monitor_source && PA_SOURCE_IS_LINKED(s->monitor_source->thread_info.state))
pa_source_process_rewind(s->monitor_source, nbytes);
- if (s->flags & PA_SINK_SYNC_VOLUME)
- pa_sink_volume_change_rewind(s, nbytes);
}
}
@@ -3006,6 +3007,7 @@ pa_bool_t pa_sink_volume_change_apply(pa_sink *s, pa_usec_t *usec_to_next) {
static void pa_sink_volume_change_rewind(pa_sink *s, size_t nbytes) {
/* All the queued volume events later than current latency are shifted to happen earlier. */
pa_sink_volume_change *c;
+ pa_volume_t prev_vol = pa_cvolume_avg(&s->thread_info.current_hw_volume);
pa_usec_t rewound = pa_bytes_to_usec(nbytes, &s->sample_spec);
pa_usec_t limit;
@@ -3013,13 +3015,21 @@ static void pa_sink_volume_change_rewind(pa_sink *s, size_t nbytes) {
if (PA_MSGOBJECT(s)->process_msg(PA_MSGOBJECT(s), PA_SINK_MESSAGE_GET_LATENCY, &limit, 0, NULL) < 0)
limit = 0;
+ pa_log_debug("latency = %lld", limit);
limit += pa_rtclock_now() + s->thread_info.volume_change_extra_delay;
PA_LLIST_FOREACH(c, s->thread_info.volume_changes) {
- if (c->at > limit) {
+ pa_usec_t modified_limit = limit;
+ if (prev_vol > pa_cvolume_avg(&c->hw_volume))
+ modified_limit -= s->thread_info.volume_change_safety_margin;
+ else
+ modified_limit += s->thread_info.volume_change_safety_margin;
+ if (c->at > modified_limit) {
c->at -= rewound;
- if (c->at < limit)
- c->at = limit;
+ if (c->at < modified_limit)
+ c->at = modified_limit;
}
+ prev_vol = pa_cvolume_avg(&c->hw_volume);
}
+ pa_sink_volume_change_apply(s, NULL);
}