From f7b8dadedbb04af625582ae7469d80508fdc7645 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Mon, 8 May 2017 10:05:34 +0300 Subject: [PATCH] Made size of music stream buffer customizable Use snd_streambuffersize CVAR to set buffer size in kilobytes, from 16 to 1024 Name of existed CVAR from removed FMOD sound backend is used Increased default size of stream buffer to 64 kB like it was in FMOD backend --- src/sound/musicformats/music_libsndfile.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/sound/musicformats/music_libsndfile.cpp b/src/sound/musicformats/music_libsndfile.cpp index 5e7d620f35..bdba19b4af 100644 --- a/src/sound/musicformats/music_libsndfile.cpp +++ b/src/sound/musicformats/music_libsndfile.cpp @@ -79,6 +79,18 @@ protected: // PUBLIC DATA DEFINITIONS ------------------------------------------------- +CUSTOM_CVAR(Int, snd_streambuffersize, 64, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (self < 16) + { + self = 16; + } + else if (self > 1024) + { + self = 1024; + } +} + // PRIVATE DATA DEFINITIONS ------------------------------------------------ // CODE -------------------------------------------------------------------- @@ -206,7 +218,7 @@ SndFileSong::SndFileSong(FileReader *reader, SoundDecoder *decoder, uint32_t loo Reader = reader; Decoder = decoder; Channels = iChannels == ChannelConfig_Stereo? 2:1; - m_Stream = GSnd->CreateStream(Read, 32*1024, iChannels == ChannelConfig_Stereo? 0 : SoundStream::Mono, SampleRate, this); + m_Stream = GSnd->CreateStream(Read, snd_streambuffersize * 1024, iChannels == ChannelConfig_Stereo? 0 : SoundStream::Mono, SampleRate, this); } //==========================================================================