mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-06-12 03:01:58 -04:00
combine-stream: fix incorrect compensate samples on playback restart
update_delay is called primarily when the stream format or latency changes, and from playback thread, if stream reports different delay as before. This function calculates the number of compensate samples for each stream based on the latencies of other streams (which must be in a streaming state). During the first playback on a new format, update_delay is called multiple times due to format or latency changes. The delay is calculated only from streams that are currently streaming. If some streams are not yet streaming, their latencies are ignored, and the delay is updated later in the processing thread. The processing thread also stores the stream delay in a local variable (accessed only from that thread, thus requiring no locking). On a subsequent playback using the same format, update_delay is still called a few times, and the delay is updated based on the currently streaming streams. If some streams are not streaming, their latencies are ignored. However, this time, the processing thread fails to update the delay for the previously non-streaming streams. Because the format didn't change, the streams delay matches the last stored delay from the previous playback. As a result, the compensate samples are not recalculated. To properly update the compensate samples, update_delay must also be called when a stream's state changes to streaming (avoiding the need to clear the thread-buffered value, which would require locking in the processing thread).
This commit is contained in:
parent
32fe4dbda3
commit
fa9eb6320a
1 changed files with 1 additions and 0 deletions
|
|
@ -777,6 +777,7 @@ static void stream_state_changed(void *d, enum pw_stream_state old,
|
||||||
break;
|
break;
|
||||||
case PW_STREAM_STATE_STREAMING:
|
case PW_STREAM_STATE_STREAMING:
|
||||||
update_latency(s->impl);
|
update_latency(s->impl);
|
||||||
|
update_delay(s->impl);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue