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`. diff --git a/src/sdl2/mixer/mod.rs b/src/sdl2/mixer/mod.rs index 5421e21aea..72c992754c 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. ///