From 6267d4398288ce5c57c4433af4513f94ad7fc331 Mon Sep 17 00:00:00 2001 From: Hyrum Wright Date: Tue, 14 Oct 2025 09:10:30 -0600 Subject: [PATCH] Add method for loading chunks from bytes --- src/sdl2/mixer/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sdl2/mixer/mod.rs b/src/sdl2/mixer/mod.rs index be39d3397d..1921db2926 100644 --- a/src/sdl2/mixer/mod.rs +++ b/src/sdl2/mixer/mod.rs @@ -305,6 +305,12 @@ impl Chunk { Self::from_owned_raw(raw) } + /// Load from `RWOps` for use as a sample. + pub fn from_rwops(rwops: RWops) -> Result { + let raw = unsafe { mixer::Mix_LoadWAV_RW(rwops.raw(), 0) }; + Self::from_owned_raw(raw) + } + /// Load chunk from a buffer containing raw audio data in the mixer format. The length of the /// buffer has to fit in 32-bit unsigned integer. The chunk takes ownership of the buffer. ///