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:
2026-07-12 11:52:53 +02:00
parent c684a15fb9
commit 30eccf749d
155 changed files with 3333 additions and 6171 deletions

View File

@@ -22,8 +22,7 @@
using namespace coop;
namespace
{
namespace {
// Directory of this test executable (coop_tone.exe is built alongside it).
std::wstring exe_dir()
@@ -40,19 +39,15 @@ bool wait_for_token(HANDLE pipe, const char* token, DWORD timeout_ms)
{
std::string acc;
const DWORD end = GetTickCount() + timeout_ms;
while (GetTickCount() < end)
{
while (GetTickCount() < end) {
DWORD avail = 0;
if (PeekNamedPipe(pipe, nullptr, 0, nullptr, &avail, nullptr) && avail > 0)
{
if (PeekNamedPipe(pipe, nullptr, 0, nullptr, &avail, nullptr) && avail > 0) {
char buf[256];
DWORD read = 0;
if (ReadFile(pipe, buf, sizeof(buf) - 1, &read, nullptr) && read > 0)
{
if (ReadFile(pipe, buf, sizeof(buf) - 1, &read, nullptr) && read > 0) {
acc.append(buf, read);
std::fwrite(buf, 1, read, stdout);
if (acc.find(token) != std::string::npos)
{
if (acc.find(token) != std::string::npos) {
return true;
}
continue;
@@ -72,8 +67,7 @@ bool capture_one(const WAVEFORMATEX* endpoint_fmt, const std::wstring& tone_args
HANDLE read_pipe = nullptr;
HANDLE write_pipe = nullptr;
SECURITY_ATTRIBUTES sa = {sizeof(sa), nullptr, TRUE};
if (!CreatePipe(&read_pipe, &write_pipe, &sa, 0))
{
if (!CreatePipe(&read_pipe, &write_pipe, &sa, 0)) {
std::printf("FAIL: CreatePipe\n");
return false;
}
@@ -88,8 +82,7 @@ bool capture_one(const WAVEFORMATEX* endpoint_fmt, const std::wstring& tone_args
PROCESS_INFORMATION pi = {};
std::vector<wchar_t> cmd_buf(cmd.begin(), cmd.end());
cmd_buf.push_back(L'\0');
if (!CreateProcessW(nullptr, cmd_buf.data(), nullptr, nullptr, TRUE, 0, nullptr, nullptr, &si, &pi))
{
if (!CreateProcessW(nullptr, cmd_buf.data(), nullptr, nullptr, TRUE, 0, nullptr, nullptr, &si, &pi)) {
std::printf("FAIL: CreateProcess(coop_tone) err=%lu\n", GetLastError());
CloseHandle(read_pipe);
CloseHandle(write_pipe);
@@ -98,12 +91,9 @@ bool capture_one(const WAVEFORMATEX* endpoint_fmt, const std::wstring& tone_args
CloseHandle(write_pipe); // keep only the read end
bool ok = false;
if (!wait_for_token(read_pipe, "TONE_RENDERING", 5000))
{
if (!wait_for_token(read_pipe, "TONE_RENDERING", 5000)) {
std::printf("FAIL: tone generator never started rendering\n");
}
else
{
} else {
ProcessLoopbackCapture capture;
const bool started = capture.start(pi.dwProcessId, endpoint_fmt, nullptr);
std::printf("Capture start: %s, targeting pid %lu\n", started ? "ok" : "FAILED", pi.dwProcessId);
@@ -114,8 +104,7 @@ bool capture_one(const WAVEFORMATEX* endpoint_fmt, const std::wstring& tone_args
// Expect at least ~0.2 s of non-silent audio for a 1.5 s capture.
const unsigned long long need = endpoint_fmt->nSamplesPerSec / 5;
std::printf("Non-silent frames: %llu (need >= %llu)\n", static_cast<unsigned long long>(nonsilent),
need);
std::printf("Non-silent frames: %llu (need >= %llu)\n", static_cast<unsigned long long>(nonsilent), need);
ok = nonsilent >= need;
std::printf("%s\n", ok ? "PASS" : "FAIL: too few non-silent frames");
}
@@ -132,27 +121,23 @@ bool capture_one(const WAVEFORMATEX* endpoint_fmt, const std::wstring& tone_args
int main()
{
if (FAILED(CoInitializeEx(nullptr, COINIT_MULTITHREADED)))
{
if (FAILED(CoInitializeEx(nullptr, COINIT_MULTITHREADED))) {
std::printf("FAIL: CoInitializeEx\n");
return 1;
}
WAVEFORMATEX* fmt = default_render_format();
if (!fmt)
{
if (!fmt) {
std::printf("SKIP: no default render endpoint (no audio device?)\n");
CoUninitialize();
return 0;
}
std::printf("Endpoint format: %u Hz, %u ch, %u-bit\n", fmt->nSamplesPerSec, fmt->nChannels,
fmt->wBitsPerSample);
std::printf("Endpoint format: %u Hz, %u ch, %u-bit\n", fmt->nSamplesPerSec, fmt->nChannels, fmt->wBitsPerSample);
// Each case spawns coop_tone at a different source format; loopback should capture all
// of them correctly because it captures post-mix at the device endpoint format.
// Args: <seconds> <freq> <rate> <channels> <bits> <float|pcm>. ~8 s outlives capture.
struct Case
{
struct Case {
std::wstring args;
const char* label;
};
@@ -164,10 +149,8 @@ int main()
};
int failures = 0;
for (const Case& c : cases)
{
if (!capture_one(fmt, c.args, c.label))
{
for (const Case& c : cases) {
if (!capture_one(fmt, c.args, c.label)) {
++failures;
}
}