summaryrefslogtreecommitdiffhomepage
path: root/src/nomute.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2024-08-03 16:11:57 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2024-08-22 00:01:06 +0100
commit44902cb49cd51e2bb2f1cef05cb3c0e799b83434 (patch)
treeb64af413b10c32173aa535df22b5ee4162eb0290 /src/nomute.c
parent01ec55edd9f767bebb1222c88f0e53e9cf8b2d59 (diff)
Rework OS abstractions
- As much as possible avoid dragging system headers into translation units. This should avoid namespace pollution and, hopefully, speed up builds a little bit. - Avoid leaning on the UCRT so much on Windows - prefer native win32 calls and native file handles except where doing so is inconvenient (in particular, for stat(), which we might try and replace later). - Also, switch from SystemFunction036 to ProcessPrng on Windows. This requires us to generate a stub for bcryptprimitives.dll because Microsoft haven't bothered to provide a link library, but the function is better-documented and seems to be a more direct under-the-hood call as well. Apparently it's what's used by the major web browsers these days, which seems like a good indication it's stable and trusted. - Lastly, remove a bunch of functions and macros and stuff that weren't actually being used. It seems good to try and keep the scope of OS-dependent stuff relatively contained and only add to it when actually required.
Diffstat (limited to 'src/nomute.c')
-rw-r--r--src/nomute.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/nomute.c b/src/nomute.c
index 93cfcd2..6a42d46 100644
--- a/src/nomute.c
+++ b/src/nomute.c
@@ -1,6 +1,6 @@
/*
* Copyright © 2023 Willian Henrique <wsimanbrazil@yahoo.com.br>
- * Copyright © 2023 Michael Smith <mikesmiffy128@gmail.com>
+ * Copyright © 2024 Michael Smith <mikesmiffy128@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -18,16 +18,17 @@
// TODO(linux): this is currently only built on Windows, but a linux
// implementation would be also useful for some games e.g. L4D2
+// NOTE: all three of these headers must be in this order. annoyingly.
+#include <Windows.h>
+#include <mmeapi.h>
+#include <dsound.h>
+
#include "con_.h"
#include "errmsg.h"
#include "feature.h"
#include "os.h"
#include "sst.h"
-// these have to come after Windows.h (via os.h) and in this order
-#include <mmeapi.h>
-#include <dsound.h>
-
FEATURE("inactive window audio control")
DEF_CVAR_UNREG(snd_mute_losefocus,