diff --git a/src/bin/example.rs b/src/bin/example.rs index 371fa37..f2f763f 100644 --- a/src/bin/example.rs +++ b/src/bin/example.rs @@ -87,7 +87,9 @@ impl MyEmulator { let mut audio_spec = None; let audio_device = audio .open_playback(None, &desired_spec, |spec| { - println!("audio format {:?}", spec.format); + if spec.format != AudioFormat::S16LSB { + println!("unsupported audio format {:?}", spec.format); + } audio_spec = Some(spec.clone()); MySdlAudio { audio_spec: spec, @@ -254,13 +256,10 @@ impl AudioCallback for MySdlAudio { type Channel = i16; fn callback(&mut self, out: &mut [Self::Channel]) { - match self.audio_spec.format { - AudioFormat::S16LSB | AudioFormat::U16LSB => { - if let Ok(samples) = self.audio_receiver.recv() { - out.copy_from_slice(&samples[..out.len()]); - } + if self.audio_spec.format == AudioFormat::S16LSB { + if let Ok(samples) = self.audio_receiver.recv() { + out.copy_from_slice(&samples[..out.len()]); } - _ => {} } } }