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

@@ -17,8 +17,7 @@
#include <cstring>
#include <string>
namespace coop
{
namespace coop {
// 'AURG' little-endian; sanity-checks the mapping before either side trusts it.
inline constexpr std::uint32_t kAudioRingMagic = 0x47525541u;
@@ -30,8 +29,7 @@ inline constexpr std::uint32_t kAudioRingVersion = 2;
// fields in the header. The host writes the fields then bumps op_seq; the hook applies
// the command once per new op_seq. Lets the Audio panel re-measure a stream's rate or
// override its format when detection is wrong/unrecoverable.
enum AudioRingOp : std::uint32_t
{
enum AudioRingOp : std::uint32_t {
AudioRingOp_None = 0,
AudioRingOp_Remeasure = 1, // re-run the sample-rate measurement for this stream
AudioRingOp_Override = 2, // adopt the op_rate/channels/bits/format_tag verbatim
@@ -48,8 +46,7 @@ inline constexpr std::uint32_t kAudioRingCapacity = 1u << 20;
// the format fields are written once by the producer *before* it publishes
// format_valid (release), and read by the consumer *after* it observes
// format_valid (acquire), so they need no atomicity of their own.
struct AudioRingHeader
{
struct AudioRingHeader {
std::uint32_t magic;
std::uint32_t version;
@@ -67,7 +64,7 @@ struct AudioRingHeader
std::uint32_t sample_rate;
std::uint32_t channels;
std::uint32_t bits;
std::uint32_t format_tag; // WAVE_FORMAT_* (PCM=1, IEEE_FLOAT=3, EXTENSIBLE=0xFFFE)
std::uint32_t format_tag; // WAVE_FORMAT_* (PCM=1, IEEE_FLOAT=3, EXTENSIBLE=0xFFFE)
std::uint32_t block_align; // bytes per frame (all channels)
std::uint32_t capacity; // bytes in the trailing data region
@@ -176,8 +173,7 @@ inline bool audio_ring_push(AudioRingHeader& h, const void* src, std::uint32_t b
const std::uint64_t w = h.write_pos.load(std::memory_order_relaxed);
const std::uint64_t r = h.read_pos.load(std::memory_order_acquire);
const std::uint32_t used = static_cast<std::uint32_t>(w - r);
if (bytes > h.capacity - used)
{
if (bytes > h.capacity - used) {
h.overruns.fetch_add(1, std::memory_order_relaxed);
return false;
}
@@ -185,8 +181,7 @@ inline bool audio_ring_push(AudioRingHeader& h, const void* src, std::uint32_t b
const std::uint32_t off = static_cast<std::uint32_t>(w % h.capacity);
const std::uint32_t first = std::min(bytes, h.capacity - off);
std::memcpy(data + off, src, first);
if (bytes > first)
{
if (bytes > first) {
std::memcpy(data, static_cast<const std::uint8_t*>(src) + first, bytes - first);
}
h.write_pos.store(w + bytes, std::memory_order_release);
@@ -222,8 +217,7 @@ inline std::uint32_t audio_ring_pop(AudioRingHeader& h, void* dst, std::uint32_t
const std::uint32_t off = static_cast<std::uint32_t>(r % h.capacity);
const std::uint32_t first = std::min(bytes, h.capacity - off);
std::memcpy(dst, data + off, first);
if (bytes > first)
{
if (bytes > first) {
std::memcpy(static_cast<std::uint8_t*>(dst) + first, data, bytes - first);
}
h.read_pos.store(r + bytes, std::memory_order_release);
@@ -234,8 +228,7 @@ inline std::uint32_t audio_ring_pop(AudioRingHeader& h, void* dst, std::uint32_t
// bumps op_seq (release) so the hook applies it exactly once. For a re-measure the
// rate/channels/bits are ignored.
inline void audio_ring_post_op(AudioRingHeader& h, std::uint32_t kind, std::uint32_t rate = 0,
std::uint32_t channels = 0, std::uint32_t bits = 0,
std::uint32_t format_tag = 0)
std::uint32_t channels = 0, std::uint32_t bits = 0, std::uint32_t format_tag = 0)
{
h.op_kind = kind;
h.op_rate = rate;
@@ -246,8 +239,7 @@ inline void audio_ring_post_op(AudioRingHeader& h, std::uint32_t kind, std::uint
}
// One operator command read back by the hook.
struct AudioRingOpCmd
{
struct AudioRingOpCmd {
std::uint32_t kind = AudioRingOp_None;
std::uint32_t rate = 0;
std::uint32_t channels = 0;
@@ -261,8 +253,7 @@ struct AudioRingOpCmd
inline std::uint32_t audio_ring_poll_op(AudioRingHeader& h, std::uint32_t& last_seq, AudioRingOpCmd& out)
{
const std::uint32_t seq = h.op_seq.load(std::memory_order_acquire);
if (seq == last_seq)
{
if (seq == last_seq) {
return AudioRingOp_None;
}
last_seq = seq;
@@ -280,8 +271,7 @@ inline std::uint32_t audio_ring_poll_op(AudioRingHeader& h, std::uint32_t& last_
inline std::wstring audio_ring_name(unsigned long target_pid, unsigned index = 0)
{
std::wstring name = std::wstring(kAudioRingPrefix) + std::to_wstring(target_pid);
if (index != 0)
{
if (index != 0) {
name += L"_" + std::to_wstring(index);
}
return name;