`Mix` implements ExactSizeIterator but `len()` panics
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- rust
- Área
- audio-video-rtc
Línea de trabajo
Start with src/source/mix.rs and inspect how Mix implements ExactSizeIterator and size_hint(), then read the uniform format converters in src/source/uniform.rs. The report identifies two possible fixes but asks maintainers which they prefer, so first seek a decision on the contract before estimating completion; done means len() no longer panics for the reported inputs and the chosen behavior is covered.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Mix implements ExactSizeIterator, but its size_hint() can't always give an exact upper bound, so the default len() panics. Two same-format buffers are enough:
use rodio::{buffer::SamplesBuffer, nz, Source};
let mix = SamplesBuffer::new(nz!(1), nz!(1), [0.25])
.mix(SamplesBuffer::new(nz!(1), nz!(1), [0.25, 0.5]));
assert_eq!(mix.clone().count(), 2);
let _ = mix.len(); // panics: upper bound of size_hint() is None
The inputs go through the uniform format converters (src/source/uniform.rs), whose upper bound is None here, and ExactSizeIterator::len asserts upper == Some(lower). On master (685e057) this panics in both debug and release.
Two ways I can see to fix it, and I'd like to know which you prefer before opening a PR:
- Remove the
ExactSizeIteratorimpl forMix(src/source/mix.rs). Simple, but it is a breaking change for anyone callinglen(). - Keep the impl and make
size_hint()exact when it can be: both inputs report exact lengths and need no resampling (same rate), so the output length is just the longer input converted to the shared channel count. That keepslen()working for the common case, but the impl would still panic for inputs that need resampling, so it may only move the problem.
I lean towards 1, since an ExactSizeIterator that panics for some inputs breaks its contract. Noticed while reviewing the stream adapters around #915.
- 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
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
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 67/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 46/100
Todos los issues de RustAudio/rodio
Issues similares
-
bug nvim
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
-
chip:esp32c6 peripheral:dma
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
esp-rs/esp-hal#7037 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
BrettMayson/HEMTT#1445 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
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