@@ -70,10 +70,16 @@ impl RealtimeSynthStatsReader {
7070 }
7171}
7272
73+ // A helper for making the stream be send/sync, allowing the entire synth to be passed between threads.
74+ // The stream is never actually accessed from multiple threads, it's only stored for ownership and then dropped.
75+ struct SendSyncStream ( Stream ) ;
76+ unsafe impl Sync for SendSyncStream { }
77+ unsafe impl Send for SendSyncStream { }
78+
7379struct RealtimeSynthThreadSharedData {
7480 buffered_renderer : Arc < Mutex < BufferedRenderer > > ,
7581
76- stream : Stream ,
82+ stream : SendSyncStream ,
7783
7884 event_senders : RealtimeEventSender ,
7985}
@@ -272,7 +278,7 @@ impl RealtimeSynth {
272278 buffered_renderer : buffered,
273279
274280 event_senders : RealtimeEventSender :: new ( senders, max_nps, config. ignore_range ) ,
275- stream,
281+ stream : SendSyncStream ( stream ) ,
276282 } ) ,
277283 join_handles : thread_handles,
278284
@@ -329,13 +335,13 @@ impl RealtimeSynth {
329335 /// Pauses the playback of the audio output device.
330336 pub fn pause ( & mut self ) -> Result < ( ) , PauseStreamError > {
331337 let data = self . data . as_mut ( ) . unwrap ( ) ;
332- data. stream . pause ( )
338+ data. stream . 0 . pause ( )
333339 }
334340
335341 /// Resumes the playback of the audio output device.
336342 pub fn resume ( & mut self ) -> Result < ( ) , PlayStreamError > {
337343 let data = self . data . as_mut ( ) . unwrap ( ) ;
338- data. stream . play ( )
344+ data. stream . 0 . play ( )
339345 }
340346
341347 /// Changes the length of the buffer reader.
0 commit comments