Audio Codec¶
Overview¶
The Audio Codec API provides access to digital audio codecs.
API Reference¶
-
group
audio_codec_interface
Abstraction for audio codecs.
Enums
-
enum
audio_pcm_rate_t
¶ PCM audio sample rates
Values:
-
enumerator
AUDIO_PCM_RATE_8K
¶
-
enumerator
AUDIO_PCM_RATE_16K
¶
-
enumerator
AUDIO_PCM_RATE_24K
¶
-
enumerator
AUDIO_PCM_RATE_32K
¶
-
enumerator
AUDIO_PCM_RATE_44P1K
¶
-
enumerator
AUDIO_PCM_RATE_48K
¶
-
enumerator
AUDIO_PCM_RATE_96K
¶
-
enumerator
AUDIO_PCM_RATE_192K
¶
-
enumerator
-
enum
audio_pcm_width_t
¶ PCM audio sample bit widths
Values:
-
enumerator
AUDIO_PCM_WIDTH_16_BITS
¶
-
enumerator
AUDIO_PCM_WIDTH_20_BITS
¶
-
enumerator
AUDIO_PCM_WIDTH_24_BITS
¶
-
enumerator
AUDIO_PCM_WIDTH_32_BITS
¶
-
enumerator
-
enum
audio_dai_type_t
¶ Digital Audio Interface (DAI) type
Values:
-
enumerator
AUDIO_DAI_TYPE_I2S
¶
-
enumerator
AUDIO_DAI_TYPE_INVALID
¶
-
enumerator
-
enum
audio_property_t
¶ Codec properties that can be set by audio_codec_set_property()
Values:
-
enumerator
AUDIO_PROPERTY_OUTPUT_VOLUME
¶
-
enumerator
AUDIO_PROPERTY_OUTPUT_MUTE
¶
-
enumerator
-
enum
audio_channel_t
¶ Audio channel identifiers to use in audio_codec_set_property()
Values:
-
enumerator
AUDIO_CHANNEL_FRONT_LEFT
¶
-
enumerator
AUDIO_CHANNEL_FRONT_RIGHT
¶
-
enumerator
AUDIO_CHANNEL_LFE
¶
-
enumerator
AUDIO_CHANNEL_FRONT_CENTER
¶
-
enumerator
AUDIO_CHANNEL_REAR_LEFT
¶
-
enumerator
AUDIO_CHANNEL_REAR_RIGHT
¶
-
enumerator
AUDIO_CHANNEL_REAR_CENTER
¶
-
enumerator
AUDIO_CHANNEL_SIDE_LEFT
¶
-
enumerator
AUDIO_CHANNEL_SIDE_RIGHT
¶
-
enumerator
AUDIO_CHANNEL_ALL
¶
-
enumerator
Functions
-
int
audio_codec_configure
(const struct device *dev, struct audio_codec_cfg *cfg)¶ Configure the audio codec.
Configure the audio codec device according to the configuration parameters provided as input
- Return
0 on success, negative error code on failure
- Parameters
dev
: Pointer to the device structure for codec driver instance.cfg
: Pointer to the structure containing the codec configuration.
-
void
audio_codec_start_output
(const struct device *dev)¶ Set codec to start output audio playback.
Setup the audio codec device to start the audio playback
- Return
none
- Parameters
dev
: Pointer to the device structure for codec driver instance.
-
void
audio_codec_stop_output
(const struct device *dev)¶ Set codec to stop output audio playback.
Setup the audio codec device to stop the audio playback
- Return
none
- Parameters
dev
: Pointer to the device structure for codec driver instance.
-
int
audio_codec_set_property
(const struct device *dev, audio_property_t property, audio_channel_t channel, audio_property_value_t val)¶ Set a codec property defined by audio_property_t.
Set a property such as volume level, clock configuration etc.
- Return
0 on success, negative error code on failure
- Parameters
dev
: Pointer to the device structure for codec driver instance.property
: The codec property to setchannel
: The audio channel for which the property has to be setval
: pointer to a property value of type audio_codec_property_value_t
-
int
audio_codec_apply_properties
(const struct device *dev)¶ Atomically apply any cached properties.
Following one or more invocations of audio_codec_set_property, that may have been cached by the driver, audio_codec_apply_properties can be invoked to apply all the properties as atomic as possible
- Return
0 on success, negative error code on failure
- Parameters
dev
: Pointer to the device structure for codec driver instance.
-
union
audio_dai_cfg_t
¶ - #include <codec.h>
Digital Audio Interface Configuration Configuration is dependent on DAI type
Public Members
-
struct i2s_config
i2s
¶
-
struct i2s_config
-
struct
audio_codec_cfg
¶ - #include <codec.h>
Codec configuration parameters
-
union
audio_property_value_t
¶ - #include <codec.h>
Codec property values
-
enum