The live indicator compared frames_rendered to the previous UI frame's value, but audio buffers release in bursts so most frames saw no change -- the cell flickered between a green dot and grey "idle". Now each stream remembers when it last advanced and reads "live" for a short window (0.4 s) afterwards, with a ~2 Hz frames/s estimate next to it; otherwise "idle". Steady and readable for multi-stream games. Verified: x64 build green. Full visual confirmation needs an injected, audio-playing game with the per-stream table open (Debug details); logic reviewed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
// Owns the audio-mirror pipeline (render-hook ring or WASAPI process loopback +
|
|
// re-render) and its UI. The target process is derived from the injected game's
|
|
// window; the render-stream debug view reads the hook's diagnostics back-channel.
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include <windows.h>
|
|
|
|
#include "audio/audio_loopback.hpp"
|
|
#include "ipc/ipc_server.hpp"
|
|
|
|
namespace coop
|
|
{
|
|
|
|
class AudioPanel
|
|
{
|
|
public:
|
|
// The window whose process audio to mirror (0 if none); typically the
|
|
// injected game's HWND.
|
|
void set_target(HWND target)
|
|
{
|
|
target_ = target;
|
|
}
|
|
|
|
// `status` is the hook's back-channel, for the render-stream view. With
|
|
// `debug_details` on, the per-stream table is shown.
|
|
void draw_ui(const HookStatusView& status, bool debug_details);
|
|
|
|
private:
|
|
HWND target_ = nullptr;
|
|
bool enabled_ = false;
|
|
AudioMirror mirror_;
|
|
|
|
// Per-stream activity tracking for the "live" column. Audio buffers release in
|
|
// bursts, so most UI frames see no change; comparing to just the previous frame
|
|
// flickers. Instead we remember when each stream last advanced and debounce the
|
|
// live/idle indicator over a short window, plus a ~2 Hz frames/s estimate.
|
|
std::uint64_t prev_frames_[kMaxAudioStreams] = {};
|
|
double last_active_[kMaxAudioStreams] = {}; // ImGui time a stream last advanced
|
|
std::uint64_t rate_base_frames_[kMaxAudioStreams] = {};
|
|
double frames_per_s_[kMaxAudioStreams] = {};
|
|
double rate_base_time_ = 0.0;
|
|
};
|
|
|
|
} // namespace coop
|