From de13f30e286358d8e4f41e457421e4ec9776e3f5 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 18 Nov 2018 05:38:03 -0800 Subject: Improve audio underrun recordery in alffplay Now it has a better idea to skip samples during refill instead of after restarting. --- examples/alffplay.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'examples/alffplay.cpp') diff --git a/examples/alffplay.cpp b/examples/alffplay.cpp index 27520a6d..f02fb16b 100644 --- a/examples/alffplay.cpp +++ b/examples/alffplay.cpp @@ -992,6 +992,18 @@ int AudioState::handler() */ alSourceRewind(mSource); alSourcei(mSource, AL_BUFFER, 0); + if(alcGetInteger64vSOFT) + { + /* Also update the device start time with the current device + * clock, so the decoder knows we're running behind. + */ + int64_t devtime{}; + alcGetInteger64vSOFT(alcGetContextsDevice(alcGetCurrentContext()), + ALC_DEVICE_CLOCK_SOFT, 1, &devtime); + auto device_time = nanoseconds{devtime}; + + mDeviceStartTime = device_time - mCurrentPts; + } continue; } -- cgit v1.2.3