diff --git a/demos/features/src/main.rs b/demos/features/src/main.rs index 13a7e7c3a4..f51a653b13 100644 --- a/demos/features/src/main.rs +++ b/demos/features/src/main.rs @@ -427,7 +427,7 @@ fn audio_demo_plugin(session: &mut Session) { fn audio_demo_ui( ctx: Res, localization: Localization, - audio: Res, + mut audio: ResMut, meta: Root, assets: Res, ) { @@ -437,10 +437,7 @@ fn audio_demo_ui( ui.vertical_centered(|ui| { ui.add_space(50.0); if ui.button(localization.get("play-sound")).clicked() { - audio - .borrow_mut() - .play(&*assets.get(meta.audio_demo)) - .unwrap(); + audio.play(&*assets.get(meta.audio_demo)).unwrap(); } }) }); diff --git a/framework_crates/bones_framework/src/render/audio.rs b/framework_crates/bones_framework/src/render/audio.rs index ed5ee34e10..eb6a75dc52 100644 --- a/framework_crates/bones_framework/src/render/audio.rs +++ b/framework_crates/bones_framework/src/render/audio.rs @@ -1,6 +1,6 @@ //! Audio components. -use std::{io::Cursor, sync::Arc}; +use std::io::Cursor; use crate::prelude::*; @@ -18,19 +18,18 @@ pub fn game_plugin(game: &mut Game) { } /// The audio manager resource which can be used to play sounds. -#[derive(HasSchema, Clone, Deref, DerefMut)] -pub struct AudioManager(Arc>); +#[derive(HasSchema, Deref, DerefMut)] +#[schema(no_clone)] +pub struct AudioManager(KiraAudioManager); impl Default for AudioManager { fn default() -> Self { - Self(Arc::new(AtomicCell::new( - KiraAudioManager::::new(default()).unwrap(), - ))) + Self(KiraAudioManager::::new(default()).unwrap()) } } /// The audio source asset type, contains no data, but [`Handle`] is still useful /// because it uniquely represents a sound/music that may be played outside of bones. -#[derive(Clone, HasSchema, Debug)] +#[derive(Clone, HasSchema, Debug, Deref, DerefMut)] #[schema(no_default)] #[type_data(asset_loader(["ogg", "mp3", "flac", "wav"], AudioLoader))] pub struct AudioSource(pub StaticSoundData);