Convert some unwrap calls to errors.

This commit is contained in:
Nolan Darilek 2021-05-25 14:19:17 -05:00
parent 9018f3cf15
commit 76c7701e92

View File

@ -282,7 +282,7 @@ fn source_update(
source.play();
}
} else {
let mut source = context.new_static_source().unwrap();
if let Ok(mut source) = context.new_static_source() {
if let Some(buffer) = buffers.0.get(&sound.buffer.id) {
source.set_buffer(buffer.clone()).unwrap();
}
@ -301,6 +301,9 @@ fn source_update(
);
source.play();
sound.source = Some(Arc::new(Mutex::new(source)));
} else {
error!("Error creating source");
}
}
}
SoundState::Paused => {
@ -403,16 +406,17 @@ fn listener_update(
if let Some(transform) = transform {
let look = transform.local_x();
let up = transform.local_z();
context
.set_position([
if let Err(e) = context.set_position([
transform.translation.x,
transform.translation.y,
transform.translation.z,
])
.unwrap();
context
.set_orientation(([look.x, look.y, look.z], [up.x, up.y, up.z]))
.unwrap();
]) {
error!("Error setting listener position: {:?}", e);
}
if let Err(e) = context.set_orientation(([look.x, look.y, look.z], [up.x, up.y, up.z]))
{
error!("Error setting listener orientation: {:?}", e);
}
} else {
context.set_position([0., 0., 0.]).unwrap();
context