diff options
Diffstat (limited to '')
| -rw-r--r-- | sdl2/mixer/channels.ha | 10 | ||||
| -rw-r--r-- | sdl2/mixer/general.ha | 32 | ||||
| -rw-r--r-- | sdl2/mixer/samples.ha | 32 |
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; |
