ALSA project - the C library reference
Functions
Helper Functions
Collaboration diagram for Helper Functions:

Functions

int snd_pcm_format_signed (snd_pcm_format_t format)
 Return sign info for a PCM sample linear format. More...
 
int snd_pcm_format_unsigned (snd_pcm_format_t format)
 Return sign info for a PCM sample linear format. More...
 
int snd_pcm_format_linear (snd_pcm_format_t format)
 Return linear info for a PCM sample format. More...
 
int snd_pcm_format_float (snd_pcm_format_t format)
 Return float info for a PCM sample format. More...
 
int snd_pcm_format_little_endian (snd_pcm_format_t format)
 Return endian info for a PCM sample format. More...
 
int snd_pcm_format_big_endian (snd_pcm_format_t format)
 Return endian info for a PCM sample format. More...
 
int snd_pcm_format_cpu_endian (snd_pcm_format_t format)
 Return endian info for a PCM sample format. More...
 
int snd_pcm_format_width (snd_pcm_format_t format)
 Return nominal bits per a PCM sample. More...
 
int snd_pcm_format_physical_width (snd_pcm_format_t format)
 Return bits needed to store a PCM sample. More...
 
snd_pcm_format_t snd_pcm_build_linear_format (int width, int pwidth, int unsignd, int big_endian)
 Compose a PCM sample linear format. More...
 
ssize_t snd_pcm_format_size (snd_pcm_format_t format, size_t samples)
 Return bytes needed to store a quantity of PCM sample. More...
 
uint8_t snd_pcm_format_silence (snd_pcm_format_t format)
 Return 8 bit expressing silence for a PCM sample format. More...
 
uint16_t snd_pcm_format_silence_16 (snd_pcm_format_t format)
 Return 16 bit expressing silence for a PCM sample format. More...
 
uint32_t snd_pcm_format_silence_32 (snd_pcm_format_t format)
 Return 32 bit expressing silence for a PCM sample format. More...
 
uint64_t snd_pcm_format_silence_64 (snd_pcm_format_t format)
 Return 64 bit expressing silence for a PCM sample format. More...
 
int snd_pcm_format_set_silence (snd_pcm_format_t format, void *buf, unsigned int samples)
 Silence a PCM samples buffer. More...
 
snd_pcm_sframes_t snd_pcm_bytes_to_frames (snd_pcm_t *pcm, ssize_t bytes)
 Convert bytes in frames for a PCM. More...
 
ssize_t snd_pcm_frames_to_bytes (snd_pcm_t *pcm, snd_pcm_sframes_t frames)
 Convert frames in bytes for a PCM. More...
 
long snd_pcm_bytes_to_samples (snd_pcm_t *pcm, ssize_t bytes)
 Convert bytes in samples for a PCM. More...
 
ssize_t snd_pcm_samples_to_bytes (snd_pcm_t *pcm, long samples)
 Convert samples in bytes for a PCM. More...
 
int snd_pcm_area_silence (const snd_pcm_channel_area_t *dst_channel, snd_pcm_uframes_t dst_offset, unsigned int samples, snd_pcm_format_t format)
 Silence an area. More...
 
int snd_pcm_areas_silence (const snd_pcm_channel_area_t *dst_channels, snd_pcm_uframes_t dst_offset, unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format)
 Silence one or more areas. More...
 
int snd_pcm_area_copy (const snd_pcm_channel_area_t *dst_channel, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_channel, snd_pcm_uframes_t src_offset, unsigned int samples, snd_pcm_format_t format)
 Copy an area. More...
 
int snd_pcm_areas_copy (const snd_pcm_channel_area_t *dst_channels, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_channels, snd_pcm_uframes_t src_offset, unsigned int channels, snd_pcm_uframes_t frames, snd_pcm_format_t format)
 Copy one or more areas. More...
 
int snd_pcm_areas_copy_wrap (const snd_pcm_channel_area_t *dst_channels, snd_pcm_uframes_t dst_offset, const snd_pcm_uframes_t dst_size, const snd_pcm_channel_area_t *src_channels, snd_pcm_uframes_t src_offset, const snd_pcm_uframes_t src_size, const unsigned int channels, snd_pcm_uframes_t frames, const snd_pcm_format_t format)
 Copy one or more areas. More...
 

Detailed Description

See the PCM (digital audio) interface page for more details.

Function Documentation

◆ snd_pcm_area_copy()

