99
1010#include "esp_audio_render_types.h"
1111#include "esp_gmf_element.h"
12+ #include "esp_gmf_task.h"
1213
1314#ifdef __cplusplus
1415extern "C" {
@@ -18,17 +19,19 @@ extern "C" {
1819 * @brief Audio render configuration
1920 */
2021typedef struct {
21- uint8_t max_stream_num ; /*!< Maximum supported stream number */
22- esp_audio_render_write_cb_t out_writer ; /*!< Audio render write callback */
23- void * out_ctx ; /*!< Audio render write context */
24- esp_audio_render_sample_info_t out_sample_info ; /*!< Output sample information, needs to be aligned with actual device setting */
25- void * pool ; /*!< GMF pool handle */
22+ uint8_t max_stream_num ; /*!< Maximum supported stream number */
23+ esp_audio_render_write_cb_t out_writer ; /*!< Audio render write callback */
24+ void * out_ctx ; /*!< Audio render write context */
25+ esp_audio_render_sample_info_t out_sample_info ; /*!< Output sample information, needs to be aligned with actual device setting */
26+ void * pool ; /*!< GMF pool handle */
2627 uint16_t process_period ; /*!< Audio processing interval in milliseconds (default: 20ms)
2728 This determines how frequently the audio mixer processes input streams
2829 Only valid for multiple streams which need mix processor
2930 - Shorter periods: Faster audio response but require more precise timing
3031 - Longer periods: More tolerant to buffer variations but increase latency
3132 This value controls the ring_fifo size used by `esp_audio_render_stream_write` also */
33+ uint8_t process_buf_align ; /*!< When use hardware or optimized processor may need special buffer alignment
34+ If set to 0, the default value is 16 */
3235} esp_audio_render_cfg_t ;
3336
3437/**
@@ -90,6 +93,25 @@ typedef int (*esp_audio_render_event_cb_t)(esp_audio_render_event_type_t event_t
9093 */
9194esp_audio_render_err_t esp_audio_render_create (esp_audio_render_cfg_t * cfg , esp_audio_render_handle_t * render );
9295
96+ /**
97+ * @brief Reconfigures the audio render task parameters
98+ *
99+ * @note This function must be called when no audio stream is active (no stream is opened yet)
100+ *
101+ * @note Default configuration (applied if never called):
102+ * - `stack_in_ext` = true (task stack allocated in external SPI-RAM)
103+ * - Other parameters use values from Kconfig defaults
104+ *
105+ * @param[in] render Audio render handle
106+ * @param[in] cfg Pointer to task configuration
107+ *
108+ * @return
109+ * - ESP_AUDIO_RENDER_ERR_OK On success
110+ * - ESP_AUDIO_RENDER_ERR_INVALID_ARG Invalid input argument
111+ * - ESP_AUDIO_RENDER_ERR_INVALID_STATE Called when any stream is opened
112+ */
113+ esp_audio_render_err_t esp_audio_render_task_reconfigure (esp_audio_render_handle_t render , esp_gmf_task_config_t * cfg );
114+
93115/**
94116 * @brief Set event callback for audio render
95117 *
@@ -182,6 +204,24 @@ esp_audio_render_err_t esp_audio_render_stream_get(esp_audio_render_handle_t ren
182204 esp_audio_render_stream_id_t stream_id ,
183205 esp_audio_render_stream_handle_t * stream_handle );
184206
207+ /**
208+ * @brief Set mixer gain for audio render stream (optional)
209+ *
210+ * @note Currently only support to set when none stream is opened yet
211+ * When this API not call it will use default mixer gain [0, sqrt(1.0 / max_stream_num)]
212+ * Target gain should be limited to avoid clipping after mixed
213+ *
214+ * @param[in] stream Audio render handle
215+ * @param[in] mixer_gain Mixer gain to set
216+ *
217+ * @return
218+ * - ESP_AUDIO_RENDER_ERR_OK On success
219+ * - ESP_AUDIO_RENDER_ERR_INVALID_ARG Invalid input argument
220+ * - ESP_AUDIO_RENDER_ERR_INVALID_STATE Mixer already running
221+ */
222+ esp_audio_render_err_t esp_audio_render_stream_set_mixer_gain (esp_audio_render_stream_handle_t stream ,
223+ esp_audio_render_mixer_gain_t * mixer_gain );
224+
185225/**
186226 * @brief Open audio render stream
187227 *
@@ -254,6 +294,24 @@ esp_audio_render_err_t esp_audio_render_stream_get_element(esp_audio_render_stre
254294esp_audio_render_err_t esp_audio_render_stream_write (esp_audio_render_stream_handle_t stream ,
255295 uint8_t * pcm_data , uint32_t pcm_size );
256296
297+ /**
298+ * @brief Fade in/out for audio render stream
299+ *
300+ * @note Fade in/out will only take effect in multiple stream cases
301+ * When fade in, mixer gain for this stream will goes from current to target gain
302+ * When fade out, mixer gain for this stream will goes from current to initial gain
303+ * Allow to set during runtime
304+ *
305+ * @param[in] stream Stream handle
306+ * @param[in] fade_in Fade operation (true: fade in, false: fade out)
307+ *
308+ * @return
309+ * - ESP_AUDIO_RENDER_ERR_OK On success
310+ * - ESP_AUDIO_RENDER_ERR_INVALID_ARG Invalid input argument
311+ */
312+ esp_audio_render_err_t esp_audio_render_stream_set_fade (esp_audio_render_stream_handle_t stream ,
313+ bool fade_in );
314+
257315/**
258316 * @brief Pause audio render stream
259317 *
0 commit comments