From 3d2c45a077fcf9cd02a0d8abf3c8dfd7f1584edd Mon Sep 17 00:00:00 2001 From: Hisham Aburaqibah Date: Mon, 7 Jul 2025 23:40:11 +0200 Subject: [PATCH] feat: some mixer-related procs and data types --- alsa.odin | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/alsa.odin b/alsa.odin index ae20d2d..882a29f 100644 --- a/alsa.odin +++ b/alsa.odin @@ -209,10 +209,34 @@ pcm_chmap_position :: enum i32 { LAST = BRC, } +mixer_selem_channel_id_t :: enum i32 { + UNKNOWN = -1, + FRONT_LEFT = 0, + FRONT_RIGHT, + REAR_LEFT, + REAR_RIGHT, + FRONT_CENTER, + WOOFER, + SIDE_LEFT, + SIDE_RIGHT, + REAR_CENTER, + MONO = FRONT_LEFT, + // LAST = 31, +} + +mixer_selem_regopt_abstract :: enum i32 { + NONE = 0, + BASIC, +} + pcm_uframes_t :: c.ulong pcm_sframes_t :: c.long pcm_t :: struct{} pcm_hw_params_t :: struct{} +mixer_t :: struct{} +mixer_class_t :: struct{} +mixer_selem_id_t :: struct{} +mixer_elem_t :: struct{} pcm_chmap_t :: struct { // Number of channels @@ -221,6 +245,14 @@ pcm_chmap_t :: struct { pos: [0]u32, } +mixer_selem_regopt :: struct { + ver: c.int, + abstract: mixer_selem_regopt_abstract, + device: cstring, + playback_pcm: ^pcm_t, + capture_pcm: ^pcm_t, +} + @(link_prefix="snd_") foreign alsa { pcm_open :: proc(pcmp: ^^pcm_t, name: cstring, stream: pcm_stream_t, mode: pcm_open_flags) -> i32 --- @@ -244,4 +276,36 @@ foreign alsa { pcm_hw_params_set_channels :: proc(pcm: ^pcm_t, params: ^pcm_hw_params_t, val: u32) --- pcm_chmap_long_name :: proc(val: pcm_chmap_position) -> cstring --- pcm_get_chmap :: proc(pcm: ^pcm_t) -> ^pcm_chmap_t --- + + mixer_open :: proc(mixerp: ^^mixer_t, mode: c.int) -> c.int --- + mixer_attach :: proc(mixer: ^mixer_t, name: cstring) -> c.int --- + mixer_selem_register :: proc(mixer: ^mixer_t, options: ^mixer_selem_regopt, classp: ^^mixer_class_t) -> c.int --- + mixer_load :: proc(mixer: ^mixer_t) -> c.int --- + mixer_first_elem :: proc(mixer: ^mixer_t) -> ^mixer_elem_t --- + mixer_elem_next :: proc(elem: ^mixer_elem_t) -> ^mixer_elem_t --- + // MACRO: mixer_selem_id_alloca :: proc() --- + mixer_selem_id_malloc :: proc(ptr: ^^mixer_selem_id_t) -> c.int --- + mixer_selem_id_set_index :: proc(obj: ^mixer_selem_id_t, val: c.uint) --- + mixer_selem_id_set_name :: proc(obj: ^mixer_selem_id_t, val: cstring) --- + mixer_selem_get_name :: proc(elem: ^mixer_elem_t) -> cstring --- + mixer_find_selem :: proc(mixer: ^mixer_t, id: ^mixer_selem_id_t) -> ^mixer_elem_t --- + mixer_selem_has_playback_switch :: proc(elem: ^mixer_elem_t) -> b32 --- + mixer_selem_set_playback_switch_all :: proc(elem: ^mixer_elem_t, value: c.int) -> c.int --- + /* + Return value of playback switch control of a mixer simple element. + + Parameters + elem Mixer simple element handle + channel mixer simple element channel identifier + value pointer to returned value + + Returns + 0 on success otherwise a negative error code + */ + mixer_selem_get_playback_switch :: proc(elem: ^mixer_elem_t, channel: mixer_selem_channel_id_t, value: ^c.int) -> c.int --- + mixer_selem_has_capture_switch :: proc(mixer: ^mixer_elem_t) -> b32 --- + mixer_selem_get_capture_switch :: proc(elem: ^mixer_elem_t, channel: mixer_selem_channel_id_t, value: ^c.int) -> c.int --- + mixer_selem_set_capture_switch :: proc(elem: ^mixer_elem_t, channel: mixer_selem_channel_id_t, value: c.int) -> c.int --- + mixer_selem_id_free :: proc(obj: ^mixer_selem_id_t) --- + mixer_close :: proc(mixer: ^mixer_t) -> c.int --- }