int snd_pcm_area_copy ( const snd_pcm_channel_area_t dst_area,
snd_pcm_uframes_t  dst_offset,
const snd_pcm_channel_area_t src_area,
snd_pcm_uframes_t  src_offset,
unsigned int  samples,
snd_pcm_format_t  format 
)

Copy an area.

Parameters
dst_areadestination area specification
dst_offsetoffset in frames inside destination area
src_areasource area specification
src_offsetoffset in frames inside source area
samplessamples to copy
formatPCM sample format
Returns
0 on success otherwise a negative error code

◆ snd_pcm_area_silence()

int snd_pcm_area_silence ( const snd_pcm_channel_area_t dst_area,
snd_pcm_uframes_t  dst_offset,
unsigned int  samples,
snd_pcm_format_t  format 
)

Silence an area.

Parameters
dst_areaarea specification
dst_offsetoffset in frames inside area
samplessamples to silence
formatPCM sample format
Returns
0 on success otherwise a negative error code

◆ snd_pcm_areas_copy()

int snd_pcm_areas_copy ( const snd_pcm_channel_area_t dst_areas,
snd_pcm_uframes_t  dst_offset,
const snd_pcm_channel_area_t src_areas,
snd_pcm_uframes_t  src_offset,
unsigned int  channels,
snd_pcm_uframes_t  frames,
snd_pcm_format_t  format 
)

Copy one or more areas.

Parameters
dst_areasdestination areas specification (one for each channel)
dst_offsetoffset in frames inside destination area
src_areassource areas specification (one for each channel)
src_offsetoffset in frames inside source area
channelschannels count
framesframes to copy
formatPCM sample format
Returns
0 on success otherwise a negative error code

◆ snd_pcm_areas_copy_wrap()

int snd_pcm_areas_copy_wrap ( const snd_pcm_channel_area_t dst_channels,
snd_pcm_uframes_t  dst_offset,
const snd_pcm_uframes_t  dst_size,
const snd_pcm_channel_area_t src_channels,
snd_pcm_uframes_t  src_offset,
const snd_pcm_uframes_t  src_size,
const unsigned int  channels,
snd_pcm_uframes_t  frames,
const snd_pcm_format_t  format 
)

Copy one or more areas.

Parameters
dst_areasdestination areas specification (one for each channel)
dst_offsetoffset in frames inside destination area
dst_sizesize in frames of the destination buffer
src_areassource areas specification (one for each channel)
src_offsetoffset in frames inside source area
dst_sizesize in frames of the source buffer
channelschannels count
framesframes to copy
formatPCM sample format
Returns
0 on success otherwise a negative error code

◆ snd_pcm_areas_silence()

int snd_pcm_areas_silence ( const snd_pcm_channel_area_t dst_areas,
snd_pcm_uframes_t  dst_offset,
unsigned int  channels,
snd_pcm_uframes_t  frames,
snd_pcm_format_t  format 
)

Silence one or more areas.

Parameters
dst_areasareas specification (one for each channel)
dst_offsetoffset in frames inside area
channelschannels count
framesframes to silence
formatPCM sample format
Returns
0 on success otherwise a negative error code

◆ snd_pcm_build_linear_format()

snd_pcm_format_t snd_pcm_build_linear_format ( int  width,
int  pwidth,
int  unsignd,
int  big_endian 
)

Compose a PCM sample linear format.

Parameters
widthNominal bits per sample
pwidthPhysical bit width of the format
unsigndSign: 0 signed, 1 unsigned
big_endianEndian: 0 little endian, 1 big endian
Returns
The matching format type, or SND_PCM_FORMAT_UNKNOWN if no match

◆ snd_pcm_bytes_to_frames()

snd_pcm_sframes_t snd_pcm_bytes_to_frames ( snd_pcm_t pcm,
ssize_t  bytes 
)

Convert bytes in frames for a PCM.

Parameters
pcmPCM handle
bytesquantity in bytes
Returns
quantity expressed in frames

◆ snd_pcm_bytes_to_samples()

long snd_pcm_bytes_to_samples ( snd_pcm_t pcm,
ssize_t  bytes 
)

Convert bytes in samples for a PCM.

Parameters
pcmPCM handle
bytesquantity in bytes
Returns
quantity expressed in samples

◆ snd_pcm_format_big_endian()

int snd_pcm_format_big_endian ( snd_pcm_format_t  format)

Return endian info for a PCM sample format.

