diff --git a/src/common/audio/music/music.cpp b/src/common/audio/music/music.cpp index 1f8b0a004..198b9975f 100644 --- a/src/common/audio/music/music.cpp +++ b/src/common/audio/music/music.cpp @@ -95,6 +95,26 @@ void S_SetMusicCallbacks(MusicCallbacks* cb) static std::unique_ptr musicStream; +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, size, flags, samplerate, userdata); + if (stream) stream->Play(true, 1); + return stream; +} + +void S_StopCustomStream(SoundStream *stream) +{ + if (stream) + { + stream->Stop(); + delete stream; + } + +} + + static bool FillStream(SoundStream* stream, void* buff, int len, void* userdata) { bool written = ZMusic_FillStream(mus_playing.handle, buff, len); @@ -123,6 +143,7 @@ void S_CreateStream() } } + void S_PauseStream(bool paused) { if (musicStream) musicStream->SetPaused(paused); @@ -298,7 +319,7 @@ bool S_ChangeMusic(const char* musicname, int order, bool looping, bool force) if (!force && PlayList.GetNumSongs()) { // Don't change if a playlist is active - return false; + return true; // do not report an error here. } // Do game specific lookup. FString musicname_; diff --git a/src/common/audio/music/s_music.h b/src/common/audio/music/s_music.h index 4138dc7da..8b6e33188 100644 --- a/src/common/audio/music/s_music.h +++ b/src/common/audio/music/s_music.h @@ -8,6 +8,12 @@ #include class FileReader; +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); struct MusicCallbacks {