Browse and listen to thousands of radio stations across the globe right from your terminal ๐ŸŒŽ ๐Ÿ“ป ๐ŸŽตโœจ
radio rust tokio web-radio command-line-tool tui

app: App: run(): fix: receive from frame only if currently playing

Prior to this, once paused, would get stuck at receiving the frame
since the receiver sleeps when nothing is available, thus no events
are polled. By receiving only when playing, this eliminates the issue.

NOTE: cannot use `try_recv()` since it would lead to flickering when
this thread is running faster than the audio producing thread.

Changed files
+7 -4
src
+7 -4
src/app.rs
··· 301 301 let mut last_poll = Instant::now(); 302 302 303 303 loop { 304 - let audio_frame = self.frame_rx.recv().unwrap(); 305 - let channels = 306 - stream_to_matrix(audio_frame.data.iter().cloned(), audio_frame.channels, 1.); 304 + let channels = (!self.graph.pause) 305 + .then(|| self.frame_rx.recv().unwrap()) 306 + .map(|audio_frame| { 307 + stream_to_matrix(audio_frame.data.iter().cloned(), audio_frame.channels, 1.) 308 + }); 307 309 308 310 fps += 1; 309 311 ··· 321 323 datasets.append(&mut current_display.references(&graph)); 322 324 } 323 325 } 324 - if let Some(current_display) = self.current_display_mut() { 326 + if let Some((current_display, channels)) = self.current_display_mut().zip(channels) 327 + { 325 328 datasets.append(&mut current_display.process(&graph, &channels)); 326 329 } 327 330 terminal