LIBTTAr_MISC(3)

NAME
libttaR_misc - miscellaneous functions and objects

SYNOPSIS
#include <libttaR.h>
int libttaR_test_nchan(unsigned int nchan);
size_t libttaR_nsamples_perframe_tta1(size_t samplerate);
size_t libttaR_ttabuf_safety_margin(
    enum LibTTAr_Samplebytes samplebytes, unsigned int nchan
);
size_t libttaR_codecstate_priv_size(unsigned int nchan);
const struct LibTTAr_VersionInfo libttaR_info;

DESCRIPTION
libttaR_test_nchan(3) tests whether the library was built to support nchan audio channels. libttaR_nsamples_perframe_tta1(3) calculates the number of samples in a TTA1 frame for a given samplerate. libttaR_ttabuf_safety_margin(3) calculates a safety-margin size for padding the TTA buffer in order to prevent a possible buffer overrun. The calculated size is greater than the maximum number of TTA bytes that could be encoded for one PCM sample with nchan channels. When decoding, the padding is needed in case the TTA data is corrupted or malformed. Not using this function may result in a LIBTTAr_RET_INVAL_BOUNDS return from a codec function if the TTA buffer length is too small. libttaR_codecstate_priv_size(3) calculates the size of a private state struct with nchan audio channels. The returned size is suitable for passing to aligned_alloc(3).
        #include <stdlib.h>
        #include <libttaR.h>
        /*@only@*/ /*@null@*/
        LibTTAr_CodecState_Priv *
        priv_alloc(const unsigned int nchan)
        /*@globals	internalState@*/
        /*@modifies	internalState@*/
        {
        	const size_t size = libttaR_codecstate_priv_size(nchan);
        	if ( size == 0 ){
        		return NULL;
        	}
        	return aligned_alloc(LIBTTAr_CODECSTATE_PRIV_ALIGN, size);
        }
libttaR_info is a read-only object containing the library's version information.
    struct LibTTAr_VersionInfo {
        unsigned int       version;
        unsigned int       version_major;   /* API change               */
        unsigned int       version_minor;   /* bugfix or improvement    */
        unsigned int       version_revis;	/* inbetween minor versions */
        const char        *version_extra;
        const char        *version_date;
        const char        *copyright;
        const char        *license;
    };

  Arguments
nchan
    The number of audio channels in the PCM.
samplerate
    The audio sampling frequency in samples-per-second.
samplebytes
    The number of bytes per samples in the originally sized PCM.
    enum LibTTAr_SampleBytes {
        LIBTTAr_SAMPLEBYTES_1   = 1u,
        LIBTTAr_SAMPLEBYTES_2   = 2u,
        LIBTTAr_SAMPLEBYTES_3   = 3u
    };

RETURN VALUE
libttaR_test_nchan(3)
    Non-0 on success.
libttaR_nsamples_perframe_tta1(3)
    The number of samples in a TTA1 frame.
libttaR_ttabuf_safety_margin(3)
    How much to pad the TTA buffer by.
libttaR_codecstate_priv_size(3)
    The size of a private state struct.

ERRORS
0 - bad parameter or integer overflow. The debug build of the library may abort instead of returning an error.

ATTRIBUTES
All are MT-Safe.

SEE ALSO
libttaR_tta_encode(3), libttaR_tta_decode(3), libttaR_pcm_read(3), libttaR_pcm_write(3), libttaR_crc32(3)

AUTHOR
Shane Seelig
    Developer