aboutsummaryrefslogtreecommitdiff
path: root/sdl2/mixer
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
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 'sdl2/mixer')
-rw-r--r--sdl2/mixer/channels.ha10
-rw-r--r--sdl2/mixer/general.ha32
-rw-r--r--sdl2/mixer/samples.ha32
3 files changed, 37 insertions, 37 deletions
diff --git a/sdl2/mixer/channels.ha b/sdl2/mixer/channels.ha
index 4bf4820..fffccd0 100644
--- a/sdl2/mixer/channels.ha
+++ b/sdl2/mixer/channels.ha
@@ -1,8 +1,8 @@
use sdl2;
-@symbol("Mix_PlayChannelTimed") fn _play_channel_timed(
+@symbol("Mix_PlayChannelTimed") fn _Mix_PlayChannelTimed(
channel: int,
- sample: *chunk,
+ sample: *Mix_Chunk,
loops: int,
ticks: int,
) int;
@@ -11,10 +11,10 @@ use sdl2;
// channel. The sample will play for loops+1 number of times, unless stopped by
// halt, or fade out, or setting a new expiration time of less time than it
// would have originally taken to play the loops, or closing the mixer.
-export fn play_channel(
+export fn Mix_PlayChannelTimed(
channel: int,
- sample: *chunk,
+ sample: *Mix_Chunk,
loops: int,
) (void | sdl2::error) = {
- return sdl2::wrapvoid(_play_channel_timed(channel, sample, loops, -1));
+ return sdl2::wrapvoid(_Mix_PlayChannelTimed(channel, sample, loops, -1));
};
diff --git a/sdl2/mixer/general.ha b/sdl2/mixer/general.ha
index 32c7b38..4f819bf 100644
--- a/sdl2/mixer/general.ha
+++ b/sdl2/mixer/general.ha
@@ -1,7 +1,7 @@
use sdl2;
// Flags for [[init]].
-export type init_flags = enum {
+export type MIX_InitFlags = enum {
FLAC = 0x00000001,
MOD = 0x00000002,
MP3 = 0x00000008,
@@ -11,42 +11,42 @@ export type init_flags = enum {
};
// The default mixer has 8 simultaneous mixing channels
-export def CHANNELS: int = 8;
+export def MIX_CHANNELS: int = 8;
// Good default frequency for a PC soundcard
-export def DEFAULT_FREQUENCY: int = 22050;
+export def MIX_DEFAULT_FREQUENCY: int = 22050;
// Good default channels for a PC soundcard
-export def DEFAULT_CHANNELS: int = 2;
+export def MIX_DEFAULT_CHANNELS: int = 2;
// XXX: This should choose MSB on a big-endian system:
// Good default format for a PC soundcard
-export def DEFAULT_FORMAT: sdl2::audio_format = sdl2::AUDIO_S16LSB;
+export def MIX_DEFAULT_FORMAT: sdl2::SDL_AudioFormat = sdl2::AUDIO_S16LSB;
-@symbol("Mix_Init") fn _init(flags: int) int;
+@symbol("Mix_Init") fn _Mix_Init(flags: int) int;
// Loads dynamic libraries and prepares them for use. Flags should be
-// one or more flags from [[init_flags]] OR'd together.
-export fn init(flags: init_flags) (void | sdl2::error) = {
- return sdl2::wrapvoid(_init(flags));
+// one or more flags from [[MIX_InitFlags]] OR'd together.
+export fn Mix_Init(flags: MIX_InitFlags) (void | sdl2::error) = {
+ return sdl2::wrapvoid(_Mix_Init(flags));
};
-// Unloads libraries loaded with [[init]].
-export @symbol("Mix_Quit") fn quit() void;
+// Unloads libraries loaded with [[Mix_Init]].
+export @symbol("Mix_Quit") fn Mix_Quit() void;
-@symbol("Mix_OpenAudio") fn _openaudio(frequency: int,
+@symbol("Mix_OpenAudio") fn _Mix_OpenAudio(frequency: int,
format: u16, channels: int, chunksize: int) int;
// Open the mixer with a certain audio format
-export fn open_audio(
+export fn Mix_OpenAudio(
frequency: int,
- format: sdl2::audio_format,
+ format: sdl2::SDL_AudioFormat,
channels: int,
chunksize: int,
) (void | sdl2::error) = {
- return sdl2::wrapvoid(_openaudio(frequency, format, channels, chunksize));
+ return sdl2::wrapvoid(_Mix_OpenAudio(frequency, format, channels, chunksize));
};
// Close the mixer, halting all playing audio
-export @symbol("Mix_CloseAudio") fn close_audio() void;
+export @symbol("Mix_CloseAudio") fn Mix_CloseAudio() void;
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;