Skip to content

Commit

Permalink
fix(anni-playback): recreate CpalOutputStream on device change
Browse files Browse the repository at this point in the history
  • Loading branch information
snylonue authored and Yesterday17 committed Dec 20, 2023
1 parent 0e2646a commit b034251
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion anni-playback/src/decoder/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,12 @@ impl Decoder {
// and pause playback. Once the user is ready, they can start
// playback themselves.
InternalPlayerEvent::DeviceChanged => {
self.cpal_output = None;
self.controls.pause();
self.cpal_output = None;
self.cpal_output_stream = CpalOutputStream::new(
SignalSpec::new_with_layout(44100, Layout::Stereo),
self.controls.clone(),
)?;

// The device change will also affect the preloaded playback.
if self.preload_playback.is_some() {
Expand Down

0 comments on commit b034251

Please sign in to comment.