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:
31
host/src/ui/text_match.hpp
Normal file
31
host/src/ui/text_match.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// Small case-insensitive text helpers shared by the host panels' filter boxes, so
|
||||
// "error" matches "ERROR" everywhere consistently. ASCII-fold only (the UI filters
|
||||
// are typed ASCII); non-ASCII bytes compare as-is.
|
||||
#pragma once
|
||||
|
||||
#include <cctype>
|
||||
#include <string>
|
||||
|
||||
namespace coop
|
||||
{
|
||||
|
||||
inline std::string ascii_lower(std::string s)
|
||||
{
|
||||
for (char& c : s)
|
||||
{
|
||||
c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
// True when `needle` is empty or a case-insensitive substring of `haystack`.
|
||||
inline bool contains_ci(const std::string& haystack, const char* needle)
|
||||
{
|
||||
if (needle == nullptr || needle[0] == '\0')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return ascii_lower(haystack).find(ascii_lower(needle)) != std::string::npos;
|
||||
}
|
||||
|
||||
} // namespace coop
|
||||
Reference in New Issue
Block a user