Repository navigation
Report playback from the null and stdout sinks so the player releases chunks - #89
Merged
Merged
Conversation
… chunks A sink that never calls on_frames_played leaves the player's sync task in initial-sync priming: the codec header stays held, every chunk queues behind it in the inbound ring, the player's quota overflows and the library closes the connection, which the server then reopens in a loop (#82). The null and stdout sinks now report every write as played against a virtual clock that runs ahead of real time by the server's lead, so each chunk is released on arrival. The audio_sink.h note that said reporting was optional for instant sinks is corrected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The null and stdout sinks never reported playback, so the player's sync task stayed in initial-sync priming: the codec header stayed held, every chunk queued behind it in the inbound ring, the player's quota overflowed, the library closed the connection, and the server reopened it in a loop. Both sinks now report every write as played against a virtual clock, so each chunk is released as it arrives.
Fixes #82
What changes
NullAudioSink::write()reports the frames it consumed, in the discard, muted and stdout branches alike, with a finish timestamp on a playhead that is never behind real time:max(now, playhead) + frames / rate. The clock runs ahead of real time by whatever the server sends ahead, which is what lets the sync task release each chunk on arrival; it is the pattern the library's ownVirtualSinkListeneruses. A short stdout write reports what it consumed, so the sync task's frame accounting does not drift.audio_sink.hnote that said reporting was optional for instant sinks is corrected: a sink that never reports stalls the player before its first chunk.tests/null_sink_test.cpp: every write is reported with its frame count on a clock that keeps advancing; nothing is reported beforeconfigure(), for a zero-length write, or afterstop().Verification
Against Music Assistant 2.11.0.dev with a 44.1 kHz / 24-bit FLAC track, the same player identity on the same server,
-o null -d debug.mainbefore this change, three stream starts in a row:With this change, the player restarted on the same state directory while the server kept playing:
One stream start, no warning of any kind, 0.2% CPU over the following minute.
ctest521/521 apart fromConfigMerge.AConfiguredControlSocketIsAbsolutizedUnderDaemonize, which fails only from a 105-byte worktree socket path;scripts/format.sh --check,scripts/smoke_test.shand a-DSENDSPIN_CLI_WERROR=ONbuild are clean. Device-backed sinks already report and are unaffected.