sample.h File Reference

Constants and routines for sample type handling. More...

Go to the source code of this file.

Data Structures

struct  pa_sample_spec
 A sample format and attribute specification. More...

Defines

#define PA_CHANNELS_MAX   32
 Maximum number of allowed channels.
#define PA_RATE_MAX   (48000*4)
 Maximum allowed sample rate.
#define PA_SAMPLE_S16NE   PA_SAMPLE_S16LE
 Signed 16 Bit PCM, native endian.
#define PA_SAMPLE_FLOAT32NE   PA_SAMPLE_FLOAT32LE
 32 Bit IEEE floating point, native endian
#define PA_SAMPLE_S32NE   PA_SAMPLE_S32LE
 Signed 32 Bit PCM, native endian.
#define PA_SAMPLE_S16RE   PA_SAMPLE_S16BE
 Signed 16 Bit PCM reverse endian.
#define PA_SAMPLE_FLOAT32RE   PA_SAMPLE_FLOAT32BE
 32 Bit IEEE floating point, reverse endian
#define PA_SAMPLE_S32RE   PA_SAMPLE_S32BE
 Signed 32 Bit PCM reverse endian.
#define PA_SAMPLE_FLOAT32   PA_SAMPLE_FLOAT32NE
 A Shortcut for PA_SAMPLE_FLOAT32NE.
#define PA_SAMPLE_SPEC_SNPRINT_MAX   32
 Maximum required string length for pa_sample_spec_snprint().

Typedefs

typedef enum pa_sample_format pa_sample_format_t
 Sample format.
typedef uint64_t pa_usec_t
 Type for usec specifications (unsigned).

Enumerations

enum  pa_sample_format {
  PA_SAMPLE_U8,
  PA_SAMPLE_ALAW,
  PA_SAMPLE_ULAW,
  PA_SAMPLE_S16LE,
  PA_SAMPLE_S16BE,
  PA_SAMPLE_FLOAT32LE,
  PA_SAMPLE_FLOAT32BE,
  PA_SAMPLE_S32LE,
  PA_SAMPLE_S32BE,
  PA_SAMPLE_MAX,
  PA_SAMPLE_INVALID = -1
}
 Sample format. More...

Functions

size_t pa_bytes_per_second (const pa_sample_spec *spec) PA_GCC_PURE
 Return the amount of bytes playback of a second of audio with the specified sample type takes.
size_t pa_frame_size (const pa_sample_spec *spec) PA_GCC_PURE
 Return the size of a frame with the specific sample type.
size_t pa_sample_size (const pa_sample_spec *spec) PA_GCC_PURE
 Return the size of a sample with the specific sample type.
pa_usec_t pa_bytes_to_usec (uint64_t length, const pa_sample_spec *spec) PA_GCC_PURE
 Calculate the time the specified bytes take to play with the specified sample type.
size_t pa_usec_to_bytes (pa_usec_t t, const pa_sample_spec *spec) PA_GCC_PURE
 Calculates the number of bytes that are required for the specified time.
int pa_sample_spec_valid (const pa_sample_spec *spec) PA_GCC_PURE
 Return non-zero when the sample type specification is valid.
int pa_sample_spec_equal (const pa_sample_spec *a, const pa_sample_spec *b) PA_GCC_PURE
 Return non-zero when the two sample type specifications match.
const char * pa_sample_format_to_string (pa_sample_format_t f) PA_GCC_PURE
 Return a descriptive string for the specified sample format.
pa_sample_format_t pa_parse_sample_format (const char *format) PA_GCC_PURE
 Parse a sample format text.
char * pa_sample_spec_snprint (char *s, size_t l, const pa_sample_spec *spec)
 Pretty print a sample type specification to a string.
char * pa_bytes_snprint (char *s, size_t l, unsigned v)
 Pretty print a byte size value.


Detailed Description

Constants and routines for sample type handling.


Define Documentation

#define PA_CHANNELS_MAX   32

Maximum number of allowed channels.

#define PA_RATE_MAX   (48000*4)

Maximum allowed sample rate.

#define PA_SAMPLE_FLOAT32   PA_SAMPLE_FLOAT32NE

