diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 21c672364..05b08aaf5 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -3400,12 +3400,12 @@ static void pa_sink_volume_change_flush(pa_sink *s) { /* Called from the IO thread. */ pa_bool_t pa_sink_volume_change_apply(pa_sink *s, pa_usec_t *usec_to_next) { - pa_usec_t now = pa_rtclock_now(); + pa_usec_t now; pa_bool_t ret = FALSE; pa_assert(s); - if (!PA_SINK_IS_LINKED(s->state)) { + if (!s->thread_info.volume_changes || !PA_SINK_IS_LINKED(s->state)) { if (usec_to_next) *usec_to_next = 0; return ret; @@ -3413,6 +3413,8 @@ pa_bool_t pa_sink_volume_change_apply(pa_sink *s, pa_usec_t *usec_to_next) { pa_assert(s->write_volume); + now = pa_rtclock_now(); + while (s->thread_info.volume_changes && now >= s->thread_info.volume_changes->at) { pa_sink_volume_change *c = s->thread_info.volume_changes; PA_LLIST_REMOVE(pa_sink_volume_change, s->thread_info.volume_changes, c); @@ -3423,7 +3425,7 @@ pa_bool_t pa_sink_volume_change_apply(pa_sink *s, pa_usec_t *usec_to_next) { pa_sink_volume_change_free(c); } - if (s->write_volume && ret) + if (ret) s->write_volume(s); if (s->thread_info.volume_changes) { diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c index 523961010..d47280ce8 100644 --- a/src/pulsecore/source.c +++ b/src/pulsecore/source.c @@ -2575,12 +2575,12 @@ static void pa_source_volume_change_flush(pa_source *s) { /* Called from the IO thread. */ pa_bool_t pa_source_volume_change_apply(pa_source *s, pa_usec_t *usec_to_next) { - pa_usec_t now = pa_rtclock_now(); + pa_usec_t now; pa_bool_t ret = FALSE; pa_assert(s); - if (!PA_SOURCE_IS_LINKED(s->state)) { + if (!s->thread_info.volume_changes || !PA_SOURCE_IS_LINKED(s->state)) { if (usec_to_next) *usec_to_next = 0; return ret; @@ -2588,6 +2588,8 @@ pa_bool_t pa_source_volume_change_apply(pa_source *s, pa_usec_t *usec_to_next) { pa_assert(s->write_volume); + now = pa_rtclock_now(); + while (s->thread_info.volume_changes && now >= s->thread_info.volume_changes->at) { pa_source_volume_change *c = s->thread_info.volume_changes; PA_LLIST_REMOVE(pa_source_volume_change, s->thread_info.volume_changes, c); @@ -2598,7 +2600,7 @@ pa_bool_t pa_source_volume_change_apply(pa_source *s, pa_usec_t *usec_to_next) { pa_source_volume_change_free(c); } - if (s->write_volume && ret) + if (ret) s->write_volume(s); if (s->thread_info.volume_changes) {