Codec Player Interface

[中文]

Public header: #include "brookesia/hal_interface/interfaces/audio/codec_player.hpp"

Class: AudioCodecPlayerIface

API Reference

Header File

Classes

class AudioCodecPlayerIface : public esp_brookesia::hal::Interface

Player interface exposed by audio-capable devices.

Public Functions

inline AudioCodecPlayerIface()

Construct an audio interface.

virtual ~AudioCodecPlayerIface() = default

Virtual destructor for polymorphic interfaces.

virtual bool open(const Config &config) = 0

Open the backend.

Parameters

config -- [in] Dynamic configuration.

Returns

true on success; otherwise false.

virtual void close() = 0

Close the backend.

virtual bool set_volume(uint8_t volume) = 0

Set volume.

Parameters

volume -- [in] Requested output volume percentage.

Returns

true on success; otherwise false.

virtual bool write_data(const uint8_t *data, size_t size) = 0

Write PCM/encoded payload to the backend.

Parameters
  • data -- [in] Buffer pointer containing audio payload.

  • size -- [in] Buffer size in bytes.

Returns

true on success; otherwise false.

virtual bool is_pa_on_off_supported() = 0

Check if the PA control is supported.

Returns

true if the PA on/off control is supported; otherwise false.

virtual bool set_pa_on_off(bool on) = 0

Set the PA on/off state.

Parameters

on -- [in] true to set the PA to be on; false to set the PA to be off.

Returns

true if the PA on/off state is set successfully; otherwise false.

virtual bool is_pa_on() const = 0

Check if the PA is set on.

Returns

true if the PA is set on; otherwise false.

Public Static Attributes

static constexpr const char *NAME = "AudioCodecPlayer"

Interface registry name.

struct Config

Dynamic configuration.

Public Members

uint8_t bits

Sample bit width.

uint8_t channels

Number of output channels.

uint32_t sample_rate

Output sample rate in Hz.