Skip to content

Commit 28198e3

Browse files
committed
fix: add StreamTrait impl for all remaining backends
Add missing StreamTrait implementations for platform-specific backends that couldn't be tested on macOS: - aaudio (Android) - asio (Windows) - wasapi (Windows) - alsa (Linux) - null (WASI) Each implementation delegates play/pause to the inner UnsupportedDuplexStream.
1 parent 09c1b63 commit 28198e3

File tree

5 files changed

+50
-0
lines changed

5 files changed

+50
-0
lines changed

src/host/aaudio/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ pub struct Device(Option<AudioDeviceInfo>);
117117

118118
pub struct DuplexStream(pub crate::duplex::UnsupportedDuplexStream);
119119

120+
impl StreamTrait for DuplexStream {
121+
fn play(&self) -> Result<(), PlayStreamError> {
122+
StreamTrait::play(&self.0)
123+
}
124+
125+
fn pause(&self) -> Result<(), PauseStreamError> {
126+
StreamTrait::pause(&self.0)
127+
}
128+
}
129+
120130
/// Stream wraps AudioStream in Arc<Mutex<>> to provide Send + Sync semantics.
121131
///
122132
/// While the underlying ndk::audio::AudioStream is neither Send nor Sync in ndk 0.9.0

src/host/alsa/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ const LIBC_ENOTSUPP: libc::c_int = 524;
9090

9191
pub struct DuplexStream(pub crate::duplex::UnsupportedDuplexStream);
9292

93+
impl crate::traits::StreamTrait for DuplexStream {
94+
fn play(&self) -> Result<(), crate::PlayStreamError> {
95+
crate::traits::StreamTrait::play(&self.0)
96+
}
97+
98+
fn pause(&self) -> Result<(), crate::PauseStreamError> {
99+
crate::traits::StreamTrait::pause(&self.0)
100+
}
101+
}
102+
93103
/// The default Linux and BSD host type.
94104
#[derive(Debug, Clone)]
95105
pub struct Host {

src/host/asio/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ mod stream;
2323

2424
pub struct DuplexStream(pub crate::duplex::UnsupportedDuplexStream);
2525

26+
impl StreamTrait for DuplexStream {
27+
fn play(&self) -> Result<(), PlayStreamError> {
28+
StreamTrait::play(&self.0)
29+
}
30+
31+
fn pause(&self) -> Result<(), PauseStreamError> {
32+
StreamTrait::pause(&self.0)
33+
}
34+
}
35+
2636
/// Global ASIO instance shared across all Host instances.
2737
///
2838
/// ASIO only supports loading a single driver at a time globally, so all Host instances

src/host/null/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ crate::assert_stream_sync!(Stream);
2929

3030
pub struct DuplexStream(pub crate::duplex::UnsupportedDuplexStream);
3131

32+
impl StreamTrait for DuplexStream {
33+
fn play(&self) -> Result<(), PlayStreamError> {
34+
StreamTrait::play(&self.0)
35+
}
36+
37+
fn pause(&self) -> Result<(), PauseStreamError> {
38+
StreamTrait::pause(&self.0)
39+
}
40+
}
41+
3242
#[derive(Clone)]
3343
pub struct SupportedInputConfigs;
3444
#[derive(Clone)]

src/host/wasapi/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ use windows::Win32::Media::Audio;
1717

1818
pub struct DuplexStream(pub crate::duplex::UnsupportedDuplexStream);
1919

20+
impl StreamTrait for DuplexStream {
21+
fn play(&self) -> Result<(), crate::PlayStreamError> {
22+
StreamTrait::play(&self.0)
23+
}
24+
25+
fn pause(&self) -> Result<(), crate::PauseStreamError> {
26+
StreamTrait::pause(&self.0)
27+
}
28+
}
29+
2030
mod com;
2131
mod device;
2232
mod stream;

0 commit comments

Comments
 (0)