Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force cpal Stream to implement Send+Sync #107

Merged
merged 3 commits into from
Oct 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions realtime/src/realtime_synth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ impl RealtimeSynthStatsReader {
}
}

MyBlackMIDIScore marked this conversation as resolved.
Show resolved Hide resolved
struct SendSyncStream(Stream);
unsafe impl Sync for SendSyncStream {}
unsafe impl Send for SendSyncStream {}

struct RealtimeSynthThreadSharedData {
buffered_renderer: Arc<Mutex<BufferedRenderer>>,

stream: Stream,
stream: SendSyncStream,

event_senders: RealtimeEventSender,
}
Expand Down Expand Up @@ -272,7 +276,7 @@ impl RealtimeSynth {
buffered_renderer: buffered,

event_senders: RealtimeEventSender::new(senders, max_nps, config.ignore_range),
stream,
stream: SendSyncStream(stream),
}),
join_handles: thread_handles,

Expand Down Expand Up @@ -329,13 +333,13 @@ impl RealtimeSynth {
/// Pauses the playback of the audio output device.
pub fn pause(&mut self) -> Result<(), PauseStreamError> {
let data = self.data.as_mut().unwrap();
data.stream.pause()
data.stream.0.pause()
}

/// Resumes the playback of the audio output device.
pub fn resume(&mut self) -> Result<(), PlayStreamError> {
let data = self.data.as_mut().unwrap();
data.stream.play()
data.stream.0.play()
}

/// Changes the length of the buffer reader.
Expand Down
Loading