Audio render-hook M2: render hook + in-process self-test (concept proven)
Implements the WASAPI render-hook (hook/src/audio_hook.{hpp,cpp}) and an
in-process self-test that proves COM vtable discovery and GetBuffer/ReleaseBuffer
interception with no game and no second Steam account.
- audio_hook.cpp: anchors on IMMDevice::Activate (idx 3) off our own default
endpoint (shared vtable), then hooks IAudioClient::Initialize (3) /
GetService (14) and IAudioRenderClient::GetBuffer (3) / ReleaseBuffer (4) off
live game pointers. Copies primary-stream frames into the audio ring and
releases with AUDCLNT_BUFFERFLAGS_SILENT (+ memset belt-and-suspenders), only
while the host-owned capture_enabled flag is set. Stream counting runs always;
on a ring overrun it keeps playing locally rather than going silent.
- ipc_client.hpp: publish_audio_stream / note_audio_frames /
set_audio_streams_seen write the render-stream debug fields into HookStatus.
- tests/audio_hook_test.cpp: installs the hooks, renders a tone through WASAPI
in-process, and asserts exactly one stream, frames pushed to the ring, the
ring carries the non-silent tone, and the primary was silenced. PASS:
streams_seen=1, frames_captured=32640.
- plan doc: correct GetService vtable index 13 -> 14 (SetEventHandle is 13).
coop_hook DLL wiring + host consumer/fallback come next (M3).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -34,3 +34,24 @@ target_link_libraries(audio_loopback_test PRIVATE mmdevapi ole32)
|
||||
|
||||
add_dependencies(audio_loopback_test coop_tone)
|
||||
add_test(NAME audio_loopback_test COMMAND audio_loopback_test)
|
||||
|
||||
# In-process self-test for the WASAPI render-hook. Reuses the shipping
|
||||
# audio_hook.cpp and drives a real WASAPI render path in the same process, so it
|
||||
# exercises COM vtable discovery + GetBuffer/ReleaseBuffer interception with no
|
||||
# game and no second Steam account (the audio analogue of hook_selftest).
|
||||
add_executable(audio_hook_test
|
||||
audio_hook_test.cpp
|
||||
${CMAKE_SOURCE_DIR}/hook/src/audio_hook.cpp)
|
||||
|
||||
target_include_directories(audio_hook_test PRIVATE ${CMAKE_SOURCE_DIR}/hook/src)
|
||||
|
||||
# IAudioClient3 / process-audio APIs want the Windows 10 20H1 (NTDDI_WIN10_CO) headers.
|
||||
target_compile_definitions(audio_hook_test PRIVATE NTDDI_VERSION=0x0A00000B)
|
||||
|
||||
target_link_libraries(audio_hook_test PRIVATE
|
||||
coop_common
|
||||
safetyhook::safetyhook
|
||||
ole32
|
||||
mmdevapi)
|
||||
|
||||
add_test(NAME audio_hook_test COMMAND audio_hook_test)
|
||||
|
||||
Reference in New Issue
Block a user