Parameters
formatFormat
Returns
0 little endian, 1 big endian, a negative error code if endian independent
Examples
/test/pcm.c.

◆ snd_pcm_format_cpu_endian()

int snd_pcm_format_cpu_endian ( snd_pcm_format_t  format)

Return endian info for a PCM sample format.

Parameters
formatFormat
Returns
0 swapped, 1 CPU endian, a negative error code if endian independent

◆ snd_pcm_format_float()

int snd_pcm_format_float ( snd_pcm_format_t  format)

Return float info for a PCM sample format.

Parameters
formatFormat
Returns
0 non float, 1 float

◆ snd_pcm_format_linear()

int snd_pcm_format_linear ( snd_pcm_format_t  format)

Return linear info for a PCM sample format.

Parameters
formatFormat
Returns
0 non linear, 1 linear
Examples
/test/pcm.c.

◆ snd_pcm_format_little_endian()

int snd_pcm_format_little_endian ( snd_pcm_format_t  format)

Return endian info for a PCM sample format.

Parameters
formatFormat
Returns
0 big endian, 1 little endian, a negative error code if endian independent

◆ snd_pcm_format_physical_width()

int snd_pcm_format_physical_width ( snd_pcm_format_t  format)

Return bits needed to store a PCM sample.

Parameters
formatSample format
Returns
bits per sample, a negative error code if not applicable
Examples
/test/pcm.c.

◆ snd_pcm_format_set_silence()

int snd_pcm_format_set_silence ( snd_pcm_format_t  format,
void *  data,
unsigned int  samples 
)

Silence a PCM samples buffer.

Parameters
formatSample format
dataBuffer
samplesSamples count
Returns
0 if successful or a negative error code
Examples
/test/latency.c.

◆ snd_pcm_format_signed()

int snd_pcm_format_signed ( snd_pcm_format_t  format)

Return sign info for a PCM sample linear format.

Parameters
formatFormat
Returns
0 unsigned, 1 signed, a negative error code if format is not linear

◆ snd_pcm_format_silence()

uint8_t snd_pcm_format_silence ( snd_pcm_format_t  format)

Return 8 bit expressing silence for a PCM sample format.

Parameters
formatSample format
Returns
silence 8 bit word

◆ snd_pcm_format_silence_16()

uint16_t snd_pcm_format_silence_16 ( snd_pcm_format_t  format)

Return 16 bit expressing silence for a PCM sample format.

Parameters
formatSample format
Returns
silence 16 bit word

◆ snd_pcm_format_silence_32()

uint32_t snd_pcm_format_silence_32 ( snd_pcm_format_t  format)

Return 32 bit expressing silence for a PCM sample format.

Parameters
formatSample format
Returns
silence 32 bit word

◆ snd_pcm_format_silence_64()

uint64_t snd_pcm_format_silence_64 ( snd_pcm_format_t  format)

Return 64 bit expressing silence for a PCM sample format.

Parameters
formatSample format
Returns
silence 64 bit word

◆ snd_pcm_format_size()

ssize_t snd_pcm_format_size ( snd_pcm_format_t  format,
size_t  samples 
)

Return bytes needed to store a quantity of PCM sample.

Parameters
formatSample format
samplesSamples count
Returns
bytes needed, a negative error code if not integer or unknown

◆ snd_pcm_format_unsigned()

int snd_pcm_format_unsigned ( snd_pcm_format_t  format)

Return sign info for a PCM sample linear format.

Parameters
formatFormat
Returns
0 signed, 1 unsigned, a negative error code if format is not linear
Examples
/test/pcm.c.

◆ snd_pcm_format_width()

int snd_pcm_format_width ( snd_pcm_format_t  format)

Return nominal bits per a PCM sample.

Parameters
formatSample format
Returns
bits per sample, a negative error code if not applicable
Examples
/test/latency.c, and /test/pcm.c.

◆ snd_pcm_frames_to_bytes()

ssize_t snd_pcm_frames_to_bytes ( snd_pcm_t pcm,
snd_pcm_sframes_t  frames 
)

Convert frames in bytes for a PCM.

Parameters
pcmPCM handle
framesquantity in frames
Returns
quantity expressed in bytes

◆ snd_pcm_samples_to_bytes()

ssize_t snd_pcm_samples_to_bytes ( snd_pcm_t pcm,
long  samples 
)

Convert samples in bytes for a PCM.

Parameters
pcmPCM handle
samplesquantity in samples
Returns
quantity expressed in bytes