summaryrefslogtreecommitdiff
path: root/graphics/src/audio.rs
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-11-06 21:01:34 -0500
committerFreya Murphy <freya@freyacat.org>2025-11-06 21:09:00 -0500
commit73c4521b723129dff2d7c4ccac4d48dd16eae2b3 (patch)
tree7f188f740bed947a34b380d8234c7f1e8a2eb170 /graphics/src/audio.rs
parentLight bsp refactoring (diff)
downloadDungeonCrawl-73c4521b723129dff2d7c4ccac4d48dd16eae2b3.tar.gz
DungeonCrawl-73c4521b723129dff2d7c4ccac4d48dd16eae2b3.tar.bz2
DungeonCrawl-73c4521b723129dff2d7c4ccac4d48dd16eae2b3.zip
graphics: refactor renderer
Diffstat (limited to 'graphics/src/audio.rs')
-rw-r--r--graphics/src/audio.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/graphics/src/audio.rs b/graphics/src/audio.rs
new file mode 100644
index 0000000..8cf155f
--- /dev/null
+++ b/graphics/src/audio.rs
@@ -0,0 +1,32 @@
+//! The `audio` crate stores all audio assets that need to be loaded during runtime
+
+use raylib::audio::RaylibAudio;
+
+#[expect(dead_code)]
+type Sound = raylib::audio::Sound<'static>;
+
+/// The `Audio` container initalizes the audio subsystem
+/// for raylib, leaks it (to gurentee audio is statically loaded),
+/// then loads all needed audio samples
+#[derive(Debug)]
+pub struct Audio {}
+impl Audio {
+ pub(crate) fn load() -> crate::Result<Self> {
+ // Phantom handle to the raylib audio subsystem
+ // Raylib doesnt use a handle, but the rust bindings
+ // have one to ensure memory safety.
+ //
+ // We must leak this handle after allocating it,
+ // if we dont then all audio will be unloaded :(
+ //
+ // NOTE: would this cause issues if `Audio::load` was
+ // called multiple times?
+ let _handle = Box::leak(Box::new(RaylibAudio::init_audio_device()?));
+
+ // TODO: load audio samples
+
+ //let example = handle.new_sound("example.ogg")?;
+
+ Ok(Self {})
+ }
+}