formatting
This commit is contained in:
parent
7ee256e12e
commit
03950c8d3e
|
@ -296,16 +296,24 @@ pub struct Audio {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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 mut spec = None;
|
||||||
let sdl_audio_device = match sdl_audio_subsystem.open_playback(None, &desired_spec, |opened_spec| {
|
let sdl_audio_device =
|
||||||
let our_spec = AudioSpec::new(opened_spec.freq as u32, opened_spec.channels, opened_spec.format);
|
match sdl_audio_subsystem.open_playback(None, &desired_spec, |opened_spec| {
|
||||||
spec = Some(our_spec);
|
let our_spec = AudioSpec::new(
|
||||||
AudioDevice::new(our_spec)
|
opened_spec.freq as u32,
|
||||||
}) {
|
opened_spec.channels,
|
||||||
Ok(audio_device) => audio_device,
|
opened_spec.format,
|
||||||
Err(error) => return Err(AudioError::OpenDeviceFailed(error)),
|
);
|
||||||
};
|
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 {
|
if let Some(spec) = spec {
|
||||||
Ok(Audio {
|
Ok(Audio {
|
||||||
|
@ -313,7 +321,9 @@ impl Audio {
|
||||||
sdl_audio_device,
|
sdl_audio_device,
|
||||||
})
|
})
|
||||||
} else {
|
} 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