@@ -62,16 +62,16 @@ enum StreamState {
6262}
6363
6464impl StreamState {
65- fn load ( atom : & AtomicU8 ) -> Self {
66- match atom. load ( Ordering :: Acquire ) {
67- 1 => StreamState :: Paused ,
68- 2 => StreamState :: Playing ,
69- _ => StreamState :: Starting ,
65+ fn load ( atom : & AtomicU8 , order : Ordering ) -> Self {
66+ match atom. load ( order ) {
67+ 1 => Self :: Paused ,
68+ 2 => Self :: Playing ,
69+ _ => Self :: Starting ,
7070 }
7171 }
7272
73- fn store ( atom : & AtomicU8 , state : StreamState ) {
74- atom. store ( state as u8 , Ordering :: Release ) ;
73+ fn store ( self , atom : & AtomicU8 , order : Ordering ) {
74+ atom. store ( self as u8 , order ) ;
7575 }
7676}
7777
@@ -98,12 +98,12 @@ impl Stream {
9898 }
9999
100100 pub fn play ( & self ) -> Result < ( ) , Error > {
101- StreamState :: store ( & self . state , StreamState :: Playing ) ;
101+ StreamState :: Playing . store ( & self . state , Ordering :: Release ) ;
102102 Ok ( ( ) )
103103 }
104104
105105 pub fn pause ( & self ) -> Result < ( ) , Error > {
106- StreamState :: store ( & self . state , StreamState :: Paused ) ;
106+ StreamState :: Paused . store ( & self . state , Ordering :: Release ) ;
107107 Ok ( ( ) )
108108 }
109109
@@ -212,7 +212,7 @@ impl Device {
212212 // This is most performance critical part of the ASIO bindings.
213213 let callback_id = driver. add_callback ( move |callback_info| unsafe {
214214 // If not playing, return early.
215- if StreamState :: load ( & state_cb) != StreamState :: Playing {
215+ if StreamState :: load ( & state_cb, Ordering :: Acquire ) != StreamState :: Playing {
216216 return ;
217217 }
218218
@@ -443,7 +443,7 @@ impl Device {
443443 return Err ( build_stream_err ( e) ) ;
444444 }
445445
446- StreamState :: store ( & state, StreamState :: Paused ) ;
446+ StreamState :: Paused . store ( & state, Ordering :: Release ) ;
447447 Ok ( Stream {
448448 state,
449449 driver,
@@ -544,7 +544,7 @@ impl Device {
544544
545545 let callback_id = driver. add_callback ( move |callback_info| unsafe {
546546 // If not playing, return early.
547- if StreamState :: load ( & state_cb) != StreamState :: Playing {
547+ if StreamState :: load ( & state_cb, Ordering :: Acquire ) != StreamState :: Playing {
548548 return ;
549549 }
550550
@@ -826,7 +826,7 @@ impl Device {
826826 return Err ( build_stream_err ( e) ) ;
827827 }
828828
829- StreamState :: store ( & state, StreamState :: Paused ) ;
829+ StreamState :: Paused . store ( & state, Ordering :: Release ) ;
830830 Ok ( Stream {
831831 state,
832832 driver,
@@ -1002,7 +1002,7 @@ impl Device {
10021002 sys:: AsioMessageSelectors :: kAsioResetRequest => {
10031003 // Guard on Starting: some USB ASIO drivers (ASIO4ALL, Focusrite, etc.)
10041004 // fire spurious reset/resync requests during driver.start().
1005- if StreamState :: load ( & state) != StreamState :: Starting {
1005+ if StreamState :: load ( & state, Ordering :: Acquire ) != StreamState :: Starting {
10061006 let _ = timer_tx. send ( Error :: with_message (
10071007 ErrorKind :: StreamInvalidated ,
10081008 "Stream reset was requested by the ASIO driver" ,
@@ -1014,7 +1014,7 @@ impl Device {
10141014 // Per the ASIO spec (and matching JUCE's behavior), kAsioResyncRequest
10151015 // means the driver needs a full stop/reinit/start. It is *not* a simple
10161016 // xrun notification.
1017- if StreamState :: load ( & state) != StreamState :: Starting {
1017+ if StreamState :: load ( & state, Ordering :: Acquire ) != StreamState :: Starting {
10181018 let _ = timer_tx. send ( Error :: with_message (
10191019 ErrorKind :: StreamInvalidated ,
10201020 "Stream resynchronization was requested by the ASIO driver" ,
@@ -1023,7 +1023,7 @@ impl Device {
10231023 true
10241024 }
10251025 sys:: AsioMessageSelectors :: kAsioOverload => {
1026- if StreamState :: load ( & state) == StreamState :: Playing {
1026+ if StreamState :: load ( & state, Ordering :: Acquire ) == StreamState :: Playing {
10271027 let _ =
10281028 try_emit_error ( & error_callback_shared, Error :: new ( ErrorKind :: Xrun ) ) ;
10291029 }
@@ -1066,7 +1066,9 @@ impl Device {
10661066 true
10671067 }
10681068 } ;
1069- if should_notify && StreamState :: load ( & state) != StreamState :: Starting {
1069+ if should_notify
1070+ && StreamState :: load ( & state, Ordering :: Acquire ) != StreamState :: Starting
1071+ {
10701072 let _ = timer_tx. send ( Error :: with_message (
10711073 ErrorKind :: StreamInvalidated ,
10721074 format ! ( "Sample rate changed to {new_rate} Hz by the ASIO driver" ) ,
0 commit comments