OutputStream: expose the underlying cpal::Stream or provide wrapper for pause()/play()
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- rust
- Ambito
- audio-video-rtc, backend
Direzione di ricerca
The issue points to src/stream.rs and proposes exposing the underlying cpal::Stream or adding pause() and play() methods on OutputStream. Start by reading the OutputStream definition and its stream initialization code, then check how the project exposes playback controls. Done means choosing and implementing a consistent pause/resume API that reduces CPU use while output is silent, with tests covering the public API.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hello,
thanks for rodio!
I've been playing with rodio in https://github.com/martinetd/fuurin and one thing that's been annoying me is that even with all sources paused, just having an OutputStream present consumes a non-negligible amount of CPU sending silence to alsa.
(for what it's worth I tried the pipewire output provided in https://github.com/RustAudio/cpal/pull/938 and it's very slightly better, but sensibly the same)
With the current code, I see no other way around dropping the whole output stream which means dropping all the sinks I've opened first then the mixer and the stream itself, but I tried just exposing the _stream and using outputstream.stream().pause() and it reduces cpu to zero, so I think it's a much better approach to this problem.
Would you accept a patch such as this?
diff --git a/src/stream.rs b/src/stream.rs
index f6c8bcf550c0..2df5d7307b49 100644
--- a/src/stream.rs
+++ b/src/stream.rs
@@ -44,7 +44,7 @@ pub struct OutputStream {
config: OutputStreamConfig,
mixer: Mixer,
log_on_drop: bool,
- _stream: cpal::Stream,
+ stream: cpal::Stream,
}
impl OutputStream {
@@ -53,6 +53,11 @@ pub fn mixer(&self) -> &Mixer {
&self.mixer
}
+ /// Access the output stream's underlying cpal Stream.
+ pub fn stream(&self) -> &cpal::Stream {
+ &self.stream
+ }
+
/// Access the output stream's config.
pub fn config(&self) -> &OutputStreamConfig {
&self.config
@@ -487,7 +492,7 @@ fn open<E>(
Self::init_stream(device, config, source, error_callback).and_then(|stream| {
stream.play().map_err(StreamError::PlayStreamError)?;
Ok(Self {
- _stream: stream,
+ stream: stream,
mixer: controller,
config: *config,
log_on_drop: true,
Or would it be better to expose pause() and play() method directly that'd just call self.stream.pause()/play() ?
I think allowing access to the stream is more flexible ultimately, but happy either way.
I'll open a PR once there's an agreement on which is better :)
Thanks!
- Lingua principale
- Rust
- Stelle
- 2.5k
- Fork
- 338
- Merge medio
- 1g 3h
- PR unite (30g)
- 1
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di RustAudio/rodio
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 73/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
-
WavDecoder::size_hint underflows (u32 wrap, ~4.29e9) after EOF, causes multi-GB Vec::collect() allocationForse già presa @marin-m l’ha presa 2 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
Tutte le issue di RustAudio/rodio
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
plrigaux/sysd-manager#85 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
dsx-ai-factory/infra-controller#8341 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement triage:deciding
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
open-telemetry/otel-arrow#4540 ·
I maintainer di solito rispondono entro 2 giorni
-
benchmark: CSV report files contain blank records on WindowsForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertacomponent:benchmark
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
agentic-os-org/ANOLISA#9177 ·
I maintainer di solito rispondono entro 1 giorno
-
area/mcp area/modeling effort/s impact/few priority/p3 severity/low triaged type/bug urgency/this-quarter
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
cristim/AztecCraft#336 ·
I maintainer di solito rispondono entro 1 giorno