open_default_sink fails on macOS when the device's max buffer size is below ~50 ms (e.g. AirPods: 15..=960)
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- macos, rust
調査の方向性
DeviceSinkBuilder::from_device と DeviceSinkBuilder::open_default_sink から始め、デバイスがサポートするバッダー範囲と driver() のメタデータがどのように処理されるかを調べます。選択したサイズより最大バッファーサイズが小さい既定の macOS 出力で再現します。AirPods の例のように行います。完了は、制約のあるデバイスがサポートされているバッファーサイズで正常に開かれ、フォールバックパスがドライバーメタデータのないデバイスを再試行できることを意味します。
索引モデルが issue の本文から書いたものです。
説明
Summary
DeviceSinkBuilder::open_default_sink() fails on macOS when the default output device's supported buffer range doesn't include the ~50 ms size rodio picks, and the built-in fallback never tries another configuration on Core Audio.
BuildError(Error { kind: UnsupportedConfig, message: Some("Buffer size 2048 is not in the supported range 15..=960") })
Seen with rodio 0.23.0 (cpal 0.18) on macOS 27.2, with AirPods Pro 3 as the default output (48 kHz, buffer range 15..=960). The built-in speakers and wired headphones on the same Mac report 15..=4096 and open fine. The same code path is unchanged on master.
Cause
DeviceSinkBuilder::from_devicereplacesBufferSize::DefaultwithBufferSize::Fixed(nearest_multiple_of_two(sample_rate / 20)), which is 2048 frames at 48 kHz. It doesn't check the device'sSupportedBufferSize, so any device whose range tops out below that (here15..=960) is rejected by cpal.open_default_sink's fallback keeps only devices wheredescription().driver()isSomeand not"null". On Core Audiodriver()isNonefor every device, so the fallback list is always empty and the original error comes back.open_sink_or_fallback, which would have retried withwith_supported_config(and soBufferSize::Default), is never reached.
The newer speakers API already handles this: impl From<SupportedStreamConfig> for OutputConfig clamps the default buffer into min..=max. But speakers is behind experimental, and open_default_sink is still what the docs point to.
Reproduction
With a default output device whose supported buffer range has max < 2048 at 48 kHz:
use rodio::cpal::traits::{DeviceTrait, HostTrait};
fn main() {
let host = rodio::cpal::default_host();
let dev = host.default_output_device().unwrap();
println!("{:?}", dev.default_output_config().unwrap().buffer_size()); // Range { min: 15, max: 960 }
for d in host.output_devices().unwrap() {
println!("driver: {:?}", d.description().unwrap().driver()); // None for every device
}
rodio::DeviceSinkBuilder::open_default_sink().unwrap(); // BuildError(UnsupportedConfig ...)
}
Suggested fix
In from_device, clamp the target size into the device's supported range, as OutputConfig::from does:
let buffer = match default_config.buffer_size() {
cpal::SupportedBufferSize::Range { min, max } => safe_buffer_size.clamp(*min, *max),
cpal::SupportedBufferSize::Unknown => safe_buffer_size,
};
It may also be worth dropping the driver() filter, or letting devices with driver() == None through, so the fallback can work on macOS.
As a workaround, we now read the range ourselves and call DeviceSinkBuilder::from_device(dev)?.with_buffer_size(BufferSize::Fixed(clamped)).open_stream(). Downstream report: trypsynth/fedra#205.
- 主要言語
- Rust
- スター
- 2.5k
- フォーク
- 338
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
RustAudio/rodio のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 73/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 67/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 46/100
RustAudio/rodio の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
Choochmeque/tauri-plugin-webdriver#134 ·
メンテナーはふだん 17 日以内に返信
-
bug rust SDK & CLI & REST API
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
boxlite-ai/boxlite#3292 ·
メンテナーはふだん 1 日以内に返信
-
Android bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
anefzaoui/misterdownloadmanager#2516 ·
メンテナーはふだん 1 日以内に返信
-
editor ui
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
state:triage tech-debt
難易度 2/5 1〜3時間 初心者へのやさしさ 89/100
agent8-cash/ethpayserver#731 ·
メンテナーはふだん 1 日以内に返信