Commit 4d1a0cc
committed
fix(wgc): repair the four things the GPU path got wrong under review
Four defects CodeRabbit surfaced on #305, each verified against the code
before being touched. One of them is worse than it was reported to be.
**AcquireSync was tested with the wrong predicate, in both directions.**
IDXGIKeyedMutex::AcquireSync reports a timeout as WAIT_TIMEOUT (0x102),
a positive HRESULT that passes both SUCCEEDED() and !FAILED(). The capture
side tested FAILED(), so a timeout fell straight through to CopyResource
without ever holding the key, and only hard errors -- device removed,
E_FAIL, WAIT_ABANDONED -- were caught, then misreported as ordinary
contention, which skips the frame and retries forever on a bridge that can
never work again. The encoder side used succeeded(), so a timeout there read
as acquired. Both now test WAIT_TIMEOUT by value.
This also means the "Contended frames: 0" figure in the PR description was
measured with a counter that could not count: a timeout never reached it.
The number says nothing either way and is being remeasured.
**Inline webcam PiP would have silently lost its overlay.** useDxgiInput
read webcamActive, which is only set once webcam capture starts -- long
after the encoder is configured. The condition was therefore dead: always
false, always permitting the GPU path. A webcamEnabled recording with no
separate output would have run on DXGI, which cannot compose the overlay,
and reported success. It now reads config.webcamEnabled, which is final at
that point.
**The stop breadcrumb named the wrong call.** encodeStage_ was stamped
before writerMutex_ was taken, so a video thread queued behind an audio
write reported "write-sample" while it was in fact blocked on the lock --
precisely the case the watchdog exists to distinguish, since an audio write
is the only other thing that takes that mutex. It is now stamped inside the
lock, and writeAudio names its own write instead of being anonymous. Both
stamps are serialized by the mutex they sit under.
**finalize() left Media Foundation objects for the destructor.**
videoSampleAllocator_ and dxgiDeviceManager_ outlived MFShutdown(), and
captureDevice_/captureContext_ kept the WGC device alive past the point
main.cpp believes session.stop() releases it. finalize() now calls
releaseDxgiPipeline() and drops the capture device before MFShutdown().
Not addressed here: bridge-texture creation still happens on the first
frame, so a driver that refuses shared keyed-mutex textures fails the
recording rather than degrading, which contradicts what three documents
claim. That one is a restructure with a real trade-off attached and is
being decided separately.
Compile-verified in CI only; no hardware smoke test on this machine.1 parent 976d44d commit 4d1a0cc
2 files changed
Lines changed: 60 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
615 | 623 | | |
616 | 624 | | |
617 | | - | |
| 625 | + | |
618 | 626 | | |
619 | 627 | | |
620 | 628 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1029 | 1029 | | |
1030 | 1030 | | |
1031 | 1031 | | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
1032 | 1041 | | |
1033 | | - | |
| 1042 | + | |
| 1043 | + | |
1034 | 1044 | | |
1035 | 1045 | | |
1036 | 1046 | | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
1037 | 1051 | | |
1038 | 1052 | | |
1039 | 1053 | | |
| |||
1043 | 1057 | | |
1044 | 1058 | | |
1045 | 1059 | | |
1046 | | - | |
1047 | | - | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
1048 | 1071 | | |
1049 | 1072 | | |
1050 | 1073 | | |
| |||
1268 | 1291 | | |
1269 | 1292 | | |
1270 | 1293 | | |
1271 | | - | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
1272 | 1299 | | |
1273 | 1300 | | |
1274 | | - | |
1275 | 1301 | | |
1276 | 1302 | | |
| 1303 | + | |
1277 | 1304 | | |
1278 | 1305 | | |
1279 | 1306 | | |
| |||
1317 | 1344 | | |
1318 | 1345 | | |
1319 | 1346 | | |
1320 | | - | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
1321 | 1355 | | |
1322 | 1356 | | |
1323 | 1357 | | |
| |||
1333 | 1367 | | |
1334 | 1368 | | |
1335 | 1369 | | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
1336 | 1381 | | |
1337 | 1382 | | |
1338 | 1383 | | |
| |||
0 commit comments