Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

aaudio: dynamic buffer tuning never grows the buffer (set_buffer_size_in_frames reports Err on success)

オープン 初心者向け
#1,414 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@dannyward630 がすでに取り組んでいます。

2026年10月25日 から。

  • #1415 @dannyward630 による — オープン

評価

難易度
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 の本文から書いたものです。

説明

host - aaudio platform - android

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, and mixer_bursts stays at its initial value.
  • If aaudio.mixer_bursts is unset, cpal falls back to its default of 2.
  • Every underrun therefore sets the buffer to (2 + 1) × burst, never larger.

Observed

  • Device: Samsung Galaxy A56, Android 16. aaudio.mixer_bursts is unset, burst is 96 frames.
  • An AAudio LowLatency/Shared output 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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

RustAudio/cpal のほかの issue

RustAudio/cpal の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。