diff --git a/src/cvars.cpp b/src/cvars.cpp index 48188f978..bc247a3d4 100644 --- a/src/cvars.cpp +++ b/src/cvars.cpp @@ -318,6 +318,7 @@ void Captioning_OnChange(void); consvar_t cv_closedcaptioning = Player("closedcaptioning", "Off").on_off().onchange(Captioning_OnChange); consvar_t cv_continuousmusic = Player("continuousmusic", "On").on_off(); +consvar_t cv_streamersafemusic = Player("streamersafemusic", "Off").on_off(); consvar_t cv_controlperkey = Player("controlperkey", "One").values({{1, "One"}, {2, "Several"}}); // actual general (maximum) sound & music volume, saved into the config diff --git a/src/menus/options-sound.cpp b/src/menus/options-sound.cpp index 138d6e0a6..370dab611 100644 --- a/src/menus/options-sound.cpp +++ b/src/menus/options-sound.cpp @@ -292,6 +292,9 @@ menuitem_t OPTIONS_Sound[] = {IT_STRING | IT_CVAR, "Continuous Attack Music", "Keep music playing seamlessly when retrying in Attack modes.", NULL, {.cvar = &cv_continuousmusic}, 0, 0}, + {IT_STRING | IT_CVAR, "Streamer-Safe Music", "Only play music safe for video platforms.", + NULL, {.cvar = &cv_streamersafemusic}, 0, 0}, + {IT_SPACE | IT_DYBIGSPACE, NULL, NULL, NULL, {NULL}, 0, 0}, diff --git a/src/music_manager.cpp b/src/music_manager.cpp index 2a1ff9a1e..d65b7f9a9 100644 --- a/src/music_manager.cpp +++ b/src/music_manager.cpp @@ -81,7 +81,12 @@ void TuneManager::tick() { if (load()) { - I_PlaySong(tune->loop); + musicdef_t* def = find_musicdef(); + if (!cv_streamersafemusic.value || (def != nullptr && !def->contentidunsafe)) + { + I_PlaySong(tune->loop); + } + I_FadeSongFromVolume( tune->use_level_volume ? level_volume_ : 100, 0, @@ -151,7 +156,11 @@ void TuneManager::pause_unpause() const } else { - I_ResumeSong(); + musicdef_t* def = find_musicdef(); + if (!cv_streamersafemusic.value || (def != nullptr && !def->contentidunsafe)) + { + I_ResumeSong(); + } } } } @@ -168,6 +177,12 @@ bool TuneManager::load() const return I_LoadSong(static_cast(W_CacheLumpNum(lumpnum, PU_MUSIC)), W_LumpLength(lumpnum)); } +musicdef_t* TuneManager::find_musicdef() const +{ + uint8_t index = 0; + return S_FindMusicDef(current_song_.c_str(), &index); +} + void TuneManager::adjust_volume() const { UINT8 i; diff --git a/src/music_manager.hpp b/src/music_manager.hpp index 5db7b635c..682ebd27a 100644 --- a/src/music_manager.hpp +++ b/src/music_manager.hpp @@ -121,6 +121,7 @@ private: } bool load() const; + musicdef_t* find_musicdef() const; void adjust_volume() const; bool resync(); diff --git a/src/s_sound.h b/src/s_sound.h index 3b780300e..981d1bd5c 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -43,6 +43,7 @@ extern consvar_t cv_gamedigimusic; extern consvar_t cv_gamesounds; extern consvar_t cv_bgaudio; +extern consvar_t cv_streamersafemusic; typedef enum {