diff options
Diffstat (limited to 'src/nomute.c')
-rw-r--r-- | src/nomute.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/nomute.c b/src/nomute.c index 93cfcd2..4e5bcc4 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,18 @@ // 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 "langext.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, @@ -43,7 +45,7 @@ static con_cmdcbv1 snd_restart_cb = 0; // unless we were loaded later with plugin_load in which case we actually do. static bool skiprestart; static void losefocuscb(struct con_var *v) { - if (!skiprestart) snd_restart_cb(); + if_hot (!skiprestart) snd_restart_cb(); skiprestart = false; } @@ -64,14 +66,15 @@ PREINIT { INIT { skiprestart = sst_earlyloaded; // see above IDirectSound *ds_obj = 0; - if (DirectSoundCreate(0, &ds_obj, 0) != DS_OK) { + if_cold (DirectSoundCreate(0, &ds_obj, 0) != DS_OK) { // XXX: can this error be usefully stringified? errmsg_errorx("couldn't create IDirectSound instance"); return false; } ds_vt = ds_obj->lpVtbl; ds_obj->lpVtbl->Release(ds_obj); - if (!os_mprot(&ds_vt->CreateSoundBuffer, sizeof(void *), PAGE_READWRITE)) { + if_cold (!os_mprot(&ds_vt->CreateSoundBuffer, sizeof(void *), + PAGE_READWRITE)) { errmsg_errorsys("couldn't make virtual table writable"); return false; } @@ -80,7 +83,7 @@ INIT { snd_mute_losefocus->base.flags &= ~CON_HIDDEN; struct con_cmd *snd_restart = con_findcmd("snd_restart"); - if (snd_restart) { + if_hot (snd_restart) { snd_restart_cb = con_getcmdcbv1(snd_restart); snd_mute_losefocus->cb = &losefocuscb; } |