|
TB2026-YDS Firmware
|
Audio pipeline task: producer->consumer loop from a PCM source to a selectable sink (wired DAC or Bluetooth). More...
#include "pipeline.h"#include "audio_sink.h"#include "sink_i2s_dac.h"#include "decoder.h"#include "freertos/FreeRTOS.h"#include "freertos/task.h"#include "freertos/queue.h"#include "diag.h"#include "esp_log.h"#include "esp_task_wdt.h"#include <math.h>#include <stdlib.h>#include <string.h>#include <stdbool.h>Data Structures | |
| struct | pipe_cmd_t |
Macros | |
| #define | PIPE_FS 44100 |
| #define | PIPE_CHUNK_FRAMES 512 /* PCM frames handed to sink->write() per iteration */ |
| #define | TONE_AMPLITUDE 10000 /* ~ -10 dBFS, safe on headphones */ |
| #define | TONE_VOLUME |
| #define | PIPE_TASK_PRIO 22 /* above UI/maintenance, below IDF system tasks */ |
| #define | PIPE_TASK_CORE 1 /* APP_CPU: keep the audio loop off core 0 (Wi-Fi/BT) */ |
| #define | PIPE_TASK_STACK 4096 |
| #define | PIPE_PATH_MAX 320 /* matches STORAGE_PATH_MAX: "/sdcard/" + LFN + nul */ |
Enumerations | |
| enum | { CMD_PLAY_TONE , CMD_PLAY_FILE , CMD_STOP , CMD_PAUSE , CMD_RESUME , CMD_SWITCH_SINK } |
Functions | |
| esp_err_t | pipeline_init (void) |
| Create the pinned audio task and its command queue. | |
| void | pipeline_set_sink (const audio_sink_t *sink) |
| Select the output backend used by the next playback. | |
| esp_err_t | pipeline_switch_sink (void) |
| Re-route the current playback onto the sink last set by pipeline_set_sink(). | |
| void | pipeline_set_track_end_cb (void(*cb)(pipeline_end_reason_t reason)) |
| Register the callback fired when a file playback ends on its own (EOF or error). | |
| void | pipeline_get_position (uint32_t *elapsed_ms, uint32_t *total_ms) |
| Read a tear-free snapshot of the current playback position. | |
| esp_err_t | pipeline_play_file (const char *path) |
| Play an audio file: decode it to the current sink at the file's own format. | |
| esp_err_t | pipeline_pause (void) |
| Pause file playback: stop feeding the sink while keeping the stream position. | |
| esp_err_t | pipeline_resume (void) |
| Resume a playback paused with pipeline_pause(): restart the sink and keep decoding. | |
| esp_err_t | pipeline_play_tone (uint32_t freq_hz) |
| Bring-up/diagnostic: stream a continuous sine to the current sink. | |
| esp_err_t | pipeline_stop (void) |
| Stop playback and power the output path down. Safe to call when already idle. | |
Audio pipeline task: producer->consumer loop from a PCM source to a selectable sink (wired DAC or Bluetooth).
| #define PIPE_CHUNK_FRAMES 512 /* PCM frames handed to sink->write() per iteration */ |
| #define PIPE_FS 44100 |
| #define PIPE_PATH_MAX 320 /* matches STORAGE_PATH_MAX: "/sdcard/" + LFN + nul */ |
| #define PIPE_TASK_CORE 1 /* APP_CPU: keep the audio loop off core 0 (Wi-Fi/BT) */ |
| #define PIPE_TASK_PRIO 22 /* above UI/maintenance, below IDF system tasks */ |
| #define PIPE_TASK_STACK 4096 |
| #define TONE_AMPLITUDE 10000 /* ~ -10 dBFS, safe on headphones */ |
| #define TONE_VOLUME |