Skip to content

Fix Windows loopback audio decoding for extensible mix formats - #173

Merged
manhpham90vn merged 2 commits into
mainfrom
fix/wasapi-loopback-format
Dec 6, 2026
Merged

manhpham90vn merged 2 commits into
mainfrom
fix/wasapi-loopback-format

Conversation

@manhpham90vn

Copy link
Copy Markdown
Collaborator

Fixes #172.

Windows loopback capture copied only the base WAVEFORMATEX returned by GetMixFormat, then read the extensible subtype beyond that copy. A float32 stream could consequently be decoded as 16-bit PCM and sound like white noise.

Read the subtype from the original allocation and retain the channel count and validated sample type for packet decoding. Reject unsupported sample widths, inconsistent block alignment and truncated extensions before starting capture.

Verification so far is limited to git diff --check. End-to-end confirmation requires playing audio on a Windows host and listening on a Linux client.

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Perf and lag report - pull request vs base commit, same runner, 50% tolerance

  • core_perf: 37 rows · biggest slowdown stream/record-drain-scaling +25.6% · biggest speedup control/video-pacer -12.5% · 0 beyond budget
  • platform_perf: 6 rows · biggest slowdown quic/datagram-delivery +2.1% · biggest speedup quic/handshake +0.0% · 0 beyond budget
  • coverage: core lines 96.52% (min 90.00%) branches 87.54% (min 80.00%)
core_perf drift
=== core performance suite (offline: no network, no GPU) ===
release build only - debug and sanitizer numbers say nothing about production speed
baseline: /home/runner/work/_temp/base-core.txt (37 measurements, tolerance 50%)

workload                               cost per unit           throughput     allocations            vs baseline

--- video ---
video/packetize                               2035 ns/frame      58969.5 MB/s    0.00 alloc/frame       -2.3%
video/packetize-with-fec                      4824 ns/frame      24873.3 MB/s    0.00 alloc/frame       -2.7%
video/reassemble-in-order                     98.8 ns/packet     11796.0 MB/s    1.03 alloc/packet      +0.5%
video/reassemble-out-of-order                101.6 ns/packet     11462.0 MB/s    1.03 alloc/packet      +0.2%
video/reassemble-fec-recovery                615.1 ns/packet      1894.2 MB/s    1.29 alloc/packet      +3.1%
video/plan-nack                               4225 ns/plan                      54.00 alloc/plan        +0.2%
video/downscale-1080p-to-720p              6203945 ns/frame       1337.0 MB/s    0.00 alloc/frame       -0.2%
video/frame-mailbox-handoff                   17.1 ns/frame                      0.00 alloc/frame       -1.2%
video/packetize-scaling                       17.7 ns/KB         4.0x work ->  3.99x time    -0.5%
video/reassemble-scaling                     10139 ns/frame      4.0x work ->  4.00x time    -2.0%

--- transfer ---
transfer/crc32-streamed                     142928 ns/chunk        458.5 MB/s    0.00 alloc/chunk       +0.0%
transfer/send-and-receive                    72996 ns/chunk        223.6 MB/s    0.02 alloc/chunk       +0.0%
transfer/send-and-receive-scaling            72790 ns/chunk      4.0x work ->  3.98x time    -0.3%

--- terminal ---
terminal/vt-parse-plain                      12881 ns/KB            79.5 MB/s    0.00 alloc/KB          -1.8%
terminal/vt-parse-coloured                   10128 ns/KB           101.1 MB/s    0.00 alloc/KB          -4.9%
terminal/screen-write-80x24                  24979 ns/KB            41.0 MB/s    1.22 alloc/KB          -0.9%
terminal/screen-write-200x50                 23434 ns/KB            43.7 MB/s    0.69 alloc/KB          -5.2%
terminal/snapshot-200x50                     16735 ns/snapshot                   1.00 alloc/snapshot    -0.1%
terminal/render-200x50                       59248 ns/render                    10.00 alloc/render      -0.1%
terminal/screen-write-scaling                21957 ns/KB         4.0x work ->  4.99x time    +0.6%
terminal/scrollback-scaling                  22581 ns/KB         4.0x work ->  4.84x time    +1.2%

