|
TB2026-YDS Firmware
|
play/pause/resume/stop/next/prev over the playlist, with auto-advance on EOF. More...

Files | |
| file | components/services/audio/player.c |
| Playback transport state machine over the playlist and pipeline. | |
Data Structures | |
| struct | player_status_t |
| Snapshot of the transport for the UI. More... | |
Enumerations | |
| enum | player_state_t { PLAYER_STOPPED , PLAYER_PLAYING , PLAYER_PAUSED } |
| Transport state. More... | |
Functions | |
| esp_err_t | player_init (void) |
| Register the player with the pipeline's end-of-track callback. Call once at startup. | |
| esp_err_t | player_set_output (volume_output_t out) |
| Select the output and keep the volume routing consistent. | |
| void | player_poll (void) |
| Complete a deferred Bluetooth start once the speaker acknowledges the volume. | |
| esp_err_t | player_play (size_t index) |
Play the storage track at index (stops any current stream first). | |
| esp_err_t | player_start (void) |
| Start playback from the stopped state (e.g. first play after boot). | |
| esp_err_t | player_pause (void) |
| Pause the current playback (sink down, position kept). | |
| esp_err_t | player_resume (void) |
| Resume a paused playback. | |
| esp_err_t | player_stop (void) |
| Stop playback and power the output down. | |
| esp_err_t | player_next (void) |
| Skip to the next track (respecting the playlist's repeat/shuffle order). | |
| esp_err_t | player_prev (void) |
| Step to the previous track. Mirror of player_next. | |
| esp_err_t | player_get_state (player_status_t *out) |
| Read the current transport state and track. | |
| void | player_save_resume (void) |
| Persist the current track (path + position) so Now Playing re-selects it after boot. | |
play/pause/resume/stop/next/prev over the playlist, with auto-advance on EOF.
| enum player_state_t |
| esp_err_t player_get_state | ( | player_status_t * | out | ) |
Read the current transport state and track.
| [out] | out | Filled with the snapshot. Must not be NULL. |
out is NULL. | esp_err_t player_init | ( | void | ) |
Register the player with the pipeline's end-of-track callback. Call once at startup.
| esp_err_t player_next | ( | void | ) |
Skip to the next track (respecting the playlist's repeat/shuffle order).
| esp_err_t player_pause | ( | void | ) |
Pause the current playback (sink down, position kept).
| esp_err_t player_play | ( | size_t | index | ) |
Play the storage track at index (stops any current stream first).
If the output is Bluetooth and the speaker has not yet acknowledged the volume, the stream is deferred (never blast) and ESP_OK is returned; player_poll() starts it on the ack.
| index | 0-based storage index (as listed by the UI browser). |
index is out of range; otherwise the pipeline error. | void player_poll | ( | void | ) |
Complete a deferred Bluetooth start once the speaker acknowledges the volume.
Call periodically from the maintenance loop (after volume_poll()). A switch/play to a Bluetooth speaker holds the stream until the volume is acknowledged (never blast); this drives that held start to completion. A no-op when nothing is pending.
| esp_err_t player_prev | ( | void | ) |
Step to the previous track. Mirror of player_next.
| esp_err_t player_resume | ( | void | ) |
Resume a paused playback.
| void player_save_resume | ( | void | ) |
Persist the current track (path + position) so Now Playing re-selects it after boot.
Call before any power-off. Writes "last_path"/"last_pos" to Settings service when a track is loaded (playing or paused); a no-op when stopped (the previous value is kept).
| esp_err_t player_set_output | ( | volume_output_t | out | ) |
Select the output and keep the volume routing consistent.
Points the pipeline at the matching sink and tells the volume service where to send the pot. Selecting the output already in use is a no-op (playback is not disturbed). If a track is currently playing the live stream is re-routed onto the new sink immediately, continuing from its current position (the decoder stays open, no restart); otherwise the choice is just remembered for the next playback. This is the single switch point for both manual selection and a future automatic BT connect/disconnect switch.
Bluetooth is referenced only on this path, so a build without BT still links. Switching to VOLUME_OUT_BT primes the speaker's volume and, if a stream is live, holds it until the speaker acknowledges that volume before streaming (never blast) – the switch itself succeeds and player_poll() completes the deferred start. It is refused only when no speaker is connected. VOLUME_OUT_NONE is a valid software mute that cuts the active output.
| out | VOLUME_OUT_DAC (jack), VOLUME_OUT_BT (speaker), or VOLUME_OUT_NONE (mute). |
out is Bluetooth and no speaker is connected; ESP_ERR_INVALID_ARG for any other value; otherwise the pipeline error if a live re-route fails. | esp_err_t player_start | ( | void | ) |
Start playback from the stopped state (e.g. first play after boot).
Plays the playlist's current track. When shuffle is on, the play order is re-shuffled first so a random track starts (see playlist_random). A no-op unless currently stopped. If the output is Bluetooth and the speaker has not yet acknowledged the volume, the stream is deferred (never blast) and ESP_OK is returned; player_poll() starts it on the ack.
| esp_err_t player_stop | ( | void | ) |
Stop playback and power the output down.