sink-input: Change move logic

The introduction of the history queue makes it possible to implement moving
of streams without involving the implementer. Instead of dropping all data
from the render memblockq and requesting the implementer to rewrite the
data, the render memblockq is now reconstructed from the history queue.

Additionally, the render queue will be filled with silence matching the
amount of audio that is left playing on the old sink to avoid playing
the same audio twice.

This patch slightly breaks moving for virtual sinks because they do not
yet include the resampler delay in their latency reports. This will be
fixed in a different patch set.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/120>
This commit is contained in:
Georg Chini 2021-01-01 00:25:31 +01:00 committed by PulseAudio Marge Bot
parent da539ed336
commit a275a0b811
4 changed files with 176 additions and 55 deletions

View file

@ -299,6 +299,9 @@ struct pa_sink {
size_t rewind_nbytes;
bool rewind_requested;
/* Size of last rewind */
size_t last_rewind_nbytes;
/* Both dynamic and fixed latencies will be clamped to this
* range. */
pa_usec_t min_latency; /* we won't go below this latency */
@ -359,6 +362,7 @@ typedef enum pa_sink_message {
PA_SINK_MESSAGE_SET_MAX_REQUEST,
PA_SINK_MESSAGE_UPDATE_VOLUME_AND_MUTE,
PA_SINK_MESSAGE_SET_PORT_LATENCY_OFFSET,
PA_SINK_MESSAGE_GET_LAST_REWIND,
PA_SINK_MESSAGE_MAX
} pa_sink_message_t;
@ -456,6 +460,7 @@ void pa_sink_get_latency_range(pa_sink *s, pa_usec_t *min_latency, pa_usec_t *ma
pa_usec_t pa_sink_get_fixed_latency(pa_sink *s);
size_t pa_sink_get_max_rewind(pa_sink *s);
size_t pa_sink_get_last_rewind(pa_sink *s);
size_t pa_sink_get_max_request(pa_sink *s);
int pa_sink_update_status(pa_sink*s);