--- wire, audio and control ---
wire/build-video-packet                       17.7 ns/packet     67820.4 MB/s    0.00 alloc/packet      -2.3%
wire/parse-video-packet                       13.4 ns/packet     89695.6 MB/s    0.00 alloc/packet      +0.0%
wire/build-parse-input-events                 14.3 ns/event       1370.7 MB/s    0.00 alloc/event       -0.9%
audio/jitter-buffer-push-pop                  41.1 ns/frame       1948.1 MB/s    2.00 alloc/frame       +1.6%
transport/retransmit-cache                    50.8 ns/packet     23570.2 MB/s    0.03 alloc/packet      -0.7%
control/video-pacer                          5.730 ns/frame                      0.00 alloc/frame      -12.5%
audio/jitter-buffer-scaling                   35.9 ns/frame      4.0x work ->  4.00x time    +0.4%

--- audio playback ring ---
audio/pcm-ring-put-take                      11472 ns/frame        334.7 MB/s    0.00 alloc/frame       -0.1%
audio/pcm-ring-overflow-drop                  5722 ns/frame        671.1 MB/s    0.00 alloc/frame       -0.1%
audio/pcm-ring-scaling                       11472 ns/frame      4.0x work ->  4.00x time    -0.0%

--- input path (queue -> wire -> apply) ---
input/mouse-move-round-trip                   40.2 ns/event                      0.08 alloc/event       +0.9%
input/key-tap-round-trip                     478.5 ns/tap                        0.00 alloc/tap         -0.1%
input/mouse-move-scaling                      39.5 ns/event      4.0x work ->  3.98x time    -2.1%

--- record stream (terminal + transfer framing) ---
stream/terminal-records-64k                   22.8 ns/record     22534.0 MB/s    0.00 alloc/record      -1.8%
stream/bulk-records-64k                      534.8 ns/record     30640.2 MB/s    0.00 alloc/record      -8.8%
stream/record-drain-scaling                   57.8 ns/KB         4.0x work ->  3.98x time   +25.6%

=== PASS: 37 measurements within budget ===
platform_perf drift
=== platform performance suite (loopback sockets, real QUIC) ===
release build only - debug and sanitizer numbers say nothing about production speed
baseline: /home/runner/work/_temp/base-platform.txt (6 measurements, tolerance 50%)

workload                               cost per unit           throughput     allocations            vs baseline

--- quic over loopback ---
quic/handshake                            20635119 ns/handshake                  82.00 alloc/handshake    -0.0%
quic/terminal-record-delivery                19586 ns/record        26.1 MB/s    9.00 alloc/record      +1.4%
quic/stream-throughput-64k                    6861 ns/KB           149.2 MB/s    1.17 alloc/KB          +1.2%
quic/datagram-delivery                        8788 ns/datagram     136.5 MB/s    1.44 alloc/datagram    +2.1%
quic/poll-idle                             1060701 ns/poll                       3.00 alloc/poll        +0.0%
quic/stream-drain-scaling                     7006 ns/KB         4.0x work ->  1.19x time    +1.4%

=== PASS: 6 measurements within budget ===
lag under cross-load (this pull request only)
[load] a 32 MB upload rides alongside the video without stalling it...
        idle 27.9 fps (worst gap 20 ms) -> busy 28.6 fps (worst gap 40 ms), 32 MB in 1745 ms, deepest file lane 0
[load] keystrokes still reach the host with an upload in flight...
        five events injected 4 ms after they were queued
[load] audio keeps arriving with an upload in flight...
[load] skipped: this machine opened no audio output device
[lag] a terminal flood rides alongside the video without stalling it...
        flood moved 1342573 terminal bytes/redraws, video 27.9 -> 27.8 fps, worst video gap 20 ms, worst terminal gap 0 ms
[lag] a keystroke's echo crosses a bulk-flooded link promptly...
        the shell answered 4 ms after the keystrokes

@manhpham90vn
manhpham90vn merged commit 76e16f4 into main Dec 6, 2026
43 checks passed
@manhpham90vn
manhpham90vn deleted the fix/wasapi-loopback-format branch December 6, 2026 06:23
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.

[BUG] Audio from windows to linux is broken

1 participant