编解码器播放接口

[English]

公共头文件: #include "brookesia/hal_interface/interfaces/audio/codec_player.hpp"

类名: AudioCodecPlayerIface

API 参考

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.

参数

config -- [in] Dynamic configuration.

返回

true on success; otherwise false.

virtual void close() = 0

Close the backend.

virtual bool set_volume(uint8_t volume) = 0

Set volume.

参数

volume -- [in] Requested output volume percentage.

返回

true on success; otherwise false.

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

Write PCM/encoded payload to the backend.

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

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

返回

true on success; otherwise false.

virtual bool is_pa_on_off_supported() = 0

Check if the PA control is supported.

返回

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.

参数

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

返回

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.

返回

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.