Repository navigation
Audio Engine
Vodka provides a native Linux audio runtime (libvodka_audio.so and vodka-audio under vodka/src/audio/) paired with Win32 audio DLLs (mmdevapi.dll, dsound.dll, xaudio2_9.dll, winmm.dll) and ntdll audio thunks (audio_thunks.zig).
All host audio libraries are loaded dynamically via dlopen at runtime — no PipeWire or ALSA development headers are required to build Vodka, and headless/sandboxed environments automatically fall back to a deterministic software sink so tests and CI run cleanly.
flowchart LR
Apps["Windows Apps / Games"] --> DLLs["mmdevapi.dll / xaudio2_9.dll / dsound.dll / winmm.dll"]
DLLs --> Thunks["libvodka_ntdll.so (audio_thunks.zig / net_input_thunks.zig)"]
Thunks --> AudioLib["libvodka_audio.so (unixlib.zig)"]
AudioLib --> WASAPI["WASAPI Engine (wasapi.zig)"]
WASAPI --> Ring["Lock-Free SPSC PCM Ring Buffer (ringbuf.zig)"]
Ring --> PW["PipeWire Backend (libpipewire-0.3.so.0)"]
Ring --> ALSA["ALSA PCM Backend (libasound.so.2)"]
Ring --> Soft["Software Sink Fallback (Headless)"]
-
PcmRingBuffer: Single-producer, single-consumer lock-free ring buffer with power-of-two frame capacity (minimum 64 frames) and atomicread_pos/write_posindices plus atomicunderrunsandoverrunscounters. -
Sample Formats (
SampleFormat):-
i16_le(S16_LE, 2 bytes/sample) -
i24_le(S24_3LE, 3 bytes/sample) -
i32_le(S32_LE, 4 bytes/sample) -
f32_le(F32_LE, 4 bytes/sample)
-
-
Format Helpers & Mixing: Frame/byte/duration conversion (including Windows 100-nanosecond
REFERENCE_TIMEintervals), sample format conversion, multi-channel mixing (mono, stereo, 5.1), and soft-clipping gain/mute ramps.
Implements the Windows Audio Session API core state machine:
-
EndpointRegistry&AudioEndpoint: Tracks render (AudioDataFlow.render) and capture (AudioDataFlow.capture) endpoints, default device flags, active status, mix format, and backend tag. -
AudioSession: Per-session volume/mute state and smooth gain ramping. -
AudioClient: Supports.sharedand.exclusiveshare modes, stream lifecycle (uninitialized,stopped,running,paused,reset),getCurrentPadding,getRenderBuffer/releaseRenderBuffer(honoringAUDCLNT_BUFFERFLAGS_SILENT), capture read cycles, and event-driven buffer readiness notifications.
- Dynamically loads
libpipewire-0.3.so.0viadlopen(RTLD_NOW | RTLD_LOCAL). - Resolves
pw_init,pw_deinit,pw_get_library_version,pw_thread_loop_new/destroy/start/stop/lock/unlock/get_loop, andpw_stream_destroy/set_active. - Probes daemon socket reachability at
$PIPEWIRE_RUNTIME_DIR/pipewire-0(or$XDG_RUNTIME_DIR/pipewire-0). - Populates render/capture endpoints and falls back smoothly to the software ring buffer if the daemon socket is absent.
- Dynamically loads
libasound.so.2(falling back tolibasound.so) viadlopen. - Resolves
snd_asoundlib_version,snd_pcm_open,snd_pcm_close,snd_pcm_set_params,snd_pcm_writei,snd_pcm_readi,snd_pcm_drain,snd_pcm_drop,snd_pcm_prepare, andsnd_pcm_recover. - Supports playback and capture (
SND_PCM_STREAM_PLAYBACK/SND_PCM_STREAM_CAPTURE), interleaved access, andS16_LE,S32_LE, andFLOAT_LEPCM formats.
Exports the host audio runtime boundary with up to 64 concurrent stream slots (MAX_STREAMS = 64) and automatic backend selection (PipeWire -> ALSA -> software):
-
vodka_audio_init()/vodka_audio_shutdown() -
vodka_audio_backend_kind()(0= software,1= PipeWire,2= ALSA) vodka_audio_backend_version(buf, len)-
vodka_audio_enum_endpoints(flow, out_array, max_count)using C-ABICEndpointInfo - Stream open, start, stop, render write, capture read, and close entry points
-
audio_thunks.zig(libvodka_ntdll.so): Probes PipeWire/ALSA, provides WASAPIIAudioClient/IAudioRenderClientCOM vtables, and resolvesXAudio2Create,DirectSoundCreate, andDirectSoundCreate8directly forxaudio2_9.dllanddsound.dll. -
net_input_thunks.zig(libvodka_ntdll.so): Bridgeswinmm.dllmultimedia timing and audio APIs. -
PE DLLs:
mmdevapi.dll,audioses.dll,dsound.dll,xaudio2_9.dll(plus versioned XAudio2/X3DAudio/XAPOFX modules), andwinmm.dllare cross-compiled forx86_64,i386, andaarch64and verified viavodka_phase5_media_test.exe.
vodka-audio (zig-out/bin/vodka-audio) lets you inspect the host audio stack and verify WASAPI ring-buffer operation from the command line:
# Probe active backend (pipewire / alsa / software), library version, daemon socket, and endpoint count
./zig-out/bin/vodka-audio --probe
# List discovered render and capture audio endpoints with sample rate and channel count
./zig-out/bin/vodka-audio --list
# Run an end-to-end 48kHz stereo f32 440Hz sine-wave WASAPI render & drain self-test
./zig-out/bin/vodka-audio --selftest
# Print version or usage
./zig-out/bin/vodka-audio --version
./zig-out/bin/vodka-audio --helpCopyright (c) 2026 buntatoes. Vodka is a 100% standalone runtime built from scratch and licensed under the Apache License 2.0. The Vodka name, wordmark, and logo are All Rights Reserved.
Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc. DirectX, Windows, AMD, NVIDIA, Intel, and other third-party trademarks belong to their respective owners; Vodka is an independent project and is not affiliated with or endorsed by them.
Core Runtime
Graphics, Display & Audio
Tools & Programs
Platform & Project
Links