Skip to content

Commit d4ef0ac

Browse files
committed
fix compile error
1 parent b317639 commit d4ef0ac

File tree

4 files changed

+90
-4
lines changed

4 files changed

+90
-4
lines changed

crates/audio/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl AudioInput {
182182
speaker: self.speaker.take().unwrap().stream().unwrap(),
183183
},
184184
AudioSource::RealtimeMixed => AudioStream::RealtimeMixed {
185-
mixed: self.mixed.take().unwrap().stream(),
185+
mixed: self.mixed.take().unwrap().stream().unwrap(),
186186
},
187187
AudioSource::Recorded => AudioStream::Recorded {
188188
data: self.data.as_ref().unwrap().clone(),

crates/audio/src/mixed/mod.rs

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,64 @@
1+
use anyhow::Result;
2+
use futures_util::{Stream, StreamExt};
3+
14
#[cfg(target_os = "macos")]
25
mod macos;
3-
46
#[cfg(target_os = "macos")]
5-
pub use macos::*;
7+
type PlatformMixedInput = macos::MixedInput;
8+
#[cfg(target_os = "macos")]
9+
type PlatformMixedStream = macos::MixedStream;
10+
11+
#[cfg(not(target_os = "macos"))]
12+
mod other;
13+
#[cfg(not(target_os = "macos"))]
14+
type PlatformMixedInput = other::MixedInput;
15+
#[cfg(not(target_os = "macos"))]
16+
type PlatformMixedStream = other::MixedStream;
17+
18+
pub struct MixedInput {
19+
inner: PlatformMixedInput,
20+
}
21+
22+
impl MixedInput {
23+
pub fn new() -> Result<Self> {
24+
let inner = PlatformMixedInput::new()?;
25+
Ok(Self { inner })
26+
}
27+
28+
pub fn stream(self) -> Result<MixedStream> {
29+
let inner = self.inner.stream();
30+
Ok(MixedStream { inner })
31+
}
32+
}
33+
34+
pub struct MixedStream {
35+
inner: PlatformMixedStream,
36+
}
37+
38+
impl Stream for MixedStream {
39+
type Item = f32;
40+
41+
fn poll_next(
42+
mut self: std::pin::Pin<&mut Self>,
43+
cx: &mut std::task::Context<'_>,
44+
) -> std::task::Poll<Option<Self::Item>> {
45+
self.inner.poll_next_unpin(cx)
46+
}
47+
}
48+
49+
impl kalosm_sound::AsyncSource for MixedStream {
50+
fn as_stream(&mut self) -> impl Stream<Item = f32> + '_ {
51+
self
52+
}
53+
54+
fn sample_rate(&self) -> u32 {
55+
#[cfg(target_os = "macos")]
56+
{
57+
self.inner.sample_rate()
58+
}
59+
#[cfg(not(target_os = "macos"))]
60+
{
61+
0
62+
}
63+
}
64+
}

crates/audio/src/mixed/other.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use anyhow::Result;
2+
use futures_util::Stream;
3+
4+
pub struct MixedInput {}
5+
6+
impl MixedInput {
7+
pub fn new() -> Result<Self> {
8+
Ok(Self {})
9+
}
10+
11+
pub fn stream(self) -> Result<MixedStream> {
12+
Ok(MixedStream {})
13+
}
14+
}
15+
16+
pub struct MixedStream {}
17+
18+
impl Stream for MixedStream {
19+
type Item = f32;
20+
21+
fn poll_next(
22+
mut self: std::pin::Pin<&mut Self>,
23+
cx: &mut std::task::Context<'_>,
24+
) -> Poll<Option<Self::Item>> {
25+
Poll::Pending
26+
}
27+
}

plugins/listener/src/actors/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl SessionSupervisor {
283283
if state.record_enabled {
284284
let app_dir = state.app.path().app_data_dir().unwrap();
285285
let (rec_ref, _) = Actor::spawn_linked(
286-
Some("recorder".to_string()),
286+
Some(Recorder::name()),
287287
Recorder,
288288
RecArgs {
289289
app_dir: app_dir.clone(),

0 commit comments

Comments
 (0)