This sample program is an example of codes to perform movie playback by obtaining the required work buffers directly from the application without registering a user allocator.
Overview of Playback by Setting Work Buffers
If a user allocator is not registered, the application must pass the address of a memory area that is allocated according to the size of the work buffer required by the Mana library in the following three cases:
- During library initialization
- During handle creation
- Just before starting playback (specification of the work buffer for playback)
To calculate the size of the work buffer required in each of the above cases, use the corresponding work buffer size calculation functions. Then, allocate the memory for the calculated work buffer size and pass that to the CRI Mana library. For details related to memory management in the CRI Mana library, refer to
Memory Management.
1. During Library Initialization
criFwPrt_DebugPrintf("[Work: Mana Lib]\n");
app_obj->buf_mana_libwork = criFwMem_Alloc(app_obj->size_mana_libwork, SMPUTL_MEM_ALIGN);
void criMana_Initialize(const CriManaLibConfig *config, void *work, CriSint32 work_size)
Library initialization.
CriSint32 criMana_CalculateLibWorkSize(const CriManaLibConfig *config)
Calculate library initialization work area size.
The work buffer size required for library initialization is determined by the parameters in the
CriManaLibConfig structure. If NULL is specified instead of this structure, the values initialized in
criMana_SetDefaultLibConfig will be applied internally.
2. During Handle Creation
app_obj->size_mana_hnwork = criManaPlayer_CalculateHanldeWorkSize();
criFwPrt_DebugPrintf("[Work: Mana Player]\n");
app_obj->buf_mana_hnwork = criFwMem_Alloc(app_obj->size_mana_hnwork, SMPUTL_MEM_ALIGN);
CriManaPlayerHn criManaPlayer_Create(void *work, CriSint32 work_size)
Create Mana player (no config specified)
There are no parameters required for player handle creation. Pass a work buffer that is the minimum size required for handle creation.
3. Before Starting Playback (Specification of the Work Buffer for Playback)
{
criFwPrt_DebugPrintf("[Work: Mana Playback]\n");
app_obj->buf_mana_playwork = criFwMem_Alloc(app_obj->size_mana_playwork, SMPUTL_MEM_ALIGN);
}
CriSint32 criManaPlayer_CalculatePlaybackWorkSize(CriManaPlayerHn player, const CriManaPlaybackBasicWorkConfig *config_basic, const CriManaPlaybackExWorkConfig *config_ex)
Calculate playback work area size.
void criManaPlayer_SetPlaybackWork(CriManaPlayerHn player, const CriManaPlaybackBasicWorkConfig *config_basic, const CriManaPlaybackExWorkConfig *config_ex, void *work, CriSint32 work_size)
Set playback work area.
CriBool criManaPlayer_GetPlaybackWorkParam(CriManaPlayerHn player, CriManaPlaybackBasicWorkConfig *config_basic, CriManaPlaybackExWorkConfig *config_ex)
Get playback work parameter structure.
Playback work parameter structure (basic)
Definition: cri_mana.h:684
Playback work parameter structure (extended)
Definition: cri_mana.h:704
Calculate the work buffer required for playback based on the playback parameters and specifications of the movie file you want the application to play, then pass that work buffer to the Mana player handle.
If header analysis has been completed, you can use the
criManaPlayer_GetPlaybackWorkParam function to obtain the appropriate work parameters for playback based on the playback information (number of audio tracks, etc.) set in the header information and player handle. If you want to begin movie playback immediately without performing header analysis, adjust the
CriManaPlaybackExWorkConfig structure parameters in advance and specify the work buffer for playback.
If you want to reduce the playback work buffer size, adjust the parameters in the
CriManaPlaybackBasicWorkConfig and
CriManaPlaybackExWorkConfig structures to disable unnecessary functions and adjust the size required.
Releasing Work Buffers
Release the work buffers passed to the CRI Mana library/player handles only after destroying each player handle and finalizing the library. Normal operation cannot be guaranteed if you release a work buffer during movie playback or while the library is still initialized.