mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
- added custom sound stream feature from Raze.
Currently not active yet but may be useful to implement streaming sounds in ZScript
This commit is contained in:
parent
700304bf46
commit
2b64f8fb19
2 changed files with 28 additions and 1 deletions
|
@ -95,6 +95,26 @@ void S_SetMusicCallbacks(MusicCallbacks* cb)
|
|||
|
||||
static std::unique_ptr<SoundStream> 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_;
|
||||
|
|
|
@ -8,6 +8,12 @@
|
|||
#include <zmusic.h>
|
||||
|
||||
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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue