AAudio: output `playback` timestamp seconds ahead after `pause()` then `play()`
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 54/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- android, rust
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Rust
- 星标
- 4k
- 派生
- 554
- 平均合并
- 1 天 3 小时
- 30 天内合并 PR
- 1
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
RustAudio/cpal 的其他 Issue
-
API design
难度 2/5 1-3 小时 新手友好度 64/100
-
correctness
难度 2/5 1-3 小时 新手友好度 66/100
-
aaudio: dynamic buffer tuning never grows the buffer (set_buffer_size_in_frames reports Err on success)可能已有人在做 @dannyward630 于 39 天前认领。 未关闭host - aaudio platform - android
难度 2/5 1-3 小时 新手友好度 79/100
-
WebAudio wasm build fails with wasm-bindgen panic=unwind closures可能已有人在做 @bogusyogi 于 48 天前认领。 未关闭host - webaudio platform - web
难度 2/5 1-3 小时 新手友好度 75/100
-
PipeWire: dropping callback captures on the realtime worker can terminate the process with SIGXCPU未关闭host - pipewire platform - linux
难度 4/5 3-5 天 新手友好度 45/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
laravel/rust-framework#864 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
eclipse-score/kyron#249 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 68/100
维护者通常 1 天内回复