CRI Sofdec2  Last Updated: 2022-11-21 16:25 p
Playing Multiple Movie Playback

Sofdec2 supports playing multiple movies at the same time.

Maximum Number of Movie Playback

Normally each movie will use one movie decoder handle resource.
The upper limit for handle resources is set by the library initialization parameters.
If you set your Mana library initialization parameters to NULL, then the maximum number of handle resources is four.

[Remarks]
Be aware that alpha movie playback use two handle resources.

Changing the Maximum Number of Handles

(1) CRI Mana Library Initialization Settings

To increase the maximum number of movie decoder handle resources,
set the Mana library initialization configuration parameters and initialize.

For example, the following shows a sample code for increasing the maximum number of handles to eight.

#define NUM_MOVIES (8) /* Increase maximum number of movie handles to eight */
CriManaLibConfig config_mana; /* CRI Mana library initialization configuration */
/* Register user allocator */
criMana_SetUserAllocator(user_alloc, user_free, NULL);
/* Set CRI Mana library initialization configuration to default values */
/* Set maximum number of movie decoder handles */
config_mana.max_decoder_handles = NUM_MOVIES;
/* Initialize CRI Mana library */
criMana_Initialize(&config_mana, NULL, 0);
void criMana_Initialize(const CriManaLibConfig *config, void *work, CriSint32 work_size)
Library initialization.
#define criMana_SetDefaultLibConfig(p_config)
Set default values for the library initialization config structure.
Definition: cri_mana.h:136
void criMana_SetUserAllocator(CriManaMallocFunc malloc_func, CriManaFreeFunc free_func, void *obj)
Register user allocator.
Mana library initialization parameters.
Definition: cri_mana.h:460
CriUint32 max_decoder_handles
Definition: cri_mana.h:461
Attention
You will only use handle resources when using the Sofdec Prime codec.
You will not use resources when playing other codecs.


(2) CRI File System Library Initialization Settings

In addition to using movie decoder handle resources when streaming movies,
you will use resources for the loader handle (CriFsLoader) to read data and
for open files for streaming.

When you have multiple video or audio files to stream, apart from the Mana library you will need to
first set the File System initialization configuration parameters (number of loader handles,
maximum number of open files) and initialize it.

The default number of loader handles and open files is 16.
If you try to stream more than this, you will trigger
an error callback.

E2008070931:Can not allocate loader handle. (Increase num_loaders of CriFsConfiguration.)

For example, to simultaneously stream more than 17 files, you will
need the following kind of library initialization settings and
to increase the number of loaders and maximum number of simultaneous open files.

#define NUM_MOVIES (17) /* Increase maximum number of handles to 17 */
CriFsConfig config_fs; /* CRI FileSystem library initialization configuration */
CriAtomExConfig config_atom_ex; /* CRI Atom library initialization configuration */
CriManaLibConfig config_mana; /* CRI Mana library initialization configuration */
/* Register user allocator */
criAtomEx_SetUserAllocator(user_alloc, user_free, NULL);
criMana_SetUserAllocator(user_alloc, user_free, NULL);
/*--- CRI FileSystem ---*/
/* Set CRI FileSystem initialization configuration to default values */
criFs_SetDefaultConfig(&config_fs);
/* Adjust CRI FileSystem library initialization configuration(*) */
/* Number of CriFsLoader to use */
config_fs.num_loaders = NUM_MOVIES;
/* Maximum number of simultaneously open files */
config_fs.max_files = NUM_MOVIES;
/*--- CRI Atom ---*/
/* Set CRI AtomEx initialization configuration to default values */
criAtomEx_SetDefaultConfig(&config_atom_ex);
/* Set the adjusted CriFsConfig to AtomEx configuration and initialize */
config_atom_ex.fs_config = &config_fs;
/* Initialize CRI Atom library */
criAtomEx_Initialize(&config_atom_ex, NULL, 0);
/*--- CRI Mana ---*/
/* Set CRI Mana library initialization configuration to default values */
/* Set maximum number of movie decoder handles */
config_mana.max_decoder_handles = NUM_MOVIES;
/* Initialize CRI Mana library */
criMana_Initialize(&config_mana, NULL, 0);

[Notes]
1: When playing a USM file independently, then the number of max_files is specified by
the number of USM to simultaneously play. When packing USM files into CPK files to play, then
it sets the number of CPK.

2: Adjust the audio portion as well if simultaneously playing audio files using ADX2
in addition to videos.

3: You do not need to increase the number of num_loaders or max_files when
playing from memory instead of streaming.