Apply clang-format across the whole tree
Run clang-format (the repo's .clang-format: LLVM base, 120 cols, tabs, Allman functions) over every source file so the tree is formatter-clean. Whitespace only -- no behavior change; full x64 + x86 suites pass. Also set SortIncludes: false in .clang-format. Windows include order is load-bearing (windows.h must precede tlhelp32.h / mmreg.h / xinput.h / dinput.h; winsock2.h must precede windows.h), and the default alphabetical sort reorders tlhelp32.h ahead of windows.h -- a build break. Leaving order alone keeps the manual, correct grouping.
This commit is contained in:
@@ -13,18 +13,14 @@
|
||||
|
||||
using namespace coop::hook;
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace {
|
||||
int g_failures = 0;
|
||||
void check(bool ok, const char* what)
|
||||
{
|
||||
if (!ok)
|
||||
{
|
||||
if (!ok) {
|
||||
std::printf("FAIL: %s\n", what);
|
||||
++g_failures;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
std::printf(" ok: %s\n", what);
|
||||
}
|
||||
}
|
||||
@@ -32,8 +28,7 @@ void check(bool ok, const char* what)
|
||||
// Drives an estimator with a controllable QPC clock. One feed per "window" (we use a
|
||||
// 0.5 s step that matches the estimator's window, so each feed after the first completes
|
||||
// exactly one window -- making each window's frame count individually controllable).
|
||||
struct Sim
|
||||
{
|
||||
struct Sim {
|
||||
RateEstimator est;
|
||||
static constexpr std::int64_t kFreq = 1'000'000; // 1 MHz (microseconds)
|
||||
std::int64_t qpc = 0;
|
||||
@@ -53,11 +48,9 @@ RateEstimate run_steady(double rate, int max = 40)
|
||||
{
|
||||
Sim s;
|
||||
RateEstimate r;
|
||||
for (int i = 0; i < max; ++i)
|
||||
{
|
||||
for (int i = 0; i < max; ++i) {
|
||||
r = s.window(rate);
|
||||
if (r.done)
|
||||
{
|
||||
if (r.done) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@@ -78,13 +71,10 @@ int main()
|
||||
check(snap_standard_rate(45000.0) == 0, "45000 (non-standard) snaps to nothing");
|
||||
|
||||
// --- steady standard rates converge, confidently -----------------------------
|
||||
for (double rate : {44100.0, 48000.0, 96000.0, 22050.0})
|
||||
{
|
||||
for (double rate : {44100.0, 48000.0, 96000.0, 22050.0}) {
|
||||
const RateEstimate r = run_steady(rate);
|
||||
check(r.done && r.confident && r.rate == static_cast<std::uint32_t>(rate),
|
||||
"steady rate converges confidently");
|
||||
if (!(r.done && r.rate == static_cast<std::uint32_t>(rate)))
|
||||
{
|
||||
check(r.done && r.confident && r.rate == static_cast<std::uint32_t>(rate), "steady rate converges confidently");
|
||||
if (!(r.done && r.rate == static_cast<std::uint32_t>(rate))) {
|
||||
std::printf(" (rate=%.0f -> done=%d confident=%d got=%u)\n", rate, r.done, r.confident, r.rate);
|
||||
}
|
||||
}
|
||||
@@ -94,8 +84,7 @@ int main()
|
||||
Sim s;
|
||||
RateEstimate r;
|
||||
const double wobble[] = {+150.0, -120.0, +90.0, -150.0, +60.0, -90.0, +130.0, -40.0};
|
||||
for (int i = 0; i < 30 && !r.done; ++i)
|
||||
{
|
||||
for (int i = 0; i < 30 && !r.done; ++i) {
|
||||
r = s.window(44100.0, wobble[i % 8]); // ~0.3% jitter, within the snap band
|
||||
}
|
||||
check(r.done && r.confident && r.rate == 44100, "44100 with small jitter -> 44100 confident");
|
||||
@@ -112,8 +101,7 @@ int main()
|
||||
check(!burst.done, "single burst window does not commit");
|
||||
// windows 3..N: clean 44100 -> consensus on 44100.
|
||||
RateEstimate r = burst;
|
||||
for (int i = 0; i < 10 && !r.done; ++i)
|
||||
{
|
||||
for (int i = 0; i < 10 && !r.done; ++i) {
|
||||
r = s.window(44100.0);
|
||||
}
|
||||
check(r.done && r.confident && r.rate == 44100, "burst rejected; converges to 44100, not 48000");
|
||||
@@ -124,8 +112,7 @@ int main()
|
||||
const RateEstimate r = run_steady(45000.0, 40);
|
||||
check(r.done && !r.confident, "non-standard 45000 -> done but LOW-confidence");
|
||||
check(r.rate >= 44600 && r.rate <= 45400, "low-confidence estimate is ~45000");
|
||||
if (r.done)
|
||||
{
|
||||
if (r.done) {
|
||||
std::printf(" (45000 -> confident=%d rate=%u)\n", r.confident, r.rate);
|
||||
}
|
||||
}
|
||||
@@ -134,20 +121,17 @@ int main()
|
||||
{
|
||||
Sim s;
|
||||
RateEstimate r;
|
||||
for (int i = 0; i < 6; ++i)
|
||||
{
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
r = s.window(0.0); // silent: no frames advance
|
||||
check(!r.done, "idle window never commits");
|
||||
}
|
||||
for (int i = 0; i < 12 && !r.done; ++i)
|
||||
{
|
||||
for (int i = 0; i < 12 && !r.done; ++i) {
|
||||
r = s.window(48000.0); // audio resumes
|
||||
}
|
||||
check(r.done && r.confident && r.rate == 48000, "after idle, real audio converges to 48000");
|
||||
}
|
||||
|
||||
if (g_failures == 0)
|
||||
{
|
||||
if (g_failures == 0) {
|
||||
std::printf("PASS rate_estimator_test\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user