aboutsummaryrefslogtreecommitdiff
path: root/sdl2/mixer/samples.ha
diff options
context:
space:
mode:
authorVlad-Stefan Harbuz <vlad@vladh.net>2022-02-07 13:08:52 +0100
committerDrew DeVault <sir@cmpwn.com>2022-02-07 18:56:08 +0100
commit2276dc7ad067f7af7504783239103c1abd7b4433 (patch)
tree20f2f98f4af8b2ff0efeb3b15f1a26e09702e908 /sdl2/mixer/samples.ha
parentcorrect indentation (diff)
downloadhare-chip8-2276dc7ad067f7af7504783239103c1abd7b4433.tar.gz
refactor names from e.g. sdl2::init() to sdl2::SDL_Init()
Signed-off-by: Vlad-Stefan Harbuz <vlad@vladh.net>
Diffstat (limited to '')
-rw-r--r--sdl2/mixer/samples.ha32
1 files changed, 16 insertions, 16 deletions
diff --git a/sdl2/mixer/samples.ha b/sdl2/mixer/samples.ha
index aaf1ad1..2dce2ef 100644
--- a/sdl2/mixer/samples.ha
+++ b/sdl2/mixer/samples.ha
@@ -3,37 +3,37 @@ use io;
use os;
use sdl2;
-// The internal format for an audio chunk
-export type chunk = struct {
+// The internal format for an audio Mix_Chunk
+export type Mix_Chunk = struct {
allocated: int,
abuf: *u8,
alen: u32,
volume: u8,
};
-@symbol("Mix_LoadWAV_RW") fn _loadwav_rw(src: *sdl2::rwops, freesrc: int) nullable *chunk;
+@symbol("Mix_LoadWAV_RW") fn _Mix_LoadWAV_RW(src: *sdl2::SDL_RWops, freesrc: int) nullable *Mix_Chunk;
// Loads a sample from an [[io::handle]]. The stream will not be closed for you.
-export fn load(src: io::handle) (*chunk | sdl2::error) = {
+export fn Mix_LoadWAV_RW(src: io::handle) (*Mix_Chunk | sdl2::error) = {
const rw = sdl2::rw_from_handle(src);
- defer sdl2::rwclose(rw);
- return sdl2::wrapptr(_loadwav_rw(rw, 0))?: *chunk;
+ defer sdl2::SDL_RWclose(rw);
+ return sdl2::wrapptr(_Mix_LoadWAV_RW(rw, 0))?: *Mix_Chunk;
};
// Loads a sample from a file path.
-export fn load_file(src: str) (*chunk | fs::error | sdl2::error) = {
+export fn load_file(src: str) (*Mix_Chunk | fs::error | sdl2::error) = {
const file = os::open(src)?;
defer io::close(file);
- return load(file);
+ return Mix_LoadWAV_RW(file);
};
-// Free the memory used in chunk, and free chunk itself as well. Do not use
-// chunk after this without loading a new sample to it. Note: It's a bad idea to
-// free a chunk that is still being played...
-export @symbol("Mix_FreeChunk") fn free_chunk(chunk: *chunk) void;
+// Free the memory used in Mix_Chunk, and free Mix_Chunk itself as well. Do not use
+// Mix_Chunk after this without loading a new sample to it. Note: It's a bad idea to
+// free a Mix_Chunk that is still being played...
+export @symbol("Mix_FreeChunk") fn Mix_FreeChunk(Mix_Chunk: *Mix_Chunk) void;
-// Maximum volume for a chunk.
-export def MAX_VOLUME: int = 128; // XXX: SDL_mixer derives this from SDL_MIX_MAXVOLUME
+// Maximum volume for a Mix_Chunk.
+export def MIX_MAX_VOLUME: int = 128; // XXX: SDL_mixer derives this from SDL_MIX_MAXVOLUME
-// Sets the chunk volume as specified, returning the previous value.
-export @symbol("Mix_VolumeChunk") fn volume_chunk(chunk: *chunk, volume: int) int;
+// Sets the Mix_Chunk volume as specified, returning the previous value.
+export @symbol("Mix_VolumeChunk") fn Mix_VolumeChunk(Mix_Chunk: *Mix_Chunk, volume: int) int;