mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-25 08:22:36 +00:00
[client] audio: recover physical underrun debt
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled
A stable clock model can request a negative recovery slew while the unbounded ring is physically underrun. This leaves the reader ahead of the writer indefinitely and outputs silence until playback is restarted. Floor active recovery at the physical low-water requirement. Rebase the device-clock phase by any extra refill so modeled latency remains at the target without restarting the underrun correction cycle. Add a deterministic regression for negative physical debt opposing the stable clock model.
This commit is contained in:
@@ -2609,12 +2609,37 @@ static PlaybackDataResult playbackData(const void * data, size_t frameCount,
|
||||
sourceData->deviceClockStable)
|
||||
{
|
||||
devPosition = computeDevicePosition(curTime);
|
||||
const double slew = devPosition + targetBufferFrames - curPosition;
|
||||
const bool activeUnderrun =
|
||||
bufferUnderrun && state == STREAM_STATE_RUN;
|
||||
const double clockSlew =
|
||||
devPosition + targetBufferFrames - curPosition;
|
||||
double slew = clockSlew;
|
||||
if (activeUnderrun)
|
||||
{
|
||||
const int occupancy = ringbuffer_getCount(audio.playback.buffer);
|
||||
const double physicalSlew =
|
||||
ceil(targetLowWaterFrames - occupancy);
|
||||
if (physicalSlew > slew)
|
||||
slew = physicalSlew;
|
||||
}
|
||||
|
||||
const int slewFrames = clamp(llrint(slew), (int64_t)INT_MIN,
|
||||
(int64_t)INT_MAX);
|
||||
const int actualSlew = playbackSlewBuffer(sourceData, slewFrames);
|
||||
|
||||
/* A negative unbounded ring must be restored in the physical domain even
|
||||
* when the fitted clock asks for a smaller correction. Move the clock's
|
||||
* phase translation by the excess so the forced refill neither appears as
|
||||
* additional latency nor restarts the underrun/slew cycle. */
|
||||
const double correction = actualSlew - clockSlew;
|
||||
if (activeUnderrun && correction > 0.0)
|
||||
{
|
||||
sourceData->devicePositionOffsetFrames += correction;
|
||||
devPosition += correction;
|
||||
}
|
||||
|
||||
sourceData->outputPosition += actualSlew;
|
||||
curPosition += actualSlew;
|
||||
curPosition += actualSlew;
|
||||
|
||||
playbackResetRateControl(sourceData, providerRateControl);
|
||||
if (state == STREAM_STATE_KEEP_ALIVE ||
|
||||
|
||||
Reference in New Issue
Block a user