@@ -225,7 +225,7 @@ pub struct UserData<D> {
225225 format : AudioInfoRaw ,
226226 last_quantum : Arc < AtomicU64 > ,
227227 start : Instant ,
228- is_default_device : Arc < AtomicBool > ,
228+ is_default_device : bool ,
229229 has_connected : bool ,
230230 invalidated : Arc < AtomicBool > ,
231231 pending_device_changed : Arc < AtomicBool > ,
@@ -253,7 +253,7 @@ impl<D> UserData<D> {
253253 StreamState :: Unconnected => {
254254 // Let the metadata monitor fire for default-device streams
255255 if self . has_connected
256- && !self . is_default_device . load ( Ordering :: Relaxed )
256+ && !self . is_default_device
257257 && !self . invalidated . swap ( true , Ordering :: Relaxed )
258258 {
259259 emit_error (
@@ -376,7 +376,6 @@ pub struct StreamData<D> {
376376 pub error_callback : ErrorCallbackArc ,
377377 pub pending_device_changed : Arc < AtomicBool > ,
378378 pub invalidated : Arc < AtomicBool > ,
379- pub is_default_device : Arc < AtomicBool > ,
380379}
381380
382381/// Fallback timestamp using elapsed time since stream creation.
@@ -525,6 +524,7 @@ pub struct ConnectParams {
525524 pub last_quantum : Arc < AtomicU64 > ,
526525 pub start : Instant ,
527526 pub connect_automatically : bool ,
527+ pub is_default_device : bool ,
528528}
529529
530530pub fn connect_output < D , E > (
@@ -543,6 +543,7 @@ where
543543 last_quantum,
544544 start,
545545 connect_automatically,
546+ is_default_device,
546547 } = params;
547548
548549 let mainloop = MainLoopRc :: new ( None ) ?;
@@ -553,7 +554,6 @@ where
553554 let invalidated = Arc :: new ( AtomicBool :: new ( false ) ) ;
554555
555556 let pending_device_changed = Arc :: new ( AtomicBool :: new ( false ) ) ;
556- let is_default_device = Arc :: new ( AtomicBool :: new ( false ) ) ;
557557
558558 let core_monitor = {
559559 let invalidated_core = invalidated. clone ( ) ;
@@ -582,7 +582,7 @@ where
582582 last_quantum,
583583 start,
584584 invalidated : invalidated. clone ( ) ,
585- is_default_device : is_default_device . clone ( ) ,
585+ is_default_device,
586586 has_connected : false ,
587587 pending_device_changed : pending_device_changed. clone ( ) ,
588588 #[ cfg( feature = "realtime" ) ]
@@ -756,6 +756,9 @@ where
756756 if connect_automatically {
757757 flags |= StreamFlags :: AUTOCONNECT ;
758758 }
759+ if !is_default_device {
760+ flags |= StreamFlags :: DONT_RECONNECT ;
761+ }
759762
760763 stream. connect ( Direction :: Output , None , flags, & mut params) ?;
761764
@@ -769,7 +772,6 @@ where
769772 error_callback : error_callback_out,
770773 pending_device_changed,
771774 invalidated,
772- is_default_device,
773775 } )
774776}
775777
@@ -789,6 +791,7 @@ where
789791 last_quantum,
790792 start,
791793 connect_automatically,
794+ is_default_device,
792795 } = params;
793796
794797 let mainloop = MainLoopRc :: new ( None ) ?;
@@ -799,7 +802,6 @@ where
799802 let invalidated = Arc :: new ( AtomicBool :: new ( false ) ) ;
800803
801804 let pending_device_changed = Arc :: new ( AtomicBool :: new ( false ) ) ;
802- let is_default_device = Arc :: new ( AtomicBool :: new ( false ) ) ;
803805
804806 let core_monitor = {
805807 let invalidated_core = invalidated. clone ( ) ;
@@ -828,7 +830,7 @@ where
828830 last_quantum,
829831 start,
830832 invalidated : invalidated. clone ( ) ,
831- is_default_device : is_default_device . clone ( ) ,
833+ is_default_device,
832834 has_connected : false ,
833835 pending_device_changed : pending_device_changed. clone ( ) ,
834836 #[ cfg( feature = "realtime" ) ]
@@ -985,6 +987,9 @@ where
985987 if connect_automatically {
986988 flags |= StreamFlags :: AUTOCONNECT ;
987989 }
990+ if !is_default_device {
991+ flags |= StreamFlags :: DONT_RECONNECT ;
992+ }
988993
989994 stream. connect ( Direction :: Input , None , flags, & mut params) ?;
990995
@@ -998,6 +1003,5 @@ where
9981003 error_callback : error_callback_out,
9991004 pending_device_changed,
10001005 invalidated,
1001- is_default_device,
10021006 } )
10031007}
0 commit comments