Logo home 9

Over 10 years we helping companies reach their financial and branding goals. Onum is a values-driven SEO agency dedicated.

CONTACTS
Platform
STM32MP Linux
Audio
ALSA PCM / USB-C
Latency
<20 ms Target
Status
Delivered
Background

Rebuilding a 4-User Full-Duplex Headset Communication System — From Fragile User-Space Buffers to Kernel-Managed ALSA PCM Routing Under 20 ms

This project redesigned a multi-user voice communication system running on an STM32MP Cortex-A Linux platform supporting two to four simultaneous full-duplex USB Type-C headset connections. The original implementation used software-managed circular buffers to route audio between users — an architecture that worked in ideal conditions but accumulated latency under load, introduced underrun and overrun risks, required complex synchronization logic, and became fragile under stress. The engineering decision was to remove the user-space buffering layer entirely and route audio directly through kernel-managed ALSA PCM endpoints, letting the Linux audio subsystem and DMA engine handle timing with the determinism that only kernel-level scheduling can provide. The result was a stable, low-latency full-duplex communication system validated across six or more hours of continuous operation, rapid USB hot-plug cycles, and high CPU background load — with zero XRUNs in stress testing.

Challenges

Key Project Challenges

1
XRUN Instability Under Concurrent Streams
Running four simultaneous full-duplex PCM streams — capture and playback per headset — introduced underrun and overrun conditions under load. Period size tuning and blocking mode configuration were used to bring XRUN behavior to zero across all stress test scenarios.
2
USB Hot-Plug Reliability
USB Type-C headset removal and reinsertion caused audio stream failures in the original architecture. A udev-based reinitialization flow was implemented to detect device events and cleanly reinitialize the affected ALSA PCM endpoints without disrupting the remaining active streams.
3
Timing Drift Across Multiple PCM Clocks
Each USB audio device maintains its own PCM clock, introducing gradual timing drift between streams over extended sessions. Replacing the original user-space timing loops with kernel PCM clock alignment eliminated accumulated drift and kept all four streams synchronized across hours of continuous operation.
4
Achieving Sub-20 ms Latency Without XRUNs
Minimizing end-to-end latency and eliminating XRUNs are competing objectives — smaller periods reduce latency but increase XRUN risk. Period count and buffer size were tuned iteratively with ftrace kernel tracing and CPU load injection to find the stable low-latency operating point.

Project Details

CategoryEmbedded Linux / USB Audio
Client TypePro Intercom / Industrial
PlatformSTM32MP Cortex-A Linux
Audio StackALSA snd_pcm / DMA
Interface4× USB Type-C Headsets
Latency<20 ms End-to-End
Stress Test6+ Hours, 0 XRUNs
StatusDelivered

Need a Similar System?

We build custom embedded Linux audio pipelines, low-latency communication systems, and USB audio products. Let's talk.

Request a Free Quote →
Solutions

How We Built It

Our Approach

Direct ALSA PCM Routing on STM32MP Linux — Kernel DMA-Managed Streaming, udev Hot-Plug Handling, Period Tuning, and ftrace-Validated Sub-20 ms Full-Duplex Audio

The redesign eliminated the fragile user-space circular buffer layer entirely and replaced it with direct ALSA PCM routing through the Linux snd-usb-audio driver. Each USB Type-C headset enumerates as a USB Audio Class device, exposing independent ALSA capture and playback PCM endpoints. The firmware opens these endpoints directly via the snd_pcm API, configures hardware parameters, and routes audio between users through kernel DMA-managed streams — removing all user-space timing loops and buffer copy overhead. Period size and buffer count were tuned iteratively to achieve sub-20 ms end-to-end latency while maintaining XRUN-free operation under concurrent four-user load. USB hot-plug events are handled by a udev-based reinitialization flow that detects headset removal and reinsertion and cleanly restores the affected PCM stream without impacting other active users. The entire system was validated using aplay/arecord functional testing, alsamixer and /proc/asound inspection, ftrace kernel tracing, CPU load injection with top/htop monitoring, rapid USB unplug/plug cycling, all four users speaking simultaneously, and a six-plus-hour continuous streaming endurance run.

STM32MP Cortex-A Linux ALSA snd_pcm API snd-usb-audio Driver USB Audio Class USB Type-C Headsets Kernel DMA Streaming udev Hot-Plug Handler Period / Buffer Tuning ftrace Kernel Tracing Full-Duplex Audio Low-Latency Audio Embedded Linux
Benefits

Value Delivered

Sub-20 ms End-to-End Latency
Direct ALSA PCM routing with kernel DMA timing achieved the sub-20 ms end-to-end latency target — delivering voice communication quality suitable for professional intercom, aviation, and industrial real-time communication use cases.
Zero XRUNs in Stress Testing
Period size and buffer tuning eliminated all underrun and overrun events across simultaneous four-user operation, high CPU background load injection, and six-plus hours of continuous streaming — proving the architecture is production-stable, not just bench-stable.
Kernel-Level Timing Determinism
Moving audio timing from user-space buffer management to kernel DMA scheduling eliminated the accumulated latency drift and synchronization complexity of the original architecture — making stream behavior predictable and consistent regardless of application-layer load.
Robust USB Hot-Plug Handling
udev-based device monitoring detects headset removal and reinsertion in real time and reinitializes the affected PCM stream cleanly — allowing users to unplug and reconnect without disrupting other active users or requiring a system restart.
No External DSP Required
The entire four-user full-duplex routing pipeline runs within the STM32MP Linux platform using only the built-in USB host controller and standard kernel audio drivers — eliminating the cost and complexity of dedicated external DSP hardware.
6+ Hour Continuous Operation Validated
The system passed a six-plus-hour endurance run with all four users active, combined with rapid USB cycling and CPU stress injection — demonstrating the reliability required for deployment in professional, industrial, and safety-critical communication environments.
Client Feedback

What the Client Said

"

The first version of the system had latency that crept up over time and audio dropouts under load — things that are completely unacceptable for a professional communication device. What changed everything was moving the timing to the kernel instead of trying to manage it in user space. The latency is now flat and consistent regardless of what else the system is doing. We tested it for over six hours straight with all four users active and got zero audio dropouts. The hot-plug handling was a bonus we didn't expect to work as cleanly as it does — headsets reconnect instantly without any reset required.

Need a Similar System?

We build custom embedded Linux audio pipelines, low-latency communication systems, and USB audio products.

Request a Free Quote →