- Backend update from GZDoom.

This commit is contained in:
Christoph Oelckers 2022-10-14 20:11:44 +02:00
parent 972df67d92
commit 5a580c145e
6 changed files with 11 additions and 16 deletions

View file

@ -117,10 +117,11 @@ int MusicEnabled() // int return is for scripting
static std::unique_ptr<SoundStream> musicStream;
static TArray<SoundStream*> customStreams;
SoundStream *S_CreateCustomStream(size_t size, int samplerate, int numchannels, StreamCallback cb, void *userdata)
SoundStream *S_CreateCustomStream(size_t size, int samplerate, int numchannels, MusicCustomStreamType sampletype, StreamCallback cb, void *userdata)
{
int flags = 0;
if (numchannels < 2) flags |= SoundStream::Mono;
if (sampletype == MusicSamplesFloat) flags |= SoundStream::Float;
auto stream = GSnd->CreateStream(cb, int(size), flags, samplerate, userdata);
if (stream)
{

View file

@ -11,9 +11,13 @@ class FileReader;
class SoundStream;
enum MusicCustomStreamType : bool {
MusicSamples16bit,
MusicSamplesFloat
};
int MusicEnabled();
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);
SoundStream *S_CreateCustomStream(size_t size, int samplerate, int numchannels, MusicCustomStreamType sampletype, StreamCallback cb, void *userdata);
void S_StopCustomStream(SoundStream* stream);
void S_PauseAllCustomStreams(bool on);

View file

@ -618,7 +618,7 @@ public:
if (adata.inf.bitsPerSample == 8) copy8bitSamples(read);
else copy16bitSamples(read);
if (!stream && read) // the sound may not start in the first frame, but the stream cannot start without any sound data present.
stream = S_CreateCustomStream(6000, adata.inf.sampleRate, adata.inf.nChannels, StreamCallbackFunc, this);
stream = S_CreateCustomStream(6000, adata.inf.sampleRate, adata.inf.nChannels, MusicSamples16bit, StreamCallbackFunc, this);
}

View file

@ -291,7 +291,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock)
if (!bAudioStarted)
{
// start audio playback
stream = S_CreateCustomStream(6000, audio.nSampleRate, audio.nChannels, StreamCallbackFunc, this);
stream = S_CreateCustomStream(6000, audio.nSampleRate, audio.nChannels, MusicSamples16bit, StreamCallbackFunc, this);
bAudioStarted = true;
}

View file

@ -250,7 +250,7 @@ void VulkanSwapChain::CreateViews()
bool VulkanSwapChain::IsHdrModeActive() const
{
return swapChainFormat.colorSpace == VK_COLOR_SPACE_HDR10_ST2084_EXT || swapChainFormat.colorSpace == VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT;
return swapChainFormat.colorSpace == VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT;
}
void VulkanSwapChain::SelectFormat()
@ -276,16 +276,6 @@ void VulkanSwapChain::SelectFormat()
return;
}
}
// For older drivers that reported the wrong colorspace
for (const auto &format : surfaceFormats)
{
if (format.format == VK_FORMAT_R16G16B16A16_SFLOAT && format.colorSpace == VK_COLOR_SPACE_HDR10_ST2084_EXT)
{
swapChainFormat = format;
return;
}
}
}
for (const auto &format : surfaceFormats)

View file

@ -205,7 +205,7 @@ public:
audio.nWrite = 5; // play 5 blocks (i.e. half a second) of silence to get ahead of the stream. For this video it isn't necessary to sync it perfectly.
// start audio playback
stream = S_CreateCustomStream(kSampleSize * 2, kSampleRate, 1, StreamCallbackFunc, this); // size must be doubled here or dropouts can be heard.
stream = S_CreateCustomStream(kSampleSize * 2, kSampleRate, 1, MusicSamples16bit, StreamCallbackFunc, this); // size must be doubled here or dropouts can be heard.
animtex.SetSize(AnimTexture::Paletted, 200, 320);
}