Deduplicate the host audio/UI code and scrub history from comments

Extract a RAII RenderEndpoint that owns the enumerator/endpoint/client/
render-event/buffer for both AudioMirror::run_hooked and run_loopback,
replacing two hand-rolled setup+teardown blocks and their two identical
fail lambdas with one set_error helper; every COM object now frees on
each exit path automatically.

Route audio_format_verifier's mono decode through the shared
correlate_detail::decode_layout instead of a second copy, and read the
debug env var via GetEnvironmentVariableA (drops the getenv C4996).

Fold the near-identical read_frame/read_pixel staging-copy setup in
SharedTextureSource into one map_staging_copy, and the three separate
case-insensitive filter helpers (log/injection panels) into
ui/text_match.hpp.

Comments: drop game-name anecdotes and "the old code"/version phrasing;
genericize the override-file example; fix a stale heartbeat-interval
note. Behavior unchanged (host tests + mock_game_test pass).
This commit is contained in:
2026-07-12 09:07:53 +02:00
parent 635ef51283
commit 4636f4bb64
13 changed files with 217 additions and 292 deletions

View File

@@ -1,37 +1,16 @@
#include "log_panel.hpp"
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <string>
#include "imgui.h"
#include "injection_panel.hpp"
#include "ui/app_chrome.hpp"
#include "ui/text_match.hpp"
namespace coop
{
namespace
{
// Case-insensitive substring test, so the log filter matches regardless of case (consistent with the
// rest of the app, where "error" should find "ERROR").
bool icontains(const std::string& hay, const char* needle)
{
if (needle == nullptr || needle[0] == '\0')
{
return true;
}
auto lower = [](std::string s) {
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return static_cast<char>(std::tolower(c)); });
return s;
};
return lower(hay).find(lower(needle)) != std::string::npos;
}
} // namespace
void LogPanel::add_line(const LogRecord& rec)
{
if (first_millis_ == 0)
@@ -76,7 +55,7 @@ void LogPanel::draw()
const bool has_filter = filter_[0] != '\0';
for (const Line& line : lines_)
{
if (has_filter && !icontains(line.text, filter_))
if (has_filter && !contains_ci(line.text, filter_))
{
continue;
}