From e12fc0fb10e0d624f7982f2ab8263b224cfc0f7f Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 16 Sep 2021 11:53:53 -0500 Subject: [PATCH] Replace `unwrap` with `ok`. There are odd issues where OpenAL sources get into broken states, though they should either be destroyed or fixed in the next frame, depending on the specifics. Should probably replace this with better logging, but for now it seems to work and not introduce new issues. --- src/lib.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b56e450..49b6b46 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -254,21 +254,21 @@ fn sync_source_and_components( source.set_relative(false); source .set_position([translation.x, translation.y, translation.z]) - .unwrap(); + .ok(); } else { source.set_relative(true); - source.set_position([0., 0., 0.]).unwrap(); + source.set_position([0., 0., 0.]).ok(); } - source.set_gain(gain).unwrap(); - source.set_pitch(pitch).unwrap(); + source.set_gain(gain).ok(); + source.set_pitch(pitch).ok(); source.set_looping(looping); - source.set_reference_distance(reference_distance).unwrap(); - source.set_max_distance(max_distance).unwrap(); - source.set_rolloff_factor(rolloff_factor).unwrap(); - source.set_radius(radius).unwrap(); + source.set_reference_distance(reference_distance).ok(); + source.set_max_distance(max_distance).ok(); + source.set_rolloff_factor(rolloff_factor).ok(); + source.set_radius(radius).ok(); if !bypass_global_effects { for (send, effect) in global_effects.iter_mut().enumerate() { - source.set_aux_send(send as i32, effect).unwrap(); + source.set_aux_send(send as i32, effect).ok(); } } } @@ -469,10 +469,8 @@ fn listener_update( error!("Error setting listener orientation: {:?}", e); } } else { - context.set_position([0., 0., 0.]).unwrap(); - context - .set_orientation(([0., 0., 1.], [0., 1., 0.])) - .unwrap(); + context.set_position([0., 0., 0.]).ok(); + context.set_orientation(([0., 0., 1.], [0., 1., 0.])).ok(); } } }