From 6a9fd1bf5f9d3a686d1cfaf018427f12dadeb736 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Tue, 30 Apr 2024 17:44:35 -0500 Subject: [PATCH 1/2] Add 'contentidunsafe' property to MUSICDEF This allows marking music in MUSICDEF as unsafe for Content ID and other similar content surveillance mechanisms. --- src/s_sound.c | 5 +++++ src/s_sound.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/s_sound.c b/src/s_sound.c index d98f506b8..c4d1993bf 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2041,6 +2041,11 @@ ReadMusicDefFields textline[0] = toupper(textline[0]); def->important = (textline[0] == 'Y' || textline[0] == 'T' || textline[0] == '1'); } + else if (!stricmp(stoken, "contentidunsafe")) + { + textline[0] = toupper(textline[0]); + def->contentidunsafe = (textline[0] == 'Y' || textline[0] == 'T' || textline[0] == '1'); + } else { MusicDefError(CONS_WARNING, diff --git a/src/s_sound.h b/src/s_sound.h index d76deb441..3b780300e 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -171,6 +171,7 @@ struct musicdef_t int volume; int debug_volume; boolean important; + boolean contentidunsafe; musicdef_t *next; soundtestsequence_t sequence; }; From ab854ab54570f14ad119dc12df95d7169987fe55 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Tue, 30 Apr 2024 18:03:19 -0500 Subject: [PATCH 2/2] Add `streamersafemusic` cvar Don't play music that is marked contentidunsafe in its MUSICDEF (if it exists). --- src/cvars.cpp | 1 + src/menus/options-sound.cpp | 3 +++ src/music_manager.cpp | 19 +++++++++++++++++-- src/music_manager.hpp | 1 + src/s_sound.h | 1 + 5 files changed, 23 insertions(+), 2 deletions(-) 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 {