Skip to content

Commit 6267d43

Browse files
author
Hyrum Wright
committed
Add method for loading chunks from bytes
1 parent 4583b3d commit 6267d43

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/sdl2/mixer/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,12 @@ impl Chunk {
305305
Self::from_owned_raw(raw)
306306
}
307307

308+
/// Load from `RWOps` for use as a sample.
309+
pub fn from_rwops(rwops: RWops) -> Result<Chunk, String> {
310+
let raw = unsafe { mixer::Mix_LoadWAV_RW(rwops.raw(), 0) };
311+
Self::from_owned_raw(raw)
312+
}
313+
308314
/// Load chunk from a buffer containing raw audio data in the mixer format. The length of the
309315
/// buffer has to fit in 32-bit unsigned integer. The chunk takes ownership of the buffer.
310316
///

0 commit comments

Comments
 (0)