Repository navigation
Audio output: rate matched FIFO reading with a reserve, whole blocks - #3215
Open
VasylSamoilov wants to merge 1 commit into
Open
VasylSamoilov wants to merge 1 commit into
VasylSamoilov wants to merge 1 commit into
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 105 |
| Duplication | 111 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Fixes f4exb#3214. Each FIFO feeding an output device is read through an asynchronous sample rate converter with adaptive ratio control: a polyphase fractional-delay FIR (Kaiser windowed sinc, 32 taps, 256 phases), the ratio from a least-squares line fit of frames received against time plus a proportional correction holding a 50 ms reserve, slew limited. A FIFO starts when it holds the reserve, the sink buffer and its largest arrival, or when a self-throttled producer has settled. The device offers the minimum available over the started FIFOs; a late FIFO is waited for, then stalled alone. The sink gets whole blocks or nothing and readyRead after starving; no zeros are made up. The FIFO list and the audio device manager maps are locked. A status line per device every 10 s: reserve, clock difference, stalls. Broadcast FM and radio paging demods write 20 ms blocks and apply the output rate report; the paging demod adds silence after the voice and the voice message player silence for the output's latency after the end, so the end is played before the output can stop; the paging mod starts live voice once 100 ms waits; the audio input device reports its rate.
VasylSamoilov
force-pushed
the
audio-output-fix-pr
branch
from
December 1, 2026 15:00
6adc8ce to
af74938
Compare
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.
Fixes #3214. Found while investigating #3182.
What the fix is
Each audio FIFO feeding an output device is read through an asynchronous sample rate converter with adaptive ratio control, one per FIFO:
Per channel:
Related: #3212 (timer paced devices, separate PR) fixes the file input running off its rate, which fed the FIFOs too fast or too slow.
Benefits for users
Evidence
Model: the reader and mixer simulated against the Qt5 and Qt6 sink behaviours, chunk sizes, clock offsets and pull jitter: 1045 of 1062 cases pass; the 17 failures are all a -7500 ppm, 480-frame chunk case that real devices do not produce.
Unit tests: radio paging TX stream 95/95, radio paging, message table 49/49.
This PR branch alone (without #3212), both Qt5 and Qt 6.11.3: Broadcast FM starts 8/8 without gaps, one channel running and one idle in both creation orders 0 gaps 0 stalls; here the file input runs about +8000 ppm off its rate (#3212) and the reader follows it with the reserve held.
With the audio device manager mutex, both Qt5 and Qt 6.11.3: Broadcast FM starts 8/8 without gaps (audio from 0.94-1.02 s), one channel running and one idle in both creation orders 0 gaps 0 stalls, 60 s steady 0 gaps 0 stalls, voice message player 5/5 complete (the last 160 ms were lost on Qt5 before the end padding followed the output's latency).
How tested
Next steps (not in this PR)