nrfxlib API 2.8.99
Loading...
Searching...
No Matches

◆ LC3Initialize()

int32_t LC3Initialize ( uint8_t encoderSampleRates,
uint8_t decoderSampleRates,
LC3FrameSizeConfig_t frameSizeConfig,
uint8_t uniqueSessions,
uint8_t * buffer,
uint32_t * bufferSize )

#include <lc3/codec/inc/LC3API.h>

Initializes the LC3 Codec.

This function initializes the LC3 codec for the sample rates(s) specified in the encoder/decoder sample rate parameter bit masks. The sample rate bits are defined in LC3SampleRateBits. The user must provide all required encoder/decoder sample rates to this function. If the exact sample rates are unknown, the LC3_SAMPLE_RATE_ALL value should be entered.

frameSizeConfig defines if the codec will support 7.5 msec frames, 10 msec frames or both. If the frame size isn't known in advance, setting this to both allows each session to use either 7.5 or 10 msec but will use more memory.

The uniqueSessions value is the number of unique (sample rates * frame sizes) sessions expected to be used simultaneously; the sample rates of 48k and 44.1k are considered a single sample rate for this calculation. If nothing is known of the expected sessions' sample rates and/or frame sizes, this can be set to the number of simultaneous encode + decode sessions. Setting this to the total number of (unique sample rates * frame sizes) will initialize data tables globally, otherwise they will be initialized as needed when sessions are opened.

When LC3_SAMPLE_RATE_ALL and/or LC3FrameSizeBothConfig are used and the uniqueSessions value is less than the number of (sample rates * frame sizes), the codec allocates the worse case shared memory required based on the uniqueSessions value. The LC3EncodeSessionOpen and/or LC3DecodeSessionOpen call initializes the tables required for each session's sample rate and frame size. In general, the smallest memory footprint will be achieved by defining the sample rate bit fields and a single frame size.

This function can allocate its own memory or take a user-provided buffer. It can also return the amount of memory needed without initializing. These memory options are performed in the following ways:

bufferSize = NULL: Allocates memory needed. The buffer parameter may be NULL.

*bufferSize < memory required by codec: Sets bufferSize's referenced value to the total memory required and returns LC3_RESULT_INSUFFICIENT_RESOURCES. The caller can then call this function again with a buffer of at least bufferSize's referenced value. A size of 0 will always trigger this condition. The buffer parameter may be NULL.

*bufferSize >= memory required by codec: Uses the user-provided buffer. bufferSize's referenced value is set to the amount of memory used by the codec. The buffer parameter may not be NULL.

Parameters
[in]encoderSampleRatesBitfield containing all encoder session sample rates required.
[in]decoderSampleRatesBitfield containing all decoder session sample rates required.
[in]frameSizeConfigFrame size of 7.5, 10 msec or both.
[in]uniqueSessionsThe number of unique simultaneous sample rate * frame size sessions.
[in]bufferPointer to a memory buffer.
[in,out]bufferSizeSize of the memory buffer passed in, number of bytes used returned.
Returns
Zero on success or one of the defined LC3 result codes on error.