mirror of
https://github.com/lightsoutgames/bevy_openal.git
synced 2024-12-21 12:46:01 +00:00
Add check for swapped buffers, and reset source if needed.
This commit is contained in:
parent
612ac74a56
commit
7b2e26e3e6
14
src/lib.rs
14
src/lib.rs
|
@ -315,6 +315,20 @@ fn update_source_properties(
|
|||
..
|
||||
} = *sound;
|
||||
if state != SoundState::Stopped {
|
||||
let mut swap_buffers = false;
|
||||
if let Some(source) = &sound.source {
|
||||
let source = source.lock().unwrap();
|
||||
if let Some(source_buffer) = source.buffer() {
|
||||
if let Some(sound_buffer) = buffers.0.get(&sound.buffer.id) {
|
||||
if source_buffer.as_raw() != sound_buffer.as_raw() {
|
||||
swap_buffers = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if swap_buffers {
|
||||
sound.source = None;
|
||||
}
|
||||
if sound.source.is_none() {
|
||||
if let Ok(mut source) = context.new_static_source() {
|
||||
if let Some(buffer) = buffers.0.get(&sound.buffer.id) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user