src/audio_format.h File Reference

#include <glib.h>
#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_P32,
  SAMPLE_FORMAT_S32, SAMPLE_FORMAT_FLOAT, SAMPLE_FORMAT_DSD
}

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 G_GNUC_PURE bool audio_format_valid (const struct audio_format *af)
 Returns false if the format is not valid for playback with MPD.
static G_GNUC_PURE 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)
void audio_format_mask_apply (struct audio_format *af, const struct audio_format *mask)
static G_GNUC_CONST unsigned sample_format_size (enum sample_format format)
static G_GNUC_PURE unsigned audio_format_sample_size (const struct audio_format *af)
 Returns the size of each (mono) sample in bytes.
static G_GNUC_PURE unsigned audio_format_frame_size (const struct audio_format *af)
 Returns the size of each full frame in bytes.
static G_GNUC_PURE 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.
G_GNUC_PURE G_GNUC_MALLOC
const char * 
sample_format_to_string (enum sample_format format)
 Renders a sample_format enum into a string, e.g.
G_GNUC_PURE G_GNUC_MALLOC
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.

Variables

static const unsigned MAX_CHANNELS = 8

Enumeration Type Documentation

Enumerator:
SAMPLE_FORMAT_UNDEFINED 
SAMPLE_FORMAT_S8 
SAMPLE_FORMAT_S16 
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 
SAMPLE_FORMAT_FLOAT 

32 bit floating point samples in the host's format.

The range is -1.0f to +1.0f.

SAMPLE_FORMAT_DSD 

Direct Stream Digital.

1-bit samples; each frame has one byte (8 samples) per channel.

Definition at line 28 of file audio_format.h.


Function Documentation

static void audio_format_clear ( struct audio_format af  )  [inline, static]

Clears the audio_format object, i.e.

sets all attributes to an undefined (invalid) value.

Definition at line 92 of file audio_format.h.

static bool audio_format_defined ( const struct audio_format af  )  [inline, static]

Checks whether the specified audio_format object has a defined value.

Definition at line 116 of file audio_format.h.

static bool audio_format_equals ( const struct audio_format a,
const struct audio_format b 
) [inline, static]

Definition at line 214 of file audio_format.h.

static G_GNUC_PURE unsigned audio_format_frame_size ( const struct audio_format af  )  [inline, static]

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  )  [inline, static]

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 127 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 
) [inline, static]

Initializes an audio_format object, i.e.

sets all attributes to valid values.

Definition at line 103 of file audio_format.h.

void audio_format_mask_apply ( struct audio_format af,
const struct audio_format mask 
)
static bool audio_format_mask_defined ( const struct audio_format af  )  [inline, static]

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

Definition at line 138 of file audio_format.h.

static G_GNUC_PURE bool audio_format_mask_valid ( const struct audio_format af  )  [inline, static]

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

This function performs some basic validity checks.

Definition at line 205 of file audio_format.h.

static G_GNUC_PURE unsigned audio_format_sample_size ( const struct audio_format af  )  [inline, static]

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

Definition at line 258 of file audio_format.h.

static G_GNUC_PURE double audio_format_time_to_size ( const struct audio_format af  )  [inline, static]

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

Definition at line 278 of file audio_format.h.

G_GNUC_PURE G_GNUC_MALLOC 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:
af the audio_format object
s a buffer to print into
Returns:
the string, or NULL if the audio_format object is invalid
static G_GNUC_PURE bool audio_format_valid ( const struct audio_format af  )  [inline, static]

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

This function performs some basic validity checks.

Definition at line 193 of file audio_format.h.

static bool audio_valid_channel_count ( unsigned  channels  )  [inline, static]

Checks whether the number of channels is valid.

Definition at line 183 of file audio_format.h.

static bool audio_valid_sample_format ( enum sample_format  format  )  [inline, static]

Checks whether the sample format is valid.

Parameters:
bits the number of significant bits per sample

Definition at line 161 of file audio_format.h.

static bool audio_valid_sample_rate ( unsigned  sample_rate  )  [inline, static]

Checks whether the sample rate is valid.

Parameters:
sample_rate the sample rate in Hz

Definition at line 150 of file audio_format.h.

static G_GNUC_CONST unsigned sample_format_size ( enum sample_format  format  )  [inline, static]

Definition at line 228 of file audio_format.h.

G_GNUC_PURE G_GNUC_MALLOC 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:
format a sample_format enum value
Returns:
the string

Variable Documentation

const unsigned MAX_CHANNELS = 8 [static]

Definition at line 55 of file audio_format.h.


Generated on 9 Aug 2013 for MPD by  doxygen 1.6.1