A Shortcut for PA_SAMPLE_FLOAT32NE.

#define PA_SAMPLE_FLOAT32NE   PA_SAMPLE_FLOAT32LE

32 Bit IEEE floating point, native endian

Examples:
paplay.c.

#define PA_SAMPLE_FLOAT32RE   PA_SAMPLE_FLOAT32BE

32 Bit IEEE floating point, reverse endian

#define PA_SAMPLE_S16NE   PA_SAMPLE_S16LE

Signed 16 Bit PCM, native endian.

Examples:
paplay.c.

#define PA_SAMPLE_S16RE   PA_SAMPLE_S16BE

Signed 16 Bit PCM reverse endian.

#define PA_SAMPLE_S32NE   PA_SAMPLE_S32LE

Signed 32 Bit PCM, native endian.

#define PA_SAMPLE_S32RE   PA_SAMPLE_S32BE

Signed 32 Bit PCM reverse endian.

#define PA_SAMPLE_SPEC_SNPRINT_MAX   32

Maximum required string length for pa_sample_spec_snprint().

Examples:
pacat.c, and paplay.c.


Typedef Documentation

Sample format.

typedef uint64_t pa_usec_t

Type for usec specifications (unsigned).

May be either 32 or 64 bit, depending on the architecture

Examples:
pacat-simple.c, and pacat.c.


Enumeration Type Documentation

Sample format.

Enumerator:
PA_SAMPLE_U8  Unsigned 8 Bit PCM.
PA_SAMPLE_ALAW  8 Bit a-Law
PA_SAMPLE_ULAW  8 Bit mu-Law
PA_SAMPLE_S16LE  Signed 16 Bit PCM, little endian (PC).
PA_SAMPLE_S16BE  Signed 16 Bit PCM, big endian.
PA_SAMPLE_FLOAT32LE  32 Bit IEEE floating point, little endian, range -1 to 1
PA_SAMPLE_FLOAT32BE  32 Bit IEEE floating point, big endian, range -1 to 1
PA_SAMPLE_S32LE  Signed 32 Bit PCM, little endian (PC).
PA_SAMPLE_S32BE  Signed 32 Bit PCM, big endian (PC).
PA_SAMPLE_MAX  Upper limit of valid sample types.
PA_SAMPLE_INVALID  An invalid value.


Function Documentation

size_t pa_bytes_per_second ( const pa_sample_spec spec  ) 

Return the amount of bytes playback of a second of audio with the specified sample type takes.

char* pa_bytes_snprint ( char *  s,
size_t  l,
unsigned  v 
)

Pretty print a byte size value.

(i.e. "2.5 MiB")

pa_usec_t pa_bytes_to_usec ( uint64_t  length,
const pa_sample_spec spec 
)

Calculate the time the specified bytes take to play with the specified sample type.

size_t pa_frame_size ( const pa_sample_spec spec  ) 

Return the size of a frame with the specific sample type.

Examples:
paplay.c.

pa_sample_format_t pa_parse_sample_format ( const char *  format  ) 

Parse a sample format text.

Inverse of pa_sample_format_to_string()

Examples:
pacat.c.

const char* pa_sample_format_to_string ( pa_sample_format_t  f  ) 

Return a descriptive string for the specified sample format.

Since:
0.8

size_t pa_sample_size ( const pa_sample_spec spec  ) 

Return the size of a sample with the specific sample type.

int pa_sample_spec_equal ( const pa_sample_spec a,
const pa_sample_spec b 
)

Return non-zero when the two sample type specifications match.

char* pa_sample_spec_snprint ( char *  s,
size_t  l,
const pa_sample_spec spec 
)

Pretty print a sample type specification to a string.

Examples:
pacat.c, and paplay.c.

int pa_sample_spec_valid ( const pa_sample_spec spec  ) 

Return non-zero when the sample type specification is valid.

Examples:
pacat.c, and paplay.c.

size_t pa_usec_to_bytes ( pa_usec_t  t,
const pa_sample_spec spec 
)

Calculates the number of bytes that are required for the specified time.

Since:
0.9


Generated on Mon Sep 29 02:44:36 2008 for PulseAudio by  doxygen 1.5.6