#include <spdif_encoder.h>
|
| bool | setup () |
| | Initialize the SPDIF working buffer.
|
| |
| void | set_write_callback (SPDIFBlockCallback callback, void *user_ctx) |
| | Set callback for normal writes (used when channel is running)
|
| |
| void | set_preload_callback (SPDIFBlockCallback callback, void *user_ctx) |
| | Set callback for preload writes (used when preloading to DMA before enabling channel)
|
| |
| void | set_preload_mode (bool preload) |
| | Enable or disable preload mode When in preload mode, completed blocks use the preload callback instead of write callback.
|
| |
| bool | is_preload_mode () const |
| | Check if currently in preload mode.
|
| |
| esp_err_t | write (const uint8_t *src, size_t size, TickType_t ticks_to_wait, uint32_t *blocks_sent=nullptr, size_t *bytes_consumed=nullptr) |
| | Convert PCM audio data to SPDIF BMC encoded data.
|
| |
| size_t | get_pending_pcm_bytes () const |
| | Get the number of PCM bytes currently pending in the partial block buffer.
|
| |
| uint32_t | get_pending_frames () const |
| | Get the number of PCM frames currently pending in the partial block buffer.
|
| |
| bool | has_pending_data () const |
| | Check if there is a partial block pending.
|
| |
| esp_err_t | flush_with_silence (TickType_t ticks_to_wait) |
| | Emit one complete SPDIF block: pad any pending partial block with silence and send, or send a full silence block if nothing is pending.
|
| |
| void | reset () |
| | Reset the SPDIF block buffer and position tracking, discarding any partial block.
|
| |
| void | set_sample_rate (uint32_t sample_rate) |
| | Set the sample rate for Channel Status Block encoding.
|
| |
| uint32_t | get_sample_rate () const |
| | Get the currently configured sample rate.
|
| |
|
| HOT void | encode_sample_ (const uint8_t *pcm_sample) |
| | Encode a single 16-bit PCM sample into the current block position.
|
| |
| esp_err_t | send_block_ (TickType_t ticks_to_wait) |
| | Send the completed block via the appropriate callback.
|
| |
| void | build_channel_status_ () |
| | Build the channel status block from current configuration.
|
| |
| ESPHOME_ALWAYS_INLINE bool | get_channel_status_bit_ (uint8_t frame) const |
| | Get the channel status bit for a specific frame.
|
| |
Definition at line 38 of file spdif_encoder.h.
◆ build_channel_status_()
| void esphome::i2s_audio::SPDIFEncoder::build_channel_status_ |
( |
| ) |
|
|
protected |
Build the channel status block from current configuration.
Definition at line 87 of file spdif_encoder.cpp.
◆ encode_sample_()
| HOT void esphome::i2s_audio::SPDIFEncoder::encode_sample_ |
( |
const uint8_t * | pcm_sample | ) |
|
|
protected |
Encode a single 16-bit PCM sample into the current block position.
Definition at line 146 of file spdif_encoder.cpp.
◆ flush_with_silence()
| esp_err_t esphome::i2s_audio::SPDIFEncoder::flush_with_silence |
( |
TickType_t | ticks_to_wait | ) |
|
Emit one complete SPDIF block: pad any pending partial block with silence and send, or send a full silence block if nothing is pending.
Always produces exactly one block on success.
- Parameters
-
| ticks_to_wait | Timeout for blocking writes |
- Returns
- esp_err_t as returned from the callback
Definition at line 360 of file spdif_encoder.cpp.
◆ get_channel_status_bit_()
| ESPHOME_ALWAYS_INLINE bool esphome::i2s_audio::SPDIFEncoder::get_channel_status_bit_ |
( |
uint8_t | frame | ) |
const |
|
inlineprotected |
Get the channel status bit for a specific frame.
- Parameters
-
| frame | Frame number (0-191) |
- Returns
- The C bit value for this frame
Definition at line 118 of file spdif_encoder.h.
◆ get_pending_frames()
| uint32_t esphome::i2s_audio::SPDIFEncoder::get_pending_frames |
( |
| ) |
const |
|
inline |
Get the number of PCM frames currently pending in the partial block buffer.
- Returns
- Number of pending PCM frames (0 to SPDIF_BLOCK_SAMPLES - 1)
Definition at line 83 of file spdif_encoder.h.
◆ get_pending_pcm_bytes()
| size_t esphome::i2s_audio::SPDIFEncoder::get_pending_pcm_bytes |
( |
| ) |
const |
Get the number of PCM bytes currently pending in the partial block buffer.
- Returns
- Number of pending PCM bytes (0 to SPDIF_PCM_BYTES_PER_BLOCK - 1)
Definition at line 298 of file spdif_encoder.cpp.
◆ get_sample_rate()
| uint32_t esphome::i2s_audio::SPDIFEncoder::get_sample_rate |
( |
| ) |
const |
|
inline |
◆ has_pending_data()
| bool esphome::i2s_audio::SPDIFEncoder::has_pending_data |
( |
| ) |
const |
|
inline |
Check if there is a partial block pending.
Definition at line 86 of file spdif_encoder.h.
◆ is_preload_mode()
| bool esphome::i2s_audio::SPDIFEncoder::is_preload_mode |
( |
| ) |
const |
|
inline |
◆ reset()
| void esphome::i2s_audio::SPDIFEncoder::reset |
( |
| ) |
|
Reset the SPDIF block buffer and position tracking, discarding any partial block.
Definition at line 73 of file spdif_encoder.cpp.
◆ send_block_()
| esp_err_t esphome::i2s_audio::SPDIFEncoder::send_block_ |
( |
TickType_t | ticks_to_wait | ) |
|
|
protected |
Send the completed block via the appropriate callback.
Definition at line 271 of file spdif_encoder.cpp.
◆ set_preload_callback()
| void esphome::i2s_audio::SPDIFEncoder::set_preload_callback |
( |
SPDIFBlockCallback | callback, |
|
|
void * | user_ctx ) |
|
inline |
Set callback for preload writes (used when preloading to DMA before enabling channel)
- Parameters
-
| callback | Function pointer to call when a block is ready for preload |
| user_ctx | Context pointer passed to callback (typically 'this' pointer of speaker) |
Definition at line 55 of file spdif_encoder.h.
◆ set_preload_mode()
| void esphome::i2s_audio::SPDIFEncoder::set_preload_mode |
( |
bool | preload | ) |
|
|
inline |
Enable or disable preload mode When in preload mode, completed blocks use the preload callback instead of write callback.
Definition at line 62 of file spdif_encoder.h.
◆ set_sample_rate()
| void esphome::i2s_audio::SPDIFEncoder::set_sample_rate |
( |
uint32_t | sample_rate | ) |
|
Set the sample rate for Channel Status Block encoding.
- Parameters
-
| sample_rate | Sample rate in Hz (e.g., 44100, 48000, 96000) Call this before writing audio data to ensure correct channel status. |
Definition at line 79 of file spdif_encoder.cpp.
◆ set_write_callback()
| void esphome::i2s_audio::SPDIFEncoder::set_write_callback |
( |
SPDIFBlockCallback | callback, |
|
|
void * | user_ctx ) |
|
inline |
Set callback for normal writes (used when channel is running)
- Parameters
-
| callback | Function pointer to call when a block is ready |
| user_ctx | Context pointer passed to callback (typically 'this' pointer of speaker) |
Definition at line 47 of file spdif_encoder.h.
◆ setup()
| bool esphome::i2s_audio::SPDIFEncoder::setup |
( |
| ) |
|
Initialize the SPDIF working buffer.
- Returns
- true if setup was successful, false if allocation failed
Definition at line 58 of file spdif_encoder.cpp.
◆ write()
| HOT esp_err_t esphome::i2s_audio::SPDIFEncoder::write |
( |
const uint8_t * | src, |
|
|
size_t | size, |
|
|
TickType_t | ticks_to_wait, |
|
|
uint32_t * | blocks_sent = nullptr, |
|
|
size_t * | bytes_consumed = nullptr ) |
Convert PCM audio data to SPDIF BMC encoded data.
- Parameters
-
| src | Source PCM audio data (16-bit stereo) |
| size | Size of source data in bytes |
| ticks_to_wait | Timeout for blocking writes |
| blocks_sent | Optional pointer to receive the number of complete SPDIF blocks sent |
| bytes_consumed | Optional pointer to receive the number of PCM bytes consumed from src |
- Returns
- esp_err_t as returned from the callback
Definition at line 309 of file spdif_encoder.cpp.
◆ channel_status_
| std::array<uint8_t, 24> esphome::i2s_audio::SPDIFEncoder::channel_status_ {} |
|
protected |
◆ frame_in_block_
| uint8_t esphome::i2s_audio::SPDIFEncoder::frame_in_block_ {0} |
|
protected |
◆ is_left_channel_
| bool esphome::i2s_audio::SPDIFEncoder::is_left_channel_ {true} |
|
protected |
◆ preload_callback_
◆ preload_callback_ctx_
| void* esphome::i2s_audio::SPDIFEncoder::preload_callback_ctx_ {nullptr} |
|
protected |
◆ preload_mode_
| bool esphome::i2s_audio::SPDIFEncoder::preload_mode_ {false} |
|
protected |
◆ sample_rate_
| uint32_t esphome::i2s_audio::SPDIFEncoder::sample_rate_ {48000} |
|
protected |
◆ spdif_block_buf_
| std::unique_ptr<uint32_t[]> esphome::i2s_audio::SPDIFEncoder::spdif_block_buf_ |
|
protected |
◆ spdif_block_ptr_
| uint32_t* esphome::i2s_audio::SPDIFEncoder::spdif_block_ptr_ {nullptr} |
|
protected |
◆ write_callback_
◆ write_callback_ctx_
| void* esphome::i2s_audio::SPDIFEncoder::write_callback_ctx_ {nullptr} |
|
protected |
The documentation for this class was generated from the following files: