OutputStream: expose the underlying cpal::Stream or provide wrapper for pause()/play()
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- rust
- Lĩnh vực
- audio-video-rtc, backend
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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!
- Ngôn ngữ chính
- Rust
- Star
- 2.5k
- Fork
- 338
- Merge trung bình
- 1 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của RustAudio/rodio
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 73/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
-
WavDecoder::size_hint underflows (u32 wrap, ~4.29e9) after EOF, causes multi-GB Vec::collect() allocationCó thể đã có người làm @marin-m đã nhận 2 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Tất cả issue của RustAudio/rodio
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
dsx-ai-factory/infra-controller#8341 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement triage:deciding
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
open-telemetry/otel-arrow#4540 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
benchmark: CSV report files contain blank records on WindowsCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởcomponent:benchmark
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
agentic-os-org/ANOLISA#9177 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
oracle/rust-oracledb#61 ·
-
bug priority-medium to-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày