Problem
Optical S/PDIF carries only two channels of PCM, so sending 5.1 across it requires compressing the audio to AC-3. Windows does not do this in software, and the sound cards that solve it in hardware are a minority: on the rest, any program playing 5.1 ends up downmixed to stereo the moment the digital output is selected.
Context and constraints
The project spans a kernel-mode driver through to a desktop application, running against real audio hardware and a digital output connected to a receiver.
Architecture
A KMDF/ACX driver exposes a 5.1 render endpoint that Windows materializes as an ordinary device; the driver discards the samples and exists only so that endpoint is real, since one cannot be created from an application. The mix is then captured in user mode through WASAPI loopback, per-channel gain is applied, FFmpeg encodes it to AC-3, the result is framed as IEC 61937, and it is delivered to the digital device in exclusive mode.
Key engineering decisions
- Keep the driver a sink with no processing and capture the audio in user mode, leaving the risky logic outside the kernel.
- Choose the output device by probing which ones accept an IEC 61937 AC-3 carrier rather than trusting enumeration order.
- Record every driver lifecycle status in the Windows registry, because kernel debug output is unusable in unattended runs.
Challenges
- The endpoint enumerated correctly yet could not be opened in shared mode until the real-time stream was implemented and buffer-notification support was declared.
- Holding a stable presentation clock in the driver without blocking the real-time path.
Development approach
Development separated the driver, a reusable bridge engine, and the interface, so the desktop application and the command-line version share a single engine.
Validation and testing
The repository includes unit tests and four runtime gates against the installed driver: device state, endpoint contract, real six-channel playback, and loopback capture comparing per-channel energy against known amplitudes. A device-removal-during-playback test is also included.
Outcome
The result is a working chain between software playing 5.1 and a receiver connected over optical, released as open source. The driver is signed with a test certificate, so it requires Windows test mode.
Technologies
- C++
- Windows Driver Kit
- KMDF
- ACX
- WASAPI
- FFmpeg
- IEC 61937
- Win32
- CMake