Skip to content

Troubleshooting, Loopback Traps & FAQ

Real-world desktop audio capture is full of subtle OS traps that break naive recording scripts in production. Below are the most common symptoms, why they happen at the OS level, and how capture-system-or-process-audio solves them cleanly.


1. Blocking read() Waits or Times Out When Speakers Are Silent

Section titled “1. Blocking read() Waits or Times Out When Speakers Are Silent”

Cause: Unlike physical microphones (which continuously emit ADC thermal noise), Windows WASAPI loopback and per-process taps emit zero packets while no application is actively rendering audio. In legacy PyAudioWPatch / PortAudio wrappers, blocking stream.read(N) hangs indefinitely until a sound plays.

Solution:

  • If you only want active audio bursts, read with timeout_ms and check outcome.reason == PartialReason.TIMEOUT.
  • If you are feeding a continuous wall-clock pipeline (VAD, faster-whisper live window, WebRTC/Discord bot, or recording a timeline where silence must advance time), enable silence_on_idle=True:
import capture_system_or_process_audio as cspa
with cspa.capture(cspa.default_output(), silence_on_idle=True) as stream:
outcome = stream.read(frames=960, timeout_ms=200)
if outcome.mixed_metadata and outcome.mixed_metadata.synthesized_silence:
print("Speaker is idle — received continuous synthesized silence")

2. Microphone + System Audio Slowly Drift Out of Sync

Section titled “2. Microphone + System Audio Slowly Drift Out of Sync”

Cause: A USB microphone and onboard speakers run on two physically independent hardware crystal oscillators (48000.4 Hz vs 47999.7 Hz), accumulating tens of milliseconds of skew over long meetings if naively zipped together.

Solution: Pass both targets into a single capture([microphone(), find_app("Zoom")]) session rather than opening two separate streams! CspaMixer inspects per-packet Stamp.clock_domain tags and applies 64-frame crossfade slip/repeat drift compensation whenever cross-clock drift exceeds drift_threshold_ms (5 ms default).


3. macOS PermissionError or requires_relaunch

Section titled “3. macOS PermissionError or requires_relaunch”
  • Running inside a packaged .app bundle: Verify your Info.plist includes NSMicrophoneUsageDescription (for microphone / input_device) and NSAudioCaptureUsageDescription (for CoreAudio system/process taps). Missing keys return PermissionState::Restricted (PermissionError) to protect your process from macOS TCC SIGABRT.
  • Newly granted ScreenCaptureKit consent (requires_relaunch == true): macOS ScreenRecording TCC grants require restarting the host process before SCShareableContent delivers live app audio buffers. Check report.requires_relaunch after request_permissions(...) and prompt the user to restart your app once.
  • Running over SSH on macOS: macOS TCC requires an active GUI login console (CGSessionCopyCurrentDictionary). Headless SSH sessions without a logged-in desktop session report Restricted.

4. Linux ClientLibraryUnavailable in Minimal Containers

Section titled “4. Linux ClientLibraryUnavailable in Minimal Containers”

Cause: Neither libpipewire-0.3.so.0 (>= 0.3.65) nor libpulse.so.0 (>= 15.0) is installed or running in the container.

Solution: Install pipewire-libs / libpipewire-0.3-0 or pulseaudio-libs / libpulse0 on the target Linux host and ensure XDG_RUNTIME_DIR points to the active user audio session (/run/user/<uid>).


Do end users need to install VB-Cable, BlackHole, or Soundflower?

Section titled “Do end users need to install VB-Cable, BlackHole, or Soundflower?”

No. Every backend uses built-in native OS audio APIs without mutating system default playback devices, so hardware volume keys and headphone auto-pause continue working normally.

Windows WASAPI process loopback (ActivateAudioInterfaceAsync) only supports kernel tree inclusion/exclusion. Rather than silently capturing child processes or broadening to full speaker loopback, Windows rejects Exact with CapabilityError::UnsupportedScope. Use scope="tree" (the default) on Windows.

Does this library work on Free-Threaded Python 3.14t and 3.15t (-Xgil=0)?

Section titled “Does this library work on Free-Threaded Python 3.14t and 3.15t (-Xgil=0)?”

Yes. Prebuilt cp314-cp314t and PEP 803 cp315-abi3.abi3t wheels declare Py_MOD_GIL_NOT_USED (sys._is_gil_enabled() == False), freeze 100% of exported #[pyclass] types, and guard read_into buffer writes with pyo3::sync::critical_section::with_critical_section.

Next, explore the Interactive Studio Demo (cspa-tui-demo) Manual.