Skip to content

windows: add LHDC V5/aptX sink and low-latency audio path - #743

Open
Loukious wants to merge 3 commits into
bluekitchen:masterfrom
Loukious:windows-lhdcv5-sink
Open

windows: add LHDC V5/aptX sink and low-latency audio path#743
Loukious wants to merge 3 commits into
bluekitchen:masterfrom
Loukious:windows-lhdcv5-sink

Conversation

@Loukious

@Loukious Loukious commented Aug 9, 2026

Copy link
Copy Markdown

Summary

Adds a Windows WinUSB A2DP sink demo with SBC, LHDC V5, and optional aptX Classic/aptX HD decoding, together with the PortAudio changes needed for stable low-latency playback at high sample rates.

Highlights

  • LHDC V5: 44.1/48/96/192 kHz, 16/24-bit stereo
  • aptX Classic + aptX HD: 44.1/48 kHz stereo
  • aptX endpoints are advertised only when an external openaptx0.dll decoder backend is available; no aptX decoder code/binary is bundled
  • fixes Android aptX Classic media handling (no RTP header when SCMS-T is not enabled)
  • decodes aptX/aptX HD one codec block at a time
  • handles the observed LHDC V5 192 kHz transport layout with two [tag, sequence] subpacket prefixes per 20 ms A2DP payload
  • aptX keeps its 40/48 ms PCM target/high-water limiter
  • LHDC does not discard decoded PCM for latency control; testing showed queue trimming can cause audible hitches, especially around packet-burst boundaries
  • PortAudio staging scales with sample rate (128 @ 48 kHz, 256 @ 96 kHz, 512 @ 192 kHz) to preserve a similar callback period
  • Windows WASAPI shared-mode auto-convert fallback for rates rejected by the active Windows mix format; no exclusive-mode device takeover
  • monotonic PortAudio producer/consumer counters prevent stale staging buffers from growing latency indefinitely

Validation

Tested on Windows 11 with an Intel Bluetooth controller and an Android 16 Xiaomi onyx source:

  • SBC playback
  • aptX Classic playback and repeated aptX <-> aptX HD switching
  • LHDC V5 playback at 44.1, 48, 96 and 192 kHz
  • 44.1 kHz capture replay: 5,628 LHDC frames decoded, 0 bad frames
  • 192 kHz capture: 6,574 A2DP packets / 26,296 LHDC frames; after stripping the two transport subpacket prefixes, decoder replay completed with 26,296 good frames and 0 bad frames
  • sustained 192 kHz playback is clean with the parser fix and without destructive LHDC PCM trimming

The external aptX backend is intentionally not included because libopenaptx is GPLv3; the sink omits aptX endpoints when the DLL is unavailable.

@Loukious Loukious changed the title windows: add LHDC V5 sink and low-latency audio path windows: add LHDC V5/aptX sink and low-latency audio path Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant