From 8ede102a656ce97894dfbfe6ece0c385f2f7ae27 Mon Sep 17 00:00:00 2001 From: Polesznyák Márk Date: Sun, 22 Feb 2026 02:16:59 +0100 Subject: refactor: get rid of unused SDL_AudioFormat defines --- main.ha | 9 ++------- sdl_audio.ha | 17 ++--------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/main.ha b/main.ha index e3e9332..6f6c1b4 100644 --- a/main.ha +++ b/main.ha @@ -444,7 +444,7 @@ fn run() (void | fs::error | io::error | sdl2::error) = { let renderer = sdl2::SDL_CreateRenderer(window, -1, sdl2::SDL_RendererFlags::ACCELERATED)?; defer sdl2::SDL_DestroyRenderer(renderer); - const want_spec = SDL_AudioSpec { + const spec = SDL_AudioSpec { freq = 44100, format = AUDIO_S16LSB, channels = 1, @@ -454,12 +454,7 @@ fn run() (void | fs::error | io::error | sdl2::error) = { ... }; - let have_spec = SDL_AudioSpec { - callback = &audio_callback, - ... - }; - - let dev = SDL_OpenAudioDevice(null, 0, &want_spec, &have_spec, 0)?; + let dev = SDL_OpenAudioDevice(null, 0, &spec, null, 0)?; defer SDL_CloseAudioDevice(dev); sdl2::SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF)?; diff --git a/sdl_audio.ha b/sdl_audio.ha index 545668c..0a78e67 100644 --- a/sdl_audio.ha +++ b/sdl_audio.ha @@ -3,20 +3,7 @@ use types::c; type SDL_AudioFormat = u16; -def AUDIO_U8: SDL_AudioFormat = 0x0008; -def AUDIO_S8: SDL_AudioFormat = 0x8008; -def AUDIO_U16LSB: SDL_AudioFormat = 0x0010; def AUDIO_S16LSB: SDL_AudioFormat = 0x8010; -def AUDIO_U16MSB: SDL_AudioFormat = 0x1010; -def AUDIO_S16MSB: SDL_AudioFormat = 0x9010; -def AUDIO_U16: SDL_AudioFormat = AUDIO_U16LSB; -def AUDIO_S16: SDL_AudioFormat = AUDIO_S16LSB; -def AUDIO_S32LSB: SDL_AudioFormat = 0x8020; -def AUDIO_S32MSB: SDL_AudioFormat = 0x9020; -def AUDIO_S32: SDL_AudioFormat = AUDIO_S32LSB; -def AUDIO_F32LSB: SDL_AudioFormat = 0x8120; -def AUDIO_F32MSB: SDL_AudioFormat = 0x9120; -def AUDIO_F32: SDL_AudioFormat = AUDIO_F32LSB; type SDL_AudioCallback = *fn(userdata: nullable *opaque, stream: *u8, len_: int) void; @@ -34,7 +21,7 @@ type SDL_AudioSpec = struct { type SDL_AudioDeviceID = u32; -@symbol("SDL_OpenAudioDevice") fn _SDL_OpenAudioDevice(device: nullable *c::char, iscapture: int, desired: const *SDL_AudioSpec, obtained: *SDL_AudioSpec, allowed_changes: int) SDL_AudioDeviceID; +@symbol("SDL_OpenAudioDevice") fn _SDL_OpenAudioDevice(device: nullable *c::char, iscapture: int, desired: const *SDL_AudioSpec, obtained: nullable *SDL_AudioSpec, allowed_changes: int) SDL_AudioDeviceID; @symbol("SDL_CloseAudioDevice") fn SDL_CloseAudioDevice(dev: SDL_AudioDeviceID) void; @@ -42,7 +29,7 @@ type SDL_AudioDeviceID = u32; @symbol("SDL_GetError") fn SDL_GetError() const *c::char; -fn SDL_OpenAudioDevice(device: nullable *c::char, iscapture: int, desired: const *SDL_AudioSpec, obtained: *SDL_AudioSpec, allowed_changes: int) (SDL_AudioDeviceID | sdl2::error) = { +fn SDL_OpenAudioDevice(device: nullable *c::char, iscapture: int, desired: const *SDL_AudioSpec, obtained: nullable *SDL_AudioSpec, allowed_changes: int) (SDL_AudioDeviceID | sdl2::error) = { const ret = _SDL_OpenAudioDevice(device, iscapture, desired, obtained, allowed_changes); if (ret == 0) { -- cgit v1.2.3