Use a 64k stream buffer for all streams, not just net streams

- FLACs need a larger buffer than the default to run without starving on
  later versions of FMOD.
This commit is contained in:
Randy Heit 2016-01-14 20:41:09 -06:00
parent 722ef02719
commit 16781e47ae

View file

@ -462,14 +462,12 @@ public:
Stream->release(); Stream->release();
Channel = NULL; Channel = NULL;
Stream = NULL; Stream = NULL;
Owner->Sys->setStreamBufferSize(64*1024, FMOD_TIMEUNIT_RAWBYTES);
// Open the stream asynchronously, so we don't hang the game while trying to reconnect. // Open the stream asynchronously, so we don't hang the game while trying to reconnect.
// (It would be nice to do the initial open asynchronously as well, but I'd need to rethink // (It would be nice to do the initial open asynchronously as well, but I'd need to rethink
// the music system design to pull that off.) // the music system design to pull that off.)
result = Owner->Sys->createSound(URL, (Loop ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF) | FMOD_SOFTWARE | FMOD_2D | result = Owner->Sys->createSound(URL, (Loop ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF) | FMOD_SOFTWARE | FMOD_2D |
FMOD_CREATESTREAM | FMOD_NONBLOCKING, NULL, &Stream); FMOD_CREATESTREAM | FMOD_NONBLOCKING, NULL, &Stream);
JustStarted = true; JustStarted = true;
Owner->Sys->setStreamBufferSize(16*1024, FMOD_TIMEUNIT_RAWBYTES);
return result != FMOD_OK; return result != FMOD_OK;
} }
if (JustStarted && openstate == FMOD_OPENSTATE_PLAYING) if (JustStarted && openstate == FMOD_OPENSTATE_PLAYING)
@ -1170,6 +1168,9 @@ bool FMODSoundRenderer::Init()
} }
Sys->set3DSettings(0.5f, 96.f, 1.f); Sys->set3DSettings(0.5f, 96.f, 1.f);
Sys->set3DRolloffCallback(RolloffCallback); Sys->set3DRolloffCallback(RolloffCallback);
// The default is 16k, which periodically starves later FMOD versions
// when streaming FLAC files.
Sys->setStreamBufferSize(64*1024, FMOD_TIMEUNIT_RAWBYTES);
snd_sfxvolume.Callback (); snd_sfxvolume.Callback ();
return true; return true;
} }
@ -1733,10 +1734,6 @@ SoundStream *FMODSoundRenderer::OpenStream(const char *url, int flags)
exinfo.dlsname = patches; exinfo.dlsname = patches;
} }
// Use a larger buffer for URLs so that it's less likely to be effected
// by hiccups in the data rate from the remote server.
Sys->setStreamBufferSize(64*1024, FMOD_TIMEUNIT_RAWBYTES);
result = Sys->createSound(url, mode, &exinfo, &stream); result = Sys->createSound(url, mode, &exinfo, &stream);
if(result == FMOD_ERR_FORMAT && exinfo.dlsname != NULL) if(result == FMOD_ERR_FORMAT && exinfo.dlsname != NULL)
{ {
@ -1748,9 +1745,6 @@ SoundStream *FMODSoundRenderer::OpenStream(const char *url, int flags)
} }
} }
// Restore standard buffer size.
Sys->setStreamBufferSize(16*1024, FMOD_TIMEUNIT_RAWBYTES);
if(result != FMOD_OK) if(result != FMOD_OK)
return NULL; return NULL;