@@ -60,6 +60,10 @@ impl Stream {
6060 . set_write_callback ( Some ( callback) ) ;
6161 }
6262
63+ fn unset_write_callback ( & mut self ) {
64+ ( * self . inner ) . borrow_mut ( ) . set_write_callback ( None ) ;
65+ }
66+
6367 fn set_underflow_callback ( & mut self , callback : Option < Box < dyn FnMut ( ) + ' static > > ) {
6468 ( * self . inner ) . borrow_mut ( ) . set_underflow_callback ( callback)
6569 }
@@ -411,7 +415,6 @@ impl AudioOutput for PulseAudioOutput {
411415 self . enqueue ( stream, stream_params. autostart , stream_in. clone ( ) ) ;
412416 }
413417
414-
415418 fn unpause ( & mut self ) -> bool {
416419 if let Some ( ref mut stream) = self . playing {
417420 ( * self . mainloop ) . borrow_mut ( ) . lock ( ) ;
@@ -437,6 +440,7 @@ impl AudioOutput for PulseAudioOutput {
437440 fn stop ( & mut self ) {
438441 if let Some ( ref mut stream) = self . playing {
439442 ( * self . mainloop ) . borrow_mut ( ) . lock ( ) ;
443+ stream. unset_write_callback ( ) ;
440444 stream. disconnect ( ) . ok ( ) ;
441445 ( * self . mainloop ) . borrow_mut ( ) . unlock ( ) ;
442446 }
@@ -449,18 +453,7 @@ impl AudioOutput for PulseAudioOutput {
449453 }
450454
451455 fn shift ( & mut self ) {
452- let old_stream = self . playing . take ( ) ;
453456 self . playing = self . next_up . take ( ) ;
454-
455- if let Some ( old_stream) = old_stream {
456- if let Some ( pa_stream) = Rc :: into_inner ( old_stream. into_inner ( ) ) {
457- let mut pa_stream = pa_stream. into_inner ( ) ;
458- std:: thread:: spawn ( move || {
459- std:: thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
460- pa_stream. disconnect ( ) . ok ( ) ;
461- } ) ;
462- } ;
463- }
464457 }
465458
466459 fn get_dur ( & self ) -> Duration {
0 commit comments