sink-input, source-output: Assign to reference_ratio from a single place

This makes it easy to log a message every time the reference ratio
changes. I also need to add a hook for reference ratio changes, but
that need will go away if the stream relative volume controls will be
created by the core in the future.
This commit is contained in:
Tanu Kaskinen 2014-08-04 21:12:53 +03:00
parent 8a4a4f408c
commit f480fb38a7
6 changed files with 77 additions and 11 deletions

View file

@ -1313,7 +1313,7 @@ static void update_volume_due_to_moving(pa_source_output *o, pa_source *dest) {
pa_cvolume_reset(&new_volume, o->volume.channels);
pa_source_output_set_volume_direct(o, &new_volume);
pa_cvolume_reset(&o->reference_ratio, o->reference_ratio.channels);
pa_source_output_set_reference_ratio(o, &new_volume);
pa_assert(pa_cvolume_is_norm(&o->real_ratio));
pa_assert(pa_cvolume_equal(&o->soft_volume, &o->volume_factor));
}
@ -1695,3 +1695,27 @@ void pa_source_output_set_volume_direct(pa_source_output *o, const pa_cvolume *v
pa_subscription_post(o->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_CHANGE, o->index);
pa_hook_fire(&o->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_VOLUME_CHANGED], o);
}
/* Called from the main thread. */
void pa_source_output_set_reference_ratio(pa_source_output *o, const pa_cvolume *ratio) {
pa_cvolume old_ratio;
char old_ratio_str[PA_CVOLUME_SNPRINT_VERBOSE_MAX];
char new_ratio_str[PA_CVOLUME_SNPRINT_VERBOSE_MAX];
pa_assert(o);
pa_assert(ratio);
old_ratio = o->reference_ratio;
if (pa_cvolume_equal(ratio, &old_ratio))
return;
o->reference_ratio = *ratio;
if (!PA_SOURCE_OUTPUT_IS_LINKED(o->state))
return;
pa_log_debug("Source output %u reference ratio changed from %s to %s.", o->index,
pa_cvolume_snprint_verbose(old_ratio_str, sizeof(old_ratio_str), &old_ratio, &o->channel_map, true),
pa_cvolume_snprint_verbose(new_ratio_str, sizeof(new_ratio_str), ratio, &o->channel_map, true));
}