mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
sink, source: Assign to reference_volume from only one place
Forcing all reference volume changes to go through set_reference_volume_direct() makes it easier to check where the reference volume is changed, and it also allows us to have only one place where notifications for changed reference volume are sent.
This commit is contained in:
parent
a388b909f3
commit
fb70fa22c3
6 changed files with 86 additions and 34 deletions
|
|
@ -1954,13 +1954,11 @@ static bool update_reference_volume(pa_sink *s, const pa_cvolume *v, const pa_ch
|
|||
pa_cvolume_remap(&volume, channel_map, &s->channel_map);
|
||||
|
||||
reference_volume_changed = !pa_cvolume_equal(&volume, &s->reference_volume);
|
||||
s->reference_volume = volume;
|
||||
pa_sink_set_reference_volume_direct(s, &volume);
|
||||
|
||||
s->save_volume = (!reference_volume_changed && s->save_volume) || save;
|
||||
|
||||
if (reference_volume_changed)
|
||||
pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
|
||||
else if (!(s->flags & PA_SINK_SHARE_VOLUME_WITH_MASTER))
|
||||
if (!reference_volume_changed && !(s->flags & PA_SINK_SHARE_VOLUME_WITH_MASTER))
|
||||
/* If the root sink's volume doesn't change, then there can't be any
|
||||
* changes in the other sinks in the sink tree either.
|
||||
*
|
||||
|
|
@ -3798,3 +3796,27 @@ done:
|
|||
|
||||
return out_formats;
|
||||
}
|
||||
|
||||
/* Called from the main thread. */
|
||||
void pa_sink_set_reference_volume_direct(pa_sink *s, const pa_cvolume *volume) {
|
||||
pa_cvolume old_volume;
|
||||
char old_volume_str[PA_CVOLUME_SNPRINT_VERBOSE_MAX];
|
||||
char new_volume_str[PA_CVOLUME_SNPRINT_VERBOSE_MAX];
|
||||
|
||||
pa_assert(s);
|
||||
pa_assert(volume);
|
||||
|
||||
old_volume = s->reference_volume;
|
||||
|
||||
if (pa_cvolume_equal(volume, &old_volume))
|
||||
return;
|
||||
|
||||
s->reference_volume = *volume;
|
||||
pa_log_debug("The reference volume of sink %s changed from %s to %s.", s->name,
|
||||
pa_cvolume_snprint_verbose(old_volume_str, sizeof(old_volume_str), &old_volume, &s->channel_map,
|
||||
s->flags & PA_SINK_DECIBEL_VOLUME),
|
||||
pa_cvolume_snprint_verbose(new_volume_str, sizeof(new_volume_str), volume, &s->channel_map,
|
||||
s->flags & PA_SINK_DECIBEL_VOLUME));
|
||||
|
||||
pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue