aaudio: dynamic buffer tuning never grows the buffer (set_buffer_size_in_frames reports Err on success)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 79/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- android, rust
調査の方向性
src/host/aaudio.rs の build_output_stream から始めて、xrun によって駆動されるバッファ調整の経路をたどってください。ndk 0.9.0 が set_buffer_size_in_frames の結果をどのように報告するか、また buffer_size_in_frames() の読み戻しによって要求したサイズを確認できるかを調べてください。リサイズに成功したときに mixer_bursts が進むよう成功判定を更新し、その後、アンダーラン後にチューナーがより小さいバッファを要求しなくなることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
On Android, the AAudio host's dynamic buffer tuning never grows the buffer. On a low-latency stream it can actually shrink the buffer after the first underrun.
Cause
build_output_stream in src/host/aaudio.rs turns tuning on when config.buffer_size == BufferSize::Default. On each xrun-count increase it runs:
if stream.set_buffer_size_in_frames(buffer_size).is_ok() {
tuning_for_callback.mixer_bursts.store(new_mixer_bursts, Ordering::Relaxed);
}
With ndk 0.9.0, set_buffer_size_in_frames returns Err(AudioError::__Unknown(new_size)) whenever the call succeeds (rust-mobile/ndk#520). So:
.is_ok()is always false, andmixer_burstsstays at its initial value.- If
aaudio.mixer_burstsis unset, cpal falls back to its default of2. - Every underrun therefore sets the buffer to
(2 + 1) × burst, never larger.
Observed
- Device: Samsung Galaxy A56, Android 16.
aaudio.mixer_burstsis unset, burst is 96 frames. - An AAudio
LowLatency/Sharedoutput stream on this device opens with a 768-frame buffer (8 bursts). - With the code above, the first underrun resizes it to 288 frames (3 bursts), which is a shrink.
- Later underruns set 288 again, so the tuner can never back off.
I confirmed the ndk return value directly on the device: set_buffer_size_in_frames(192) returns Err(__Unknown(192)), and buffer_size_in_frames() reads 192 afterwards. The cpal tuner path follows from the code; I didn't instrument it in cpal itself. This is in cpal 0.18.2 and still on master.
Suggested fix
Until ndk is fixed, treat a positive __Unknown value as success, or read the size back:
let _ = stream.set_buffer_size_in_frames(buffer_size);
if stream.buffer_size_in_frames() >= buffer_size {
tuning_for_callback.mixer_bursts.store(new_mixer_bursts, Ordering::Relaxed);
}
Reading back also handles AAudio rounding the requested size up.
- 主要言語
- Rust
- スター
- 4k
- フォーク
- 554
- 平均マージ
- 2日 11時間
- マージ済み PR(30日)
- 3
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
RustAudio/cpal のほかの issue
-
WebAudio wasm build fails with wasm-bindgen panic=unwind closures対応中かも @bogusyogi が 9 日前に担当しました。 オープンhost - webaudio platform - web
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
RustAudio/cpal#1394 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
host - pipewire platform - linux
難易度 4/5 1〜2日 初心者へのやさしさ 52/100
RustAudio/cpal#1405 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
WASAPI: default-device activation fails with RPC_E_CHANGED_MODE after endpoint-notification callbacks put thread-pool threads into an STA対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンcorrectness host - wasapi platform - windows
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
RustAudio/cpal#1402 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
coreaudio (macOS): capture/playback timestamps double-count the buffer, loopback reads as −2 buffers対応中かも @Marco-Farruggio が 12 日前に担当しました。 オープンcorrectness host - coreaudio platform - macos
難易度 4/5 3〜5日 初心者へのやさしさ 53/100
RustAudio/cpal#1398 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
ASIO: TimeBase treats small backward steps in systemTime as timeGetTime wraps, so stream instants race ahead and overflow after ~10 minutes対応中かも @chrischaps が 16 日前に担当しました。 オープンhost - asio platform - windows
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
RustAudio/cpal#1393 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
bug llm translation
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
accounts bug decoding
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
wboayue/rust-ibapi#1088 ·
メンテナーはふだん 1 日以内に返信
-
chmod -v: missing 'could not be accessed' line for operands that can't be stat'ed対応中かも @emirmrkaljevic が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
gtk-rs/gtk-rs-core#2068 ·
メンテナーはふだん 6 日以内に返信