Skip to content

Commit

Permalink
Fix Drop impl for sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
InnocentusLime authored and not-fl3 committed Sep 21, 2024
1 parent ad4d7cf commit 38a1d78
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl Drop for QuadSndSoundGuarded {
}

#[derive(Clone)]
pub struct Sound(Arc<QuadSndSound>);
pub struct Sound(Arc<QuadSndSoundGuarded>);

impl std::fmt::Debug for Sound {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down Expand Up @@ -127,13 +127,13 @@ pub async fn load_sound_from_bytes(data: &[u8]) -> Result<Sound, Error> {
crate::window::next_frame().await;
}

Ok(Sound(Arc::new(sound)))
Ok(Sound(Arc::new(QuadSndSoundGuarded(sound))))
}

pub fn play_sound_once(sound: &Sound) {
let ctx = &mut get_context().audio_context;

sound.0.play(
sound.0 .0.play(
&mut ctx.native_ctx,
PlaySoundParams {
looped: false,
Expand All @@ -144,15 +144,15 @@ pub fn play_sound_once(sound: &Sound) {

pub fn play_sound(sound: &Sound, params: PlaySoundParams) {
let ctx = &mut get_context().audio_context;
sound.0.play(&mut ctx.native_ctx, params);
sound.0 .0.play(&mut ctx.native_ctx, params);
}

pub fn stop_sound(sound: &Sound) {
let ctx = &mut get_context().audio_context;
sound.0.stop(&mut ctx.native_ctx);
sound.0 .0.stop(&mut ctx.native_ctx);
}

pub fn set_sound_volume(sound: &Sound, volume: f32) {
let ctx = &mut get_context().audio_context;
sound.0.set_volume(&mut ctx.native_ctx, volume)
sound.0 .0.set_volume(&mut ctx.native_ctx, volume)
}

0 comments on commit 38a1d78

Please sign in to comment.