Platform-Specific Audio Capture in Meetily: WASAPI, ScreenCaptureKit, and ALSA Implementation

Meetily implements platform-specific audio capture through a modular Rust architecture that abstracts WASAPI on Windows, Screen Capture Kit on macOS, and ALSA/PulseAudio on Linux into a unified cross-platform API.

Meetily's audio subsystem relies on a sophisticated abstraction layer written in Rust to handle native audio APIs across operating systems. The implementation delegates platform-specific operations to dedicated modules while exposing a uniform interface for device enumeration and stream configuration. This design ensures low-latency audio capture for the application's local transcription pipeline regardless of the underlying operating system.

Modular Architecture and Conditional Compilation

The audio device layer centers on cpal (Cross-Platform Audio Library) to minimize platform-specific code. Platform implementations reside in frontend/src-tauri/src/audio/devices/platform/ and are conditionally compiled via platform/mod.rs based on target_os flags. The core entry point list_audio_devices() in discovery.rs instantiates a cpal::Host and delegates to the appropriate platform helper.

Windows Audio Capture with WASAPI

On Windows, Meetily utilizes the Windows Audio Session API (WASAPI) for professional-grade low-latency capture.

Device Enumeration and Loopback Configuration

The configure_windows_audio() function in platform/windows.rs enumerates input and output devices through the WASAPI host. It distinguishes between microphone inputs and system audio outputs using WASAPI's loopback capabilities. When a user selects a device, get_windows_device() resolves the selection to a cpal::Device and selects a compatible SupportedStreamConfig.

use crate::audio::devices::platform::get_windows_device;
use crate::audio::devices::configuration::AudioDevice;

fn open_windows_device(selected: &AudioDevice) -> anyhow::Result<(cpal::Device, cpal::SupportedStreamConfig)> {
    // Resolve the CPAL device and a compatible config
    get_windows_device(selected)
}

macOS Audio Capture with Screen Capture Kit

macOS implementation combines Screen Capture Kit for system audio and CoreAudio for microphone input.

System Audio vs. Microphone Handling

The configure_macos_audio() function in platform/macos.rs uses the default CPAL host to enumerate microphone inputs while filtering built-in speakers from the output list. For system audio capture, it leverages Screen Capture Kit's capabilities to capture application audio without requiring kernel extensions. This approach complies with macOS privacy requirements while maintaining high-quality audio streams.

Linux Audio Capture with ALSA and PulseAudio

Linux support utilizes ALSA (Advanced Linux Sound Architecture) as the base layer with PulseAudio extensions for modern desktop environments.

Monitor Sources for System Audio

The configure_linux_audio() function in platform/linux.rs gathers microphone inputs via the default host and appends PulseAudio monitor sources to the device list. Monitor sources—identified by the "monitor" keyword in their names—represent system audio outputs that can be captured as inputs, enabling application audio recording alongside microphone input.

// In a Tauri command or any async context
use crate::audio::devices::discovery::list_audio_devices;

#[tauri::command]
async fn get_available_devices() -> Result<Vec<AudioDevice>, String> {
    list_audio_devices()
        .await
        .map_err(|e| format!("Failed to list audio devices: {}", e))
}

Permission Handling and Pipeline Integration

Before capture begins, Meetily handles platform-specific permission requirements through trigger_audio_permission() in discovery.rs. On macOS and Windows, this function constructs a short-lived input stream to provoke the operating system's permission dialog without starting actual recording.

Once permissions are granted, the pipeline.rs module receives raw audio chunks from the selected devices. It applies Voice Activity Detection (VAD) filtering, mixes microphone and system audio streams, and forwards the processed audio to the Whisper transcription engine using a standardized interface.

let device = /* obtained from platform helper */;
let config = /* chosen SupportedStreamConfig */;

let stream = device.build_input_stream(
    &config.clone().into(),
    move |data: &[f32], _: &cpal::InputCallbackInfo| {
        // Forward raw PCM to the pipeline for mixing/VAD
        audio_pipeline.process_mic_chunk(data);
    },
    |err| eprintln!("Audio stream error: {}", err),
    None,
)?;
stream.play()?; // Begins capturing

Summary

  • Meetily abstracts Windows WASAPI, macOS Screen Capture Kit, and Linux ALSA/PulseAudio through a unified Rust interface in frontend/src-tauri/src/audio/devices/.
  • The discovery.rs module provides the public API via list_audio_devices() and trigger_audio_permission() functions.
  • Platform-specific implementations in platform/windows.rs, platform/macos.rs, and platform/linux.rs handle native API quirks while returning standard cpal::Device objects.
  • Windows utilizes WASAPI loopback for system audio, macOS combines Screen Capture Kit with CoreAudio, and Linux leverages PulseAudio monitor sources.
  • The pipeline.rs module consumes standardized audio streams for Voice Activity Detection and Whisper transcription regardless of the source platform.

Frequently Asked Questions

How does Meetily handle system audio capture differently on each platform?

On Windows, Meetily uses WASAPI loopback devices to capture system audio alongside microphone inputs. macOS implements Screen Capture Kit to record application audio without kernel extensions, while Linux utilizes PulseAudio monitor sources identified by the "monitor" keyword to tap into system audio outputs.

What is the role of the cpal crate in Meetily's audio architecture?

The cpal crate provides the cross-platform foundation that abstracts host-specific audio APIs into a consistent Rust interface. Meetily's platform modules only need to handle OS-specific quirks like WASAPI loopback or PulseAudio monitors, while the higher-level pipeline.rs and recording logic remain portable across all supported operating systems.

How does Meetily request audio permissions on macOS and Windows?

The trigger_audio_permission() function in discovery.rs creates a temporary input stream to trigger the operating system's native permission dialog. This approach ensures compliance with macOS and Windows privacy requirements before the actual transcription pipeline begins capturing audio.

Where are the platform-specific audio implementations located in the Meetily repository?

Platform-specific code resides in frontend/src-tauri/src/audio/devices/platform/, with windows.rs handling WASAPI, macos.rs implementing Screen Capture Kit and CoreAudio, and linux.rs managing ALSA and PulseAudio integration. These modules are conditionally compiled through platform/mod.rs based on the target operating system.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →