From 5ac0c4cbeaaecaa6fd075ca70cbe58e7d6d89e1b Mon Sep 17 00:00:00 2001 From: Hyrum Wright Date: Tue, 14 Oct 2025 09:10:30 -0600 Subject: [PATCH 1/3] 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 5421e21aea..a4fee9b523 100644 --- a/src/sdl2/mixer/mod.rs +++ b/src/sdl2/mixer/mod.rs @@ -307,6 +307,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. /// From 4f2596838d825d6690306fd7d56a6f067bd25805 Mon Sep 17 00:00:00 2001 From: Hyrum Wright Date: Mon, 21 Sep 2026 07:47:27 -0400 Subject: [PATCH 2/3] Update src/sdl2/mixer/mod.rs Co-authored-by: Antoni Spaanderman <49868160+antonilol@users.noreply.github.com> --- src/sdl2/mixer/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl2/mixer/mod.rs b/src/sdl2/mixer/mod.rs index a4fee9b523..72c992754c 100644 --- a/src/sdl2/mixer/mod.rs +++ b/src/sdl2/mixer/mod.rs @@ -308,7 +308,7 @@ impl Chunk { } /// Load from `RWOps` for use as a sample. - pub fn from_rwops(rwops: RWops) -> Result { + pub fn from_rwops(rwops: RWops<'_>) -> Result { let raw = unsafe { mixer::Mix_LoadWAV_RW(rwops.raw(), 0) }; Self::from_owned_raw(raw) } From c5b04f8df6c6d42a3a06283c67d6fea61debf8eb Mon Sep 17 00:00:00 2001 From: Hyrum Wright Date: Mon, 21 Sep 2026 07:52:38 -0400 Subject: [PATCH 3/3] Update changelog. --- changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.md b/changelog.md index e28696951b..e1bfe489ce 100644 --- a/changelog.md +++ b/changelog.md @@ -13,6 +13,8 @@ when upgrading from a version of rust-sdl2 to another. [PR #1506](https://github.com/Rust-SDL2/rust-sdl2/pull/1506) **BREAKING CHANGE** Update crates.io dependencies, update bundled SDL2 to 2.32.10, add whitelist to bindgen to only emit SDL related items, and specifically no platform (or compiler, etc) specific items. Implement the same set of useful derived traits on bitflags types. +[PR #1508](https://github.com/Rust-SDL2/rust-sdl2/pull/1508) Add `Chunk::from_rwops` to bind `Mix_LoadWAV_RW`. + ### v0.38.0 [PR #1493](https://github.com/Rust-SDL2/rust-sdl2/pull/1493) Add `Rect::origin` and specifies origin location in `Rect::new`.