mirror of
https://github.com/lightsoutgames/bevy_openal.git
synced 2024-11-21 17:05:55 +00:00
Convert some unwrap
calls to errors.
This commit is contained in:
parent
9018f3cf15
commit
76c7701e92
60
src/lib.rs
60
src/lib.rs
|
@ -282,25 +282,28 @@ fn source_update(
|
||||||
source.play();
|
source.play();
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
if let Some(buffer) = buffers.0.get(&sound.buffer.id) {
|
||||||
source.set_buffer(buffer.clone()).unwrap();
|
source.set_buffer(buffer.clone()).unwrap();
|
||||||
|
}
|
||||||
|
sync_source_and_components(
|
||||||
|
&mut source,
|
||||||
|
transform,
|
||||||
|
global_transform,
|
||||||
|
gain,
|
||||||
|
pitch,
|
||||||
|
looping,
|
||||||
|
reference_distance,
|
||||||
|
max_distance,
|
||||||
|
rolloff_factor,
|
||||||
|
bypass_global_effects,
|
||||||
|
&mut **global_effects,
|
||||||
|
);
|
||||||
|
source.play();
|
||||||
|
sound.source = Some(Arc::new(Mutex::new(source)));
|
||||||
|
} else {
|
||||||
|
error!("Error creating source");
|
||||||
}
|
}
|
||||||
sync_source_and_components(
|
|
||||||
&mut source,
|
|
||||||
transform,
|
|
||||||
global_transform,
|
|
||||||
gain,
|
|
||||||
pitch,
|
|
||||||
looping,
|
|
||||||
reference_distance,
|
|
||||||
max_distance,
|
|
||||||
rolloff_factor,
|
|
||||||
bypass_global_effects,
|
|
||||||
&mut **global_effects,
|
|
||||||
);
|
|
||||||
source.play();
|
|
||||||
sound.source = Some(Arc::new(Mutex::new(source)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SoundState::Paused => {
|
SoundState::Paused => {
|
||||||
|
@ -403,16 +406,17 @@ fn listener_update(
|
||||||
if let Some(transform) = transform {
|
if let Some(transform) = transform {
|
||||||
let look = transform.local_x();
|
let look = transform.local_x();
|
||||||
let up = transform.local_z();
|
let up = transform.local_z();
|
||||||
context
|
if let Err(e) = context.set_position([
|
||||||
.set_position([
|
transform.translation.x,
|
||||||
transform.translation.x,
|
transform.translation.y,
|
||||||
transform.translation.y,
|
transform.translation.z,
|
||||||
transform.translation.z,
|
]) {
|
||||||
])
|
error!("Error setting listener position: {:?}", e);
|
||||||
.unwrap();
|
}
|
||||||
context
|
if let Err(e) = context.set_orientation(([look.x, look.y, look.z], [up.x, up.y, up.z]))
|
||||||
.set_orientation(([look.x, look.y, look.z], [up.x, up.y, up.z]))
|
{
|
||||||
.unwrap();
|
error!("Error setting listener orientation: {:?}", e);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
context.set_position([0., 0., 0.]).unwrap();
|
context.set_position([0., 0., 0.]).unwrap();
|
||||||
context
|
context
|
||||||
|
|
Loading…
Reference in New Issue
Block a user