System::setStreamBufferSize

FMOD Studio API

Firelight Technologies FMOD Studio API

System::setStreamBufferSize

Sets the internal buffersize for streams opened after this call.
Larger values will consume more memory (see remarks), whereas smaller values may cause buffer under-run/starvation/stuttering caused by large delays in disk access (ie netstream), or cpu usage in slow machines, or by trying to play too many streams at once.

C++ Syntax

FMOD_RESULT System::setStreamBufferSize(
  unsigned int filebuffersize,
  FMOD_TIMEUNIT filebuffersizetype
);

C Syntax

FMOD_RESULT FMOD_System_SetStreamBufferSize(
  FMOD_SYSTEM *system,
  unsigned int filebuffersize,
  FMOD_TIMEUNIT filebuffersizetype
);

C# Syntax

RESULT System.setStreamBufferSize(
  uint filebuffersize,
  TIMEUNIT filebuffersizetype
);

JavaScript Syntax

System.setStreamBufferSize(
  filebuffersize,                  
  filebuffersizetype               
);

Parameters

filebuffersize
Size of stream file buffer. Default is 16384 (FMOD_TIMEUNIT_RAWBYTES).
filebuffersizetype
Type of unit for stream file buffer size. Must be FMOD_TIMEUNIT_MS, FMOD_TIMEUNIT_PCM, FMOD_TIMEUNIT_PCMBYTES or FMOD_TIMEUNIT_RAWBYTES. Default is FMOD_TIMEUNIT_RAWBYTES.

Return Values

If the function succeeds then the return value is FMOD_OK.
If the function fails then the return value will be one of the values defined in the FMOD_RESULT enumeration.

Remarks

Note this function does not affect streams created with FMOD_OPENUSER, as the buffer size is specified in System::createSound.
This function does not affect latency of playback. All streams are pre-buffered (unless opened with FMOD_OPENONLY), so they will always start immediately.
Seek and Play operations can sometimes cause a reflush of this buffer.

If FMOD_TIMEUNIT_RAWBYTES is used, the memory allocated is 2 * the size passed in, because fmod allocates a double buffer.
If FMOD_TIMEUNIT_MS, FMOD_TIMEUNIT_PCM or FMOD_TIMEUNIT_PCMBYTES is used, and the stream is infinite (such as a shoutcast netstream), or VBR, then FMOD cannot calculate an accurate compression ratio to work with when the file is opened. This means it will then base the buffersize on FMOD_TIMEUNIT_PCMBYTES, or in other words the number of PCM bytes, but this will be incorrect for some compressed formats.
Use FMOD_TIMEUNIT_RAWBYTES for these type (infinite / undetermined length) of streams for more accurate read sizes.

Note to determine the actual memory usage of a stream, including sound buffer and other overhead, use Memory_GetStats before and after creating a sound.

Note that the stream may still stutter if the codec uses a large amount of cpu time, which impacts the smaller, internal 'decode' buffer.
The decode buffer size is changeable via FMOD_CREATESOUNDEXINFO.

See Also




Version 1.10.03 Built on Feb 1, 2018