formatting
This commit is contained in:
parent
7ee256e12e
commit
03950c8d3e
|
@ -296,16 +296,24 @@ pub struct Audio {
|
|||
}
|
||||
|
||||
impl Audio {
|
||||
pub fn new(desired_spec: AudioSpecDesired, sdl_audio_subsystem: &AudioSubsystem) -> Result<Self, AudioError> {
|
||||
pub fn new(
|
||||
desired_spec: AudioSpecDesired,
|
||||
sdl_audio_subsystem: &AudioSubsystem,
|
||||
) -> Result<Self, AudioError> {
|
||||
let mut spec = None;
|
||||
let sdl_audio_device = match sdl_audio_subsystem.open_playback(None, &desired_spec, |opened_spec| {
|
||||
let our_spec = AudioSpec::new(opened_spec.freq as u32, opened_spec.channels, opened_spec.format);
|
||||
spec = Some(our_spec);
|
||||
AudioDevice::new(our_spec)
|
||||
}) {
|
||||
Ok(audio_device) => audio_device,
|
||||
Err(error) => return Err(AudioError::OpenDeviceFailed(error)),
|
||||
};
|
||||
let sdl_audio_device =
|
||||
match sdl_audio_subsystem.open_playback(None, &desired_spec, |opened_spec| {
|
||||
let our_spec = AudioSpec::new(
|
||||
opened_spec.freq as u32,
|
||||
opened_spec.channels,
|
||||
opened_spec.format,
|
||||
);
|
||||
spec = Some(our_spec);
|
||||
AudioDevice::new(our_spec)
|
||||
}) {
|
||||
Ok(audio_device) => audio_device,
|
||||
Err(error) => return Err(AudioError::OpenDeviceFailed(error)),
|
||||
};
|
||||
|
||||
if let Some(spec) = spec {
|
||||
Ok(Audio {
|
||||
|
@ -313,7 +321,9 @@ impl Audio {
|
|||
sdl_audio_device,
|
||||
})
|
||||
} else {
|
||||
Err(AudioError::OpenDeviceFailed(String::from("Device initialization failed to set AudioSpec")))
|
||||
Err(AudioError::OpenDeviceFailed(String::from(
|
||||
"Device initialization failed to set AudioSpec",
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue