From: Reki Date: Thu, 27 May 2021 11:20:06 +0000 (-0400) Subject: Added snd_streaming_ignoremusic X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=22184100320ea6e2810dfe2e65f313e1411236e3;p=xonotic%2Fdarkplaces.git Added snd_streaming_ignoremusic --- diff --git a/snd_main.c b/snd_main.c index 94d9b23d..e57b519a 100644 --- a/snd_main.c +++ b/snd_main.c @@ -185,6 +185,7 @@ cvar_t snd_spatialization_occlusion = {CF_CLIENT | CF_ARCHIVE, "snd_spatializati // Cvars declared in snd_main.h (shared with other snd_*.c files) cvar_t _snd_mixahead = {CF_CLIENT | CF_ARCHIVE, "_snd_mixahead", "0.15", "how much sound to mix ahead of time"}; cvar_t snd_streaming = {CF_CLIENT | CF_ARCHIVE, "snd_streaming", "1", "enables keeping compressed ogg sound files compressed, decompressing them only as needed, otherwise they will be decompressed completely at load (may use a lot of memory); when set to 2, streaming is performed even if this would waste memory"}; +cvar_t snd_streaming_ignoremusic = {CF_CLIENT | CF_ARCHIVE, "snd_streaming_ignoremusic", "1", "forces streaming off for music tracks"}; cvar_t snd_streaming_length = {CF_CLIENT | CF_ARCHIVE, "snd_streaming_length", "1", "decompress sounds completely if they are less than this play time when snd_streaming is 1"}; cvar_t snd_swapstereo = {CF_CLIENT | CF_ARCHIVE, "snd_swapstereo", "0", "swaps left/right speakers for old ISA soundblaster cards"}; extern cvar_t v_flipped; @@ -803,6 +804,7 @@ void S_Init(void) Cvar_RegisterVariable(&snd_precache); Cvar_RegisterVariable(&snd_initialized); Cvar_RegisterVariable(&snd_streaming); + Cvar_RegisterVariable(&snd_streaming_ignoremusic); Cvar_RegisterVariable(&snd_streaming_length); Cvar_RegisterVariable(&ambient_level); Cvar_RegisterVariable(&ambient_fade); diff --git a/snd_main.h b/snd_main.h index ff5e43f1..bf8dca6e 100644 --- a/snd_main.h +++ b/snd_main.h @@ -128,6 +128,7 @@ extern qbool snd_usethreadedmixing; // if true, the main thread does not mix sou extern struct cvar_s _snd_mixahead; extern struct cvar_s snd_swapstereo; extern struct cvar_s snd_streaming; +extern struct cvar_s snd_streaming_ignoremusic; extern struct cvar_s snd_streaming_length; #define SND_CHANNELLAYOUT_AUTO 0 diff --git a/snd_ogg.c b/snd_ogg.c index c1d8b96c..2afbb5a4 100644 --- a/snd_ogg.c +++ b/snd_ogg.c @@ -604,6 +604,7 @@ qbool OGG_LoadVorbisFile(const char *filename, sfx_t *sfx) vorbis_info *vi; vorbis_comment *vc; double peak, gaindb; + int shouldStream; #ifndef LINK_TO_LIBVORBIS if (!vf_dll) @@ -649,8 +650,21 @@ qbool OGG_LoadVorbisFile(const char *filename, sfx_t *sfx) sfx->format.width = 2; // We always work with 16 bits samples sfx->total_length = qov_pcm_total(&vf, -1); + + shouldStream = FALSE; + + //Con_Print("Sound effect (ogg) loaded\n"); if (snd_streaming.integer && (snd_streaming.integer >= 2 || sfx->total_length > max(sizeof(ogg_stream_perchannel_t), snd_streaming_length.value * sfx->format.speed))) + { + if (!(snd_streaming_ignoremusic.integer && (strncmp(filename, "sound/cdtracks/", 15) == 0 || strncmp(filename, "sound/music/", 12) == 0))) + { + shouldStream = TRUE; + } + } + + + if (shouldStream) { // large sounds use the OGG fetcher to decode the file on demand (but the entire file is held in memory) ogg_stream_persfx_t* per_sfx;