open_default_sink fails on macOS when the device's max buffer size is below ~50 ms (e.g. AirPods: 15..=960)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 82/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- macos, rust
- Área
- audio-video-rtc
Línea de trabajo
Comienza con DeviceSinkBuilder::from_device y DeviceSinkBuilder::open_default_sink y luego inspecciona cómo se gestionan el rango de búfer admitido del dispositivo y los metadatos de driver(). Reproduce el problema con una salida predeterminada de macOS cuyo tamaño máximo de búfer sea inferior al tamaño seleccionado, como el ejemplo de los AirPods. Done significa que los dispositivos restringidos se abren correctamente con un tamaño de búfer admitido y que la ruta de fallback puede reintentar dispositivos sin metadatos del driver.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Rust
- Estrellas
- 2.5k
- Forks
- 338
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de RustAudio/rodio
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 73/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 67/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 46/100
Todos los issues de RustAudio/rodio
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Choochmeque/tauri-plugin-webdriver#134 ·
Los mantenedores suelen responder en 17 días
-
bug(c-sdk): boxlite_box_exec does not check runtime liveness before dispatching streaming execAbiertobug rust SDK & CLI & REST API
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
boxlite-ai/boxlite#3292 ·
Los mantenedores suelen responder en 1 día
-
Android bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
anefzaoui/misterdownloadmanager#2516 ·
Los mantenedores suelen responder en 1 día
-
editor ui
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
state:triage tech-debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 89/100
agent8-cash/ethpayserver#731 ·
Los mantenedores suelen responder en 1 día