core: adjust playing_for and underrun_for at rewind
authorUoti Urpala <uau@glyph.nonexistent.invalid>
Sat, 28 Jul 2012 20:51:46 +0000 (23:51 +0300)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Wed, 31 Oct 2012 09:57:15 +0000 (15:27 +0530)
commit5bc6cadcb2e7255fd333ed88cc80b61a7673ddd9
treeda8c606280252c98ad1df68211b12f3065f854f6
parent94039790f8cd05542a6651f924fa1818ea1af605
core: adjust playing_for and underrun_for at rewind

A rewind may erase data that sink_input counted in playing_for or
underrun_for earlier. Add code adjusting those values after a rewind.

One visible symptom of this bug was problems recovering from an
underrun. When a client calls pa_stream_write() with a large block of
memory, the function can split that into smaller pieces before sending
it to the server. When receiving new data for a stream that had
silence queued due to underrun, the server would do a rewind to
replace the queued-but-not-played silence with the new data. Because
of the bug, this rewind itself would not change underrun_for. It's
possible for multiple rewinds to be done without filling the sink
buffer in between (which is what would eventually reset underrun_for).
In this case, the server rapidly processing the split packets would
rewind the stream for _each_ of them (as underrun_for would stay set),
erasing valid audio as a result.
src/pulsecore/sink-input.c