AAudio: output `playback` timestamp seconds ahead after `pause()` then `play()`
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 54/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- android, rust
- Domain
- audio-video-rtc, backend
Research direction
Start by reading output_stream_instant and monotonic_output_callback in the AAudio output stream code, then trace how pause and play affect the frame position and frames written used for timestamp projection. Reproduce the reported sequence and check how invalid timestamps fall back. Done means playback timestamps after resuming stay near the callback time and latency remains reasonable without breaking normal output timestamps.
Written by the indexing model from the issue text.
Description
AAudio: output playback timestamp seconds ahead after pause() then play()
cpal 0.18.2, AAudio host, Android 16 (Pixel 11 Pro), output stream.
What happens
After an output stream is paused with StreamTrait::pause() and started
again with play(), OutputCallbackInfo::timestamp().playback lies seconds
in the future. The difference to callback (the output latency) was about
13.9 s in one run and 40 s in another, instead of about 13 ms. Because
monotonic_output_callback keeps playback from going back, the wrong value
then holds, and the latency only shrinks as time passes.
Why
output_stream_instant projects AAudioStream_getTimestamp's anchor (frame
position and time) to the callback's first frame using
AAudioStream_getFramesWritten. After the pause, the two no longer count
from the same origin: the frame position starts over lower, while the frames
written carry on. Readings we logged in the data callback:
| frame position | frames written | written − position | |
|---|---|---|---|
last callback before pause() |
734 832 | 738 240 | 3 408 (71 ms) |
first callback after play() |
getTimestamp failed |
738 432 | – |
| a few seconds later | 149 328 | 814 848 | 665 520 (13 865 ms) |
The first callback after play() falls back to now() (no latency), so the
next good reading is far ahead of it, and the monotonic hold keeps it.
Possible fixes
- Treat a projected
playbackfurther ahead than the stream's buffer
capacity as not valid (fall back as on a failedgetTimestamp), or - re-anchor after
play(): take the frames written at the first successful
timestamp after a start, or - document that a paused AAudio output stream gives wrong timestamps until
recreated.
We work around it by closing the stream instead of pausing it, and opening a
new one when the app comes back.
- Dominant language
- Rust
- Stars
- 4k
- Forks
- 554
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 1
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from RustAudio/cpal
-
API design
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
-
correctness
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
aaudio: dynamic buffer tuning never grows the buffer (set_buffer_size_in_frames reports Err on success)Possibly taken @dannyward630 claimed this 39 days ago. Openhost - aaudio platform - android
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
-
WebAudio wasm build fails with wasm-bindgen panic=unwind closuresPossibly taken @bogusyogi claimed this 48 days ago. Openhost - webaudio platform - web
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
PipeWire: dropping callback captures on the realtime worker can terminate the process with SIGXCPUOpenhost - pipewire platform - linux
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
ci: migrate pinned macos-15 runners to macos-26 and macos-26-intelPossibly taken @hawkingrei claimed this today. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
nowledge-co/hawdb#2224 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
eclipse-score/coverage_tool#95 ·
Maintainers usually reply within 2 days
-
bug nvim
Difficulty 2/5 1-3 hours Newbie friendliness 74/100