Firelight Technologies FMOD Studio API
Sound::getOpenState
Retrieves the state a sound is in after FMOD_NONBLOCKING has been used to open it, or the state of the streaming buffer.
C++ Syntax
FMOD_RESULT Sound::getOpenState(
FMOD_OPENSTATE *openstate,
unsigned int *percentbuffered,
bool *starving,
bool *diskbusy
);
C Syntax
FMOD_RESULT FMOD_Sound_GetOpenState(
FMOD_SOUND *sound,
FMOD_OPENSTATE *openstate,
unsigned int *percentbuffered,
FMOD_BOOL *starving,
FMOD_BOOL *diskbusy
);
C# Syntax
RESULT Sound.getOpenState(
out OPENSTATE openstate,
out uint percentbuffered,
out bool starving,
out bool diskbusy
);
JavaScript Syntax
Sound.getOpenState(
openstate, // writes value to openstate.val
percentbuffered, // writes value to percentbuffered.val
starving, // writes value to starving.val
diskbusy // writes value to diskbusy.val
);
Parameters
- openstate
- Address of a variable that receives the open state of a sound. Optional. Specify 0 or NULL to ignore.
- percentbuffered
- Address of a variable that receives the percentage of the file buffer filled progress of a stream. Optional. Specify 0 or NULL to ignore.
- starving
- Address of a variable that receives the starving state of a sound. If a stream has decoded more than the stream file buffer has ready for it, it will return TRUE. Optional. Specify 0 or NULL to ignore.
- diskbusy
- Address of a variable that receives the disk busy state of a sound. That is, whether the disk is currently being accessed for the sound.
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
When a sound is opened with FMOD_NONBLOCKING, it is opened and prepared in the background, or asynchronously.
This allows the main application to execute without stalling on audio loads.
This function will describe the state of the asynchronous load routine i.e. whether it has succeeded, failed or is still in progress.
If 'starving' is true, then you will most likely hear a stuttering/repeating sound as the decode buffer loops on itself and replays old data.
Now that this variable exists, you can detect buffer underrun and use something like Channel::setMute to keep it quiet until it is not starving any more.
Note: Always check 'openstate' to determine the state of the sound. Do not assume that if this function returns FMOD_OK then the sound has finished loading.
See Also
Version 1.10.03 Built on Feb 1, 2018