sink-input: Limit rewinding to max_rewind for virtual sinks

This patch is in preparation of allowing virtual sinks to specify their own
max_rewind limit.
Currently, virtual sinks cannot specify their max_rewind limit, but just copy
the value from the master sink. This may not be correct, if the DSP code of the
virtual sink has limited (or no) rewinding capability.
Because the DSP code of the virtual sink is rewound in the process_rewind()
callback of the sink input, it must be ensured, that rewinding a sink input
to the master of a virtual sink is limited similar to rewinding a sink.
There are two remaining exceptions:

1) If an underrun is detected. In that case, the filter should be reset anyway.
2) When the sink input of the filter is moved and attached to the destination
sink.

The move case is handled without involvement of the implementer, so the implementer
can only receive a rewind larger than max_rewind when the filter should be reset
anyway.

All existing virtual sinks do not distinguish between reset and rewind of the
filter.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/120>
This commit is contained in:
Georg Chini 2021-01-01 00:31:32 +01:00 committed by PulseAudio Marge Bot
parent f121779f88
commit 5c6d91a97c
3 changed files with 50 additions and 5 deletions

View file

@ -470,6 +470,10 @@ int pa_sink_suspend_all(pa_core *c, bool suspend, pa_suspend_cause_t cause);
/* Use this instead of checking s->flags & PA_SINK_FLAT_VOLUME directly. */
bool pa_sink_flat_volume_enabled(pa_sink *s);
/* Check if the sink has a virtual sink attached.
* Called from the IO thread. */
bool pa_sink_has_filter_attached(pa_sink *s);
/* Get the master sink when sharing volumes */
pa_sink *pa_sink_get_master(pa_sink *s);