esp32-audio-player 0.1.0
Audio player engine for ESP32
Loading...
Searching...
No Matches
esp32.h File Reference

ESP32 runtime: connects the portable core to ESP-IDF and runs the player in its own task. More...

Include dependency graph for esp32.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  audio_player_esp32_config_t
 

Macros

#define AUDIO_PLAYER_ESP32_CONFIG_DEFAULT()
 The audio task runs on the second core of dual-core chips, away from Wi-Fi and Bluetooth.
 

Functions

void audio_player_port_init (core_log_level_t max_level)
 Idempotent. max_level limits the core's log output (CORE_LOG_INFO is a good default).
 
player_t * audio_player_start (const audio_player_esp32_config_t *cfg)
 Initialise the port, create the player and start its audio task.
 
void audio_player_stop (player_t *p)
 Stop the audio task and destroy the player.
 

Detailed Description

ESP32 runtime: connects the portable core to ESP-IDF and runs the player in its own task.

audio_player_esp32_config_t cfg = AUDIO_PLAYER_ESP32_CONFIG_DEFAULT(); cfg.sink = audio_i2s_sink_create(&i2s_cfg); player_t *p = audio_player_start(&cfg); queue_item_t item = {.track_id = LIB_ID_NONE, .path = "/sdcard/music/song.flac"}; player_cmd_play_items(p, &item, 1, 0, false);

audio_player_port_init() installs the platform hooks of audio_player/base.h:

  • memory: core_malloc() (decoder state, read buffers, FIFOs) prefers PSRAM when the board has it, core_malloc_fast() uses internal RAM;
  • logging through ESP_LOG with the core's tags;
  • FreeRTOS recursive mutexes for the core locks;
  • esp_timer for core_now_ms(). audio_player_start() calls it, so most applications never call it themselves.

Macro Definition Documentation

◆ AUDIO_PLAYER_ESP32_CONFIG_DEFAULT

#define AUDIO_PLAYER_ESP32_CONFIG_DEFAULT ( )
Value:
{ \
.sink = NULL, .library = NULL, .state_dir = NULL, .scrobble_log = false, .volume_default_db = -20.0f, \
.volume_max_db = 0.0f, .volume_step_db = 1.0f, .task_stack = 24576, .task_priority = 18, \
.task_core = 1, .on_event = NULL, .on_event_user = NULL, .log_level = CORE_LOG_INFO, \
}
@ CORE_LOG_INFO
Definition base.h:63

The audio task runs on the second core of dual-core chips, away from Wi-Fi and Bluetooth.

Function Documentation

◆ audio_player_port_init()

void audio_player_port_init ( core_log_level_t  max_level)

Idempotent. max_level limits the core's log output (CORE_LOG_INFO is a good default).

◆ audio_player_start()

player_t * audio_player_start ( const audio_player_esp32_config_t *  cfg)

Initialise the port, create the player and start its audio task.

NULL on failure. With state_dir set, call player_restore_state() next to continue where the last session ended.

◆ audio_player_stop()

void audio_player_stop ( player_t *  p)

Stop the audio task and destroy the player.

The sink stays: destroy it afterwards. Not from on_event (it runs on the audio task). With Bluetooth, call a2dp_xq_deinit() first: its remote callback holds the player pointer.