File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ impl AppState {
6363 pub fn create_audio_stream (
6464 & mut self ,
6565 consumer : Consumer < u8 > ,
66+ auto_play : bool ,
6667 ) -> anyhow:: Result < AudioPacketFormat > {
6768 self . audio_stream = None ;
6869
@@ -81,8 +82,14 @@ impl AppState {
8182 let ( stream, final_audio_config) =
8283 player:: create_audio_stream ( device, wanted_audio_config, consumer) ?;
8384
84- if let Err ( e) = stream. pause ( ) {
85- error ! ( "{e}" ) ;
85+ if auto_play {
86+ if let Err ( e) = stream. play ( ) {
87+ error ! ( "{e}" ) ;
88+ }
89+ } else {
90+ if let Err ( e) = stream. pause ( ) {
91+ error ! ( "{e}" ) ;
92+ }
8693 }
8794
8895 self . audio_stream = Some ( Stream {
Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ impl AppState {
150150 let ( producer, consumer) = RingBuffer :: < u8 > :: new ( self . get_shared_buf_size ( ) ) ;
151151 let config = self . config . data ( ) . clone ( ) ;
152152
153- match self . create_audio_stream ( consumer) {
153+ match self . create_audio_stream ( consumer, true ) {
154154 Ok ( audio_config) => {
155155 self . send_command ( StreamerCommand :: ReconfigureStream {
156156 buff : producer,
@@ -188,7 +188,7 @@ impl AppState {
188188 let config = self . config . data ( ) . clone ( ) ;
189189 let ( producer, consumer) = RingBuffer :: < u8 > :: new ( self . get_shared_buf_size ( ) ) ;
190190
191- let audio_config = match self . create_audio_stream ( consumer) {
191+ let audio_config = match self . create_audio_stream ( consumer, false ) {
192192 Ok ( audio_config) => audio_config,
193193 Err ( e) => {
194194 error ! ( "failed to start audio stream: {e}" ) ;
You can’t perform that action at this time.
0 commit comments