CRI ADX  Last Updated: 2024-07-17 10:47 p
Acquiring the Amount of Buffering

Samples Directory

/CRIWARE/SDK/pc/samples/criatomex/buffering_size


Sample Description

By getting the Atom player (nearly equals to Voice) in the lower layer from the Voice Pool and checking the remaining input data, it is possible to determine how much data being played in streaming is buffered.
Procedure is as follows:
  1. Use the criAtomExVoicePool_GetPlayerHandle function to get the Atom player from the Voice Pool.
  2. Use the criAtomPlayer_GetInputBufferRemainSize function to get the free input buffer in the Atom player.
Specific code is as follows:
:
/* Create Voice Pool */
pool_config.num_voices = SMP_MAX_STREAMS;
pool_config.player_config.streaming_flag = CRI_TRUE;
app_obj->pool = criAtomExVoicePool_AllocateStandardVoicePool(&pool_config, NULL, 0);
:
:
/* Get information about the Atom player (nearly equals to Voice) in the Voice Pool */
for (i = 0; i < SMP_MAX_STREAMS; i++) {
/* Get the Atom player */
player = criAtomExVoicePool_GetPlayerHandle(app_obj->pool, i);
/* Get status/amount of buffering in the Atom player */
status = criAtomPlayer_GetStatus(player);
:
}
:
CriAtomPlayerHn criAtomExVoicePool_GetPlayerHandle(CriAtomExVoicePoolHn pool, CriSint32 index)
Getting the Player Handle.
#define criAtomExVoicePool_SetDefaultConfigForStandardVoicePool(p_config)
Assign the default values to the configuration structure used to create a standard Voice Pool.
Definition: cri_le_atom_ex.h:564
CriAtomExVoicePoolHn criAtomExVoicePool_AllocateStandardVoicePool(const CriAtomExStandardVoicePoolConfig *config, void *work, CriSint32 work_size)
Create a standard Voice Pool.
CriSint32 criAtomPlayer_GetInputBufferRemainSize(CriAtomPlayerHn player)
Get amount of data remaining in input buffer.
CriAtomPlayerStatus criAtomPlayer_GetStatus(CriAtomPlayerHn player)
Get status.



[Note]
Normally, application does not have to consider the amount of buffering. However, if sound breaks while application is running, it is possible to check if data is correctly loaded by performing above step.
(If amount of buffering remains 0 for a long time even if status of Atom player is CRIATOMPLAYER_STATUS_PLAYING, file loading may be blocked by some operation.)