mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
source-output: Ensure no volumes are applied for passthrough streams
This forces passthrough source-outputs and their corresponding sources to 0dB gain so that the data is sent unaltered to the receiver.
This commit is contained in:
parent
0dea35a818
commit
f0be9c4004
3 changed files with 49 additions and 6 deletions
|
|
@ -978,6 +978,27 @@ pa_bool_t pa_source_is_passthrough(pa_source *s) {
|
|||
return (s->monitor_of && pa_sink_is_passthrough(s->monitor_of));
|
||||
}
|
||||
|
||||
/* Called from main context */
|
||||
void pa_source_enter_passthrough(pa_source *s) {
|
||||
pa_cvolume volume;
|
||||
|
||||
/* set the volume to NORM */
|
||||
s->saved_volume = *pa_source_get_volume(s, TRUE);
|
||||
s->saved_save_volume = s->save_volume;
|
||||
|
||||
pa_cvolume_set(&volume, s->sample_spec.channels, PA_VOLUME_NORM);
|
||||
pa_source_set_volume(s, &volume, TRUE, FALSE);
|
||||
}
|
||||
|
||||
/* Called from main context */
|
||||
void pa_source_leave_passthrough(pa_source *s) {
|
||||
/* Restore source volume to what it was before we entered passthrough mode */
|
||||
pa_source_set_volume(s, &s->saved_volume, TRUE, s->saved_save_volume);
|
||||
|
||||
pa_cvolume_init(&s->saved_volume);
|
||||
s->saved_save_volume = FALSE;
|
||||
}
|
||||
|
||||
/* Called from main context. */
|
||||
static void compute_reference_ratio(pa_source_output *o) {
|
||||
unsigned c = 0;
|
||||
|
|
@ -1368,9 +1389,9 @@ void pa_source_set_volume(
|
|||
pa_assert(volume || pa_source_flat_volume_enabled(s));
|
||||
pa_assert(!volume || volume->channels == 1 || pa_cvolume_compatible(volume, &s->sample_spec));
|
||||
|
||||
/* make sure we don't change the volume when a PASSTHROUGH output is connected */
|
||||
if (pa_source_is_passthrough(s)) {
|
||||
/* FIXME: Need to notify client that volume control is disabled */
|
||||
/* make sure we don't change the volume in PASSTHROUGH mode ...
|
||||
* ... *except* if we're being invoked to reset the volume to ensure 0 dB gain */
|
||||
if (pa_source_is_passthrough(s) && (!volume || !pa_cvolume_is_norm(volume))) {
|
||||
pa_log_warn("Cannot change volume, Source is monitor of a PASSTHROUGH sink");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue