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:
@@ -119,6 +119,35 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// --- Audio render-hook diagnostics -------------------------------------
|
||||
|
||||
// Total distinct render streams the audio hook has observed.
|
||||
void set_audio_streams_seen(std::uint32_t count)
|
||||
{
|
||||
if (block_ != nullptr)
|
||||
{
|
||||
block_->status.audio_streams_seen = count;
|
||||
}
|
||||
}
|
||||
|
||||
// Publish a tracked stream's format/role into its debug slot.
|
||||
void publish_audio_stream(std::uint32_t slot, const AudioStreamInfo& info)
|
||||
{
|
||||
if (block_ != nullptr && slot < kMaxAudioStreams)
|
||||
{
|
||||
block_->status.audio_streams[slot] = info;
|
||||
}
|
||||
}
|
||||
|
||||
// Update a tracked stream's cumulative frame count (host derives live/idle).
|
||||
void note_audio_frames(std::uint32_t slot, std::uint64_t frames)
|
||||
{
|
||||
if (block_ != nullptr && slot < kMaxAudioStreams)
|
||||
{
|
||||
block_->status.audio_streams[slot].frames_rendered = frames;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SharedMemory shm_;
|
||||
SharedBlock* block_ = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user