MPD
Data Structures | Enumerations | Functions
audio_format.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>

Go to the source code of this file.

Data Structures

struct  audio_format
 This structure describes the format of a raw PCM stream. More...
 
struct  audio_format_string
 Buffer for audio_format_string(). More...
 

Enumerations

enum  sample_format {
  SAMPLE_FORMAT_UNDEFINED = 0, SAMPLE_FORMAT_S8, SAMPLE_FORMAT_S16, SAMPLE_FORMAT_S24,
  SAMPLE_FORMAT_S24_P32, SAMPLE_FORMAT_S32
}
 

Functions

static void audio_format_clear (struct audio_format *af)
 Clears the audio_format object, i.e.
 
static void audio_format_init (struct audio_format *af, uint32_t sample_rate, enum sample_format format, uint8_t channels)
 Initializes an audio_format object, i.e.
 
static bool audio_format_defined (const struct audio_format *af)
 Checks whether the specified audio_format object has a defined value.
 
static bool audio_format_fully_defined (const struct audio_format *af)
 Checks whether the specified audio_format object is full, i.e.
 
static bool audio_format_mask_defined (const struct audio_format *af)
 Checks whether the specified audio_format object has at least one defined value.
 
static bool audio_valid_sample_rate (unsigned sample_rate)
 Checks whether the sample rate is valid.
 
static bool audio_valid_sample_format (enum sample_format format)
 Checks whether the sample format is valid.
 
static bool audio_valid_channel_count (unsigned channels)
 Checks whether the number of channels is valid.
 
static bool audio_format_valid (const struct audio_format *af)
 Returns false if the format is not valid for playback with MPD.
 
static bool audio_format_mask_valid (const struct audio_format *af)
 Returns false if the format mask is not valid for playback with MPD.
 
static bool audio_format_equals (const struct audio_format *a, const struct audio_format *b)
 
static void audio_format_mask_apply (struct audio_format *af, const struct audio_format *mask)
 
static unsigned audio_format_sample_size (const struct audio_format *af)
 Returns the size of each (mono) sample in bytes.
 
static unsigned audio_format_frame_size (const struct audio_format *af)
 Returns the size of each full frame in bytes.
 
static double audio_format_time_to_size (const struct audio_format *af)
 Returns the floating point factor which converts a time span to a storage size in bytes.
 
const char * sample_format_to_string (enum sample_format format)
 Renders a sample_format enum into a string, e.g.
 
const char * audio_format_to_string (const struct audio_format *af, struct audio_format_string *s)
 Renders the audio_format object into a string, e.g.
 

Enumeration Type Documentation

Enumerator:
SAMPLE_FORMAT_UNDEFINED 
SAMPLE_FORMAT_S8 
SAMPLE_FORMAT_S16 
SAMPLE_FORMAT_S24 

Signed 24 bit integer samples, without padding.

SAMPLE_FORMAT_S24_P32 

Signed 24 bit integer samples, packed in 32 bit integers (the most significant byte is filled with the sign bit).

SAMPLE_FORMAT_S32 

Definition at line 27 of file audio_format.h.

Function Documentation

static void audio_format_clear ( struct audio_format af)
inlinestatic

Clears the audio_format object, i.e.

sets all attributes to an undefined (invalid) value.

Definition at line 89 of file audio_format.h.

static bool audio_format_defined ( const struct audio_format af)
inlinestatic

Checks whether the specified audio_format object has a defined value.

Definition at line 115 of file audio_format.h.

static bool audio_format_equals ( const struct audio_format a,
const struct audio_format b 
)
inlinestatic

Definition at line 210 of file audio_format.h.

static unsigned audio_format_frame_size ( const struct audio_format af)
inlinestatic

Returns the size of each full frame in bytes.

Definition at line 268 of file audio_format.h.

static bool audio_format_fully_defined ( const struct audio_format af)
inlinestatic

Checks whether the specified audio_format object is full, i.e.

all attributes are defined. This is more complete than audio_format_defined(), but slower.

Definition at line 126 of file audio_format.h.

static void audio_format_init ( struct audio_format af,
uint32_t  sample_rate,
enum sample_format  format,
uint8_t  channels 
)
inlinestatic

Initializes an audio_format object, i.e.

sets all attributes to valid values.

Definition at line 101 of file audio_format.h.

static void audio_format_mask_apply ( struct audio_format af,
const struct audio_format mask 
)
inlinestatic

Definition at line 220 of file audio_format.h.

static bool audio_format_mask_defined ( const struct audio_format af)
inlinestatic

Checks whether the specified audio_format object has at least one defined value.

Definition at line 137 of file audio_format.h.

static bool audio_format_mask_valid ( const struct audio_format af)
inlinestatic

Returns false if the format mask is not valid for playback with MPD.

This function performs some basic validity checks.

Definition at line 201 of file audio_format.h.

static unsigned audio_format_sample_size ( const struct audio_format af)
inlinestatic

Returns the size of each (mono) sample in bytes.

Definition at line 241 of file audio_format.h.

static double audio_format_time_to_size ( const struct audio_format af)
inlinestatic

Returns the floating point factor which converts a time span to a storage size in bytes.

Definition at line 277 of file audio_format.h.

const char* audio_format_to_string ( const struct audio_format af,
struct audio_format_string s 
)

Renders the audio_format object into a string, e.g.

for printing it in a log file.

Parameters
afthe audio_format object
sa buffer to print into
Returns
the string, or NULL if the audio_format object is invalid
static bool audio_format_valid ( const struct audio_format af)
inlinestatic

Returns false if the format is not valid for playback with MPD.

This function performs some basic validity checks.

Definition at line 190 of file audio_format.h.

static bool audio_valid_channel_count ( unsigned  channels)
inlinestatic

Checks whether the number of channels is valid.

Definition at line 181 of file audio_format.h.

static bool audio_valid_sample_format ( enum sample_format  format)
inlinestatic

Checks whether the sample format is valid.

Parameters
bitsthe number of significant bits per sample

Definition at line 160 of file audio_format.h.

static bool audio_valid_sample_rate ( unsigned  sample_rate)
inlinestatic

Checks whether the sample rate is valid.

Parameters
sample_ratethe sample rate in Hz

Definition at line 149 of file audio_format.h.

const char* sample_format_to_string ( enum sample_format  format)

Renders a sample_format enum into a string, e.g.

for printing it in a log file.

Parameters
formata sample_format enum value
Returns
the string