diff --git a/source/common/audio/music/music.cpp b/source/common/audio/music/music.cpp index 9ab41c776..c1c8290f6 100644 --- a/source/common/audio/music/music.cpp +++ b/source/common/audio/music/music.cpp @@ -110,13 +110,18 @@ void S_SetMusicCallbacks(MusicCallbacks* cb) //========================================================================== static std::unique_ptr musicStream; +static TArray customStreams; SoundStream *S_CreateCustomStream(size_t size, int samplerate, int numchannels, StreamCallback cb, void *userdata) { int flags = 0; if (numchannels < 2) flags |= SoundStream::Mono; auto stream = GSnd->CreateStream(cb, int(size), flags, samplerate, userdata); - if (stream) stream->Play(true, 1); + if (stream) + { + stream->Play(true, 1); + customStreams.Push(stream); + } return stream; } @@ -125,11 +130,19 @@ void S_StopCustomStream(SoundStream *stream) if (stream) { stream->Stop(); + auto f = customStreams.Find(stream); + if (f < customStreams.Size()) customStreams.Delete(f); delete stream; } - } +void S_PauseAllCustomStreams(bool on) +{ + for (auto s : customStreams) + { + s->SetPaused(on); + } +} static TArray convert; static bool FillStream(SoundStream* stream, void* buff, int len, void* userdata) diff --git a/source/common/audio/music/s_music.h b/source/common/audio/music/s_music.h index ef852273c..a76189fc1 100644 --- a/source/common/audio/music/s_music.h +++ b/source/common/audio/music/s_music.h @@ -14,6 +14,7 @@ class SoundStream; typedef bool(*StreamCallback)(SoundStream* stream, void* buff, int len, void* userdata); SoundStream *S_CreateCustomStream(size_t size, int samplerate, int numchannels, StreamCallback cb, void *userdata); void S_StopCustomStream(SoundStream* stream); +void S_PauseAllCustomStreams(bool on); struct MusicCallbacks { diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 7963c384d..3b93b0bad 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -998,7 +998,10 @@ void updatePauseStatus() } } - paused ? S_PauseSound(!pausedWithKey, !paused) : S_ResumeSound(paused); + if (paused) + S_PauseSound(!pausedWithKey, !paused); + else + S_ResumeSound(paused); } //========================================================================== @@ -1106,6 +1109,7 @@ void S_PauseSound (bool notmusic, bool notsfx) { soundEngine->SetPaused(true); GSnd->SetSfxPaused (true, 0); + S_PauseAllCustomStreams(true); } } @@ -1124,6 +1128,7 @@ void S_ResumeSound (bool notsfx) { soundEngine->SetPaused(false); GSnd->SetSfxPaused (false, 0); + S_PauseAllCustomStreams(false); } }