shithub: qk1

Download patch

ref: b38051957d8593b10be976935aa13354113bba64
parent: 6d2e17708cebe8da6d30db3a992beb7ce9a87cf2
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sun Dec 24 13:06:42 EST 2023

openal: add "soundlist" cmd

--- a/unix/snd_openal.c
+++ b/unix/snd_openal.c
@@ -515,6 +515,26 @@
 	}
 }
 
+static void
+sfxlist(void)
+{
+	int sz, sum, w, ch;
+	Sfx *sfx, *e;
+	alsfx_t *s;
+
+	sum = 0;
+	for(sfx = known_sfx, e = known_sfx+num_sfx; sfx < e; sfx++){
+		if((s = Cache_Check(&sfx->cu)) == nil)
+			continue;
+		alGetBufferi(s->buf, AL_SIZE, &sz); ALERR();
+		alGetBufferi(s->buf, AL_CHANNELS, &ch); ALERR();
+		alGetBufferi(s->buf, AL_BITS, &w); ALERR();
+		sum += sz * ch * w/8;
+		Con_Printf("%c(%2db) %6d : %s\n", s->loop ? 'L' : ' ', w, sz, sfx->s);
+	}
+	Con_Printf("Total resident: %d\n", sum);
+}
+
 void
 sfxbegin(void)
 {
@@ -534,6 +554,7 @@
 	Cvar_RegisterVariable(&s_al_resampler_up);
 	Cvar_RegisterVariable(&s_al_hrtf);
 	Cmd_AddCommand("stopsound", stopallsfx);
+	Cmd_AddCommand("soundlist", sfxlist);
 
 	alinit(nil);
 	known_sfx = Hunk_Alloc(MAX_SOUNDS * sizeof *known_sfx);