From 7c8a698295d90c99b48fb1c9c2eab3e72103342b Mon Sep 17 00:00:00 2001 From: Hisham Aburaqibah Date: Sat, 28 Jun 2025 21:19:00 +0200 Subject: [PATCH] a couple more useful procs. spaces -> tabs --- alsa.odin | 323 +++++++++++++++++++++++++++--------------------------- 1 file changed, 164 insertions(+), 159 deletions(-) diff --git a/alsa.odin b/alsa.odin index 28547e6..ae20d2d 100644 --- a/alsa.odin +++ b/alsa.odin @@ -6,165 +6,165 @@ import "core:c" foreign import alsa "system:asound" pcm_open_flags :: enum i32 { - BLOCK = 0x0, - NONBLOCK = 0x00000001, - ASYNC = 0x00000002, + BLOCK = 0x0, + NONBLOCK = 0x00000001, + ASYNC = 0x00000002, } /** PCM stream (direction) */ pcm_stream_t :: enum i32 { - /** Playback stream */ - PLAYBACK = 0, - /** Capture stream */ - CAPTURE, - LAST = CAPTURE, + /** Playback stream */ + PLAYBACK = 0, + /** Capture stream */ + CAPTURE, + LAST = CAPTURE, } /** PCM sample format */ pcm_format_t :: enum { - /** Unknown */ - UNKNOWN = -1, - /** Signed 8 bit */ - S8 = 0, - /** Unsigned 8 bit */ - U8, - /** Signed 16 bit Little Endian */ - S16_LE, - /** Signed 16 bit Big Endian */ - S16_BE, - /** Unsigned 16 bit Little Endian */ - U16_LE, - /** Unsigned 16 bit Big Endian */ - U16_BE, - /** Signed 24 bit Little Endian using low three bytes in 32-bit word */ - S24_LE, - /** Signed 24 bit Big Endian using low three bytes in 32-bit word */ - S24_BE, - /** Unsigned 24 bit Little Endian using low three bytes in 32-bit word */ - U24_LE, - /** Unsigned 24 bit Big Endian using low three bytes in 32-bit word */ - U24_BE, - /** Signed 32 bit Little Endian */ - S32_LE, - /** Signed 32 bit Big Endian */ - S32_BE, - /** Unsigned 32 bit Little Endian */ - U32_LE, - /** Unsigned 32 bit Big Endian */ - U32_BE, - /** Float 32 bit Little Endian, Range -1.0 to 1.0 */ - FLOAT_LE, - /** Float 32 bit Big Endian, Range -1.0 to 1.0 */ - FLOAT_BE, - /** Float 64 bit Little Endian, Range -1.0 to 1.0 */ - FLOAT64_LE, - /** Float 64 bit Big Endian, Range -1.0 to 1.0 */ - FLOAT64_BE, - /** IEC-958 Little Endian */ - IEC958_SUBFRAME_LE, - /** IEC-958 Big Endian */ - IEC958_SUBFRAME_BE, - /** Mu-Law */ - MU_LAW, - /** A-Law */ - A_LAW, - /** Ima-ADPCM */ - IMA_ADPCM, - /** MPEG */ - MPEG, - /** GSM */ - GSM, - /** Signed 20bit Little Endian in 4bytes format, LSB justified */ - S20_LE, - /** Signed 20bit Big Endian in 4bytes format, LSB justified */ - S20_BE, - /** Unsigned 20bit Little Endian in 4bytes format, LSB justified */ - U20_LE, - /** Unsigned 20bit Big Endian in 4bytes format, LSB justified */ - U20_BE, - /** Special */ - SPECIAL = 31, - /** Signed 24bit Little Endian in 3bytes format */ - S24_3LE = 32, - /** Signed 24bit Big Endian in 3bytes format */ - S24_3BE, - /** Unsigned 24bit Little Endian in 3bytes format */ - U24_3LE, - /** Unsigned 24bit Big Endian in 3bytes format */ - U24_3BE, - /** Signed 20bit Little Endian in 3bytes format */ - S20_3LE, - /** Signed 20bit Big Endian in 3bytes format */ - S20_3BE, - /** Unsigned 20bit Little Endian in 3bytes format */ - U20_3LE, - /** Unsigned 20bit Big Endian in 3bytes format */ - U20_3BE, - /** Signed 18bit Little Endian in 3bytes format */ - S18_3LE, - /** Signed 18bit Big Endian in 3bytes format */ - S18_3BE, - /** Unsigned 18bit Little Endian in 3bytes format */ - U18_3LE, - /** Unsigned 18bit Big Endian in 3bytes format */ - U18_3BE, - /* G.723 (ADPCM) 24 kbit/s, 8 samples in 3 bytes */ - G723_24, - /* G.723 (ADPCM) 24 kbit/s, 1 sample in 1 byte */ - G723_24_1B, - /* G.723 (ADPCM) 40 kbit/s, 8 samples in 3 bytes */ - G723_40, - /* G.723 (ADPCM) 40 kbit/s, 1 sample in 1 byte */ - G723_40_1B, - /* Direct Stream Digital (DSD) in 1-byte samples (x8) */ - DSD_U8, - /* Direct Stream Digital (DSD) in 2-byte samples (x16) */ - DSD_U16_LE, - /* Direct Stream Digital (DSD) in 4-byte samples (x32) */ - DSD_U32_LE, - /* Direct Stream Digital (DSD) in 2-byte samples (x16) */ - DSD_U16_BE, - /* Direct Stream Digital (DSD) in 4-byte samples (x32) */ - DSD_U32_BE, - LAST = DSD_U32_BE, + /** Unknown */ + UNKNOWN = -1, + /** Signed 8 bit */ + S8 = 0, + /** Unsigned 8 bit */ + U8, + /** Signed 16 bit Little Endian */ + S16_LE, + /** Signed 16 bit Big Endian */ + S16_BE, + /** Unsigned 16 bit Little Endian */ + U16_LE, + /** Unsigned 16 bit Big Endian */ + U16_BE, + /** Signed 24 bit Little Endian using low three bytes in 32-bit word */ + S24_LE, + /** Signed 24 bit Big Endian using low three bytes in 32-bit word */ + S24_BE, + /** Unsigned 24 bit Little Endian using low three bytes in 32-bit word */ + U24_LE, + /** Unsigned 24 bit Big Endian using low three bytes in 32-bit word */ + U24_BE, + /** Signed 32 bit Little Endian */ + S32_LE, + /** Signed 32 bit Big Endian */ + S32_BE, + /** Unsigned 32 bit Little Endian */ + U32_LE, + /** Unsigned 32 bit Big Endian */ + U32_BE, + /** Float 32 bit Little Endian, Range -1.0 to 1.0 */ + FLOAT_LE, + /** Float 32 bit Big Endian, Range -1.0 to 1.0 */ + FLOAT_BE, + /** Float 64 bit Little Endian, Range -1.0 to 1.0 */ + FLOAT64_LE, + /** Float 64 bit Big Endian, Range -1.0 to 1.0 */ + FLOAT64_BE, + /** IEC-958 Little Endian */ + IEC958_SUBFRAME_LE, + /** IEC-958 Big Endian */ + IEC958_SUBFRAME_BE, + /** Mu-Law */ + MU_LAW, + /** A-Law */ + A_LAW, + /** Ima-ADPCM */ + IMA_ADPCM, + /** MPEG */ + MPEG, + /** GSM */ + GSM, + /** Signed 20bit Little Endian in 4bytes format, LSB justified */ + S20_LE, + /** Signed 20bit Big Endian in 4bytes format, LSB justified */ + S20_BE, + /** Unsigned 20bit Little Endian in 4bytes format, LSB justified */ + U20_LE, + /** Unsigned 20bit Big Endian in 4bytes format, LSB justified */ + U20_BE, + /** Special */ + SPECIAL = 31, + /** Signed 24bit Little Endian in 3bytes format */ + S24_3LE = 32, + /** Signed 24bit Big Endian in 3bytes format */ + S24_3BE, + /** Unsigned 24bit Little Endian in 3bytes format */ + U24_3LE, + /** Unsigned 24bit Big Endian in 3bytes format */ + U24_3BE, + /** Signed 20bit Little Endian in 3bytes format */ + S20_3LE, + /** Signed 20bit Big Endian in 3bytes format */ + S20_3BE, + /** Unsigned 20bit Little Endian in 3bytes format */ + U20_3LE, + /** Unsigned 20bit Big Endian in 3bytes format */ + U20_3BE, + /** Signed 18bit Little Endian in 3bytes format */ + S18_3LE, + /** Signed 18bit Big Endian in 3bytes format */ + S18_3BE, + /** Unsigned 18bit Little Endian in 3bytes format */ + U18_3LE, + /** Unsigned 18bit Big Endian in 3bytes format */ + U18_3BE, + /* G.723 (ADPCM) 24 kbit/s, 8 samples in 3 bytes */ + G723_24, + /* G.723 (ADPCM) 24 kbit/s, 1 sample in 1 byte */ + G723_24_1B, + /* G.723 (ADPCM) 40 kbit/s, 8 samples in 3 bytes */ + G723_40, + /* G.723 (ADPCM) 40 kbit/s, 1 sample in 1 byte */ + G723_40_1B, + /* Direct Stream Digital (DSD) in 1-byte samples (x8) */ + DSD_U8, + /* Direct Stream Digital (DSD) in 2-byte samples (x16) */ + DSD_U16_LE, + /* Direct Stream Digital (DSD) in 4-byte samples (x32) */ + DSD_U32_LE, + /* Direct Stream Digital (DSD) in 2-byte samples (x16) */ + DSD_U16_BE, + /* Direct Stream Digital (DSD) in 4-byte samples (x32) */ + DSD_U32_BE, + LAST = DSD_U32_BE, - /** Signed 16 bit CPU endian */ - S16 = S16_BE when ODIN_ENDIAN == .Big else S16_LE, - /** Unsigned 16 bit CPU endian */ - U16 = U16_BE when ODIN_ENDIAN == .Big else U16_LE, - /** Signed 24 bit CPU endian */ - S24 = S24_BE when ODIN_ENDIAN == .Big else S32_LE, - /** Unsigned 24 bit CPU endian */ - U24 = U24_BE when ODIN_ENDIAN == .Big else U24_LE, - /** Signed 32 bit CPU endian */ - S32 = S32_BE when ODIN_ENDIAN == .Big else S32_LE, - /** Unsigned 32 bit CPU endian */ - U32 = U32_BE when ODIN_ENDIAN == .Big else U32_LE, - /** Float 32 bit CPU endian */ - FLOAT = FLOAT_BE when ODIN_ENDIAN == .Big else FLOAT_LE, - /** Float 64 bit CPU endian */ - FLOAT64 = FLOAT64_BE when ODIN_ENDIAN == .Big else FLOAT64_LE, - /** IEC-958 CPU Endian */ - IEC958_SUBFRAME = IEC958_SUBFRAME_BE when ODIN_ENDIAN == .Big else IEC958_SUBFRAME_LE, - /** Signed 20bit in 4bytes format, LSB justified, CPU Endian */ - S20 = S20_BE when ODIN_ENDIAN == .Big else S20_LE, - /** Unsigned 20bit in 4bytes format, LSB justified, CPU Endian */ - U20 = U20_BE when ODIN_ENDIAN == .Big else U20_LE, + /** Signed 16 bit CPU endian */ + S16 = S16_BE when ODIN_ENDIAN == .Big else S16_LE, + /** Unsigned 16 bit CPU endian */ + U16 = U16_BE when ODIN_ENDIAN == .Big else U16_LE, + /** Signed 24 bit CPU endian */ + S24 = S24_BE when ODIN_ENDIAN == .Big else S32_LE, + /** Unsigned 24 bit CPU endian */ + U24 = U24_BE when ODIN_ENDIAN == .Big else U24_LE, + /** Signed 32 bit CPU endian */ + S32 = S32_BE when ODIN_ENDIAN == .Big else S32_LE, + /** Unsigned 32 bit CPU endian */ + U32 = U32_BE when ODIN_ENDIAN == .Big else U32_LE, + /** Float 32 bit CPU endian */ + FLOAT = FLOAT_BE when ODIN_ENDIAN == .Big else FLOAT_LE, + /** Float 64 bit CPU endian */ + FLOAT64 = FLOAT64_BE when ODIN_ENDIAN == .Big else FLOAT64_LE, + /** IEC-958 CPU Endian */ + IEC958_SUBFRAME = IEC958_SUBFRAME_BE when ODIN_ENDIAN == .Big else IEC958_SUBFRAME_LE, + /** Signed 20bit in 4bytes format, LSB justified, CPU Endian */ + S20 = S20_BE when ODIN_ENDIAN == .Big else S20_LE, + /** Unsigned 20bit in 4bytes format, LSB justified, CPU Endian */ + U20 = U20_BE when ODIN_ENDIAN == .Big else U20_LE, } /** PCM access type */ pcm_access_t :: enum { - /** mmap access with simple interleaved channels */ - MMAP_INTERLEAVED = 0, - /** mmap access with simple non interleaved channels */ - MMAP_NONINTERLEAVED, - /** mmap access with complex placement */ - MMAP_COMPLEX, - /** snd_pcm_readi/snd_pcm_writei access */ - RW_INTERLEAVED, - /** snd_pcm_readn/snd_pcm_writen access */ - RW_NONINTERLEAVED, - LAST = RW_NONINTERLEAVED + /** mmap access with simple interleaved channels */ + MMAP_INTERLEAVED = 0, + /** mmap access with simple non interleaved channels */ + MMAP_NONINTERLEAVED, + /** mmap access with complex placement */ + MMAP_COMPLEX, + /** snd_pcm_readi/snd_pcm_writei access */ + RW_INTERLEAVED, + /** snd_pcm_readn/snd_pcm_writen access */ + RW_NONINTERLEAVED, + LAST = RW_NONINTERLEAVED } /** channel positions */ @@ -223,19 +223,24 @@ pcm_chmap_t :: struct { @(link_prefix="snd_") foreign alsa { - pcm_open :: proc(pcmp: ^^pcm_t, name: cstring, stream: pcm_stream_t, mode: pcm_open_flags) -> i32 --- - strerror :: proc(errnum: i32) -> cstring --- - pcm_set_params :: proc( - pcm: ^pcm_t, - format: pcm_format_t, - access: pcm_access_t, - channels: u32, - rate: u32, - soft_resample: i32, - latency: u32) -> i32 --- - pcm_drain :: proc(pcm: ^pcm_t) -> i32 --- - pcm_close :: proc(pcm: ^pcm_t) -> i32 --- - pcm_writei :: proc(pcm: ^pcm_t, buffer: rawptr, size: pcm_uframes_t) -> pcm_sframes_t --- + pcm_open :: proc(pcmp: ^^pcm_t, name: cstring, stream: pcm_stream_t, mode: pcm_open_flags) -> i32 --- + strerror :: proc(errnum: i32) -> cstring --- + pcm_set_params :: proc( + pcm: ^pcm_t, + format: pcm_format_t, + access: pcm_access_t, + channels: u32, + rate: u32, + soft_resample: i32, + latency: u32) -> i32 --- + pcm_drain :: proc(pcm: ^pcm_t) -> i32 --- + pcm_close :: proc(pcm: ^pcm_t) -> i32 --- + pcm_prepare :: proc(pcm: ^pcm_t) -> i32 --- + pcm_writei :: proc(pcm: ^pcm_t, buffer: rawptr, size: pcm_uframes_t) -> pcm_sframes_t --- + pcm_writen :: proc(pcm: ^pcm_t, bufs: [^]rawptr, size: pcm_uframes_t) -> pcm_sframes_t --- + pcm_readi :: proc(pcm: ^pcm_t, buffer: rawptr, size: pcm_uframes_t) -> pcm_sframes_t --- + pcm_readn :: proc(pcm: ^pcm_t, bufs: [^]rawptr, size: pcm_uframes_t) -> pcm_sframes_t --- + pcm_format_width :: proc(format: pcm_format_t) -> i32 --- 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 ---