CRI ADX  Last Updated: 2024-07-17 10:48 p
获取缓冲量
示例目录
/cri/pc/samples/criatomex/buffering_size
示例描述
通过从Voice池中获取下层AtomPlayer(≒Voice)并检查输入数据余量, 可以检查流播放中的数据缓冲量。 通常不需要注意应用程序中的缓冲量。 但在发生与流有关的问题时,或许可以通过检查缓冲量来进行调查。 例如,应用程序执行期间发生声音中断等就属于此类问题。
处理步骤
  1. 使用::criAtomExVoicePool_GetPlayerHandle函数,从Voice池中获取AtomPlayer。
  2. 使用::criAtomPlayer_GetInputBufferRemainSize函数,获取AtomPlayer的输入缓冲余量。
/* 创建Voice池 */
pool_config.num_voices = SMP_MAX_STREAMS;
pool_config.player_config.streaming_flag = CRI_TRUE;
app_obj->pool = criAtomExVoicePool_AllocateStandardVoicePool(&pool_config, NULL, 0);
/* 获取Voice池中的AtomPlayer(≒Voice)的信息 */
for (i = 0; i < SMP_MAX_STREAMS; i++) {
/* 获取AtomPlayer */
player = criAtomExVoicePool_GetPlayerHandle(app_obj->pool, i);
/* 获取AtomPlayer的状态/缓冲量 */
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
注意
如果AtomPlayer的状态为CRIATOMPLAYER_STATUS_PLAYING,但缓冲量长期保持为0, 那么可能会因为某些处理阻断文件读取。