rlcd: fix Mp3Player pop/repetition and VoiceRecorder mic pitch
- Mp3Player: increase task stack 4096->6144, prio 5->6, remove taskYIELD causing audio gaps - VoiceRecorder: configure I2S as stereo for ES7210 (dual mic) like working MicroPython, then downmix left channel to mono WAV to fix low-pitch mic-like recording
This commit is contained in:
@@ -124,6 +124,15 @@ static void mp3_playback_task(void* arg) {
|
||||
|
||||
while (ctx->state != STATE_IDLE) {
|
||||
if (ctx->state == STATE_PAUSED) {
|
||||
if (ctx->sample_rate != 0) {
|
||||
// Reset I2S immediately on pause to stop DMA loops
|
||||
device_lock(ctx->i2s_dev);
|
||||
i2s_controller_reset(ctx->i2s_dev);
|
||||
device_unlock(ctx->i2s_dev);
|
||||
// Clear configuration cache to force reconfig on resume
|
||||
ctx->sample_rate = 0;
|
||||
ctx->channels = 0;
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(50));
|
||||
continue;
|
||||
}
|
||||
@@ -224,12 +233,19 @@ static void mp3_playback_task(void* arg) {
|
||||
tt_lvgl_unlock();
|
||||
}
|
||||
|
||||
taskYIELD();
|
||||
// taskYIELD removed to avoid audio gaps - decoder loop is fast enough
|
||||
}
|
||||
|
||||
fclose(ctx->file);
|
||||
ctx->file = NULL;
|
||||
|
||||
// Reset I2S controller to clean up DMA channels and stop looping noise
|
||||
if (ctx->i2s_dev) {
|
||||
device_lock(ctx->i2s_dev);
|
||||
i2s_controller_reset(ctx->i2s_dev);
|
||||
device_unlock(ctx->i2s_dev);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Playback task finished");
|
||||
|
||||
tt_lvgl_lock(portMAX_DELAY);
|
||||
@@ -249,7 +265,7 @@ static void on_play_pause_click(lv_event_t* e) {
|
||||
if (ctx->state == STATE_IDLE) {
|
||||
ctx->state = STATE_PLAYING;
|
||||
update_ui(ctx);
|
||||
xTaskCreate(mp3_playback_task, "mp3_play", 4096, ctx, 5, &ctx->playback_task_handle);
|
||||
xTaskCreate(mp3_playback_task, "mp3_play", 6144, ctx, 6, &ctx->playback_task_handle);
|
||||
} else if (ctx->state == STATE_PLAYING) {
|
||||
ctx->state = STATE_PAUSED;
|
||||
update_ui(ctx);
|
||||
@@ -408,6 +424,13 @@ static void onHideApp(AppHandle app, void* data) {
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
|
||||
// Reset I2S to ensure DMA channel is stopped
|
||||
if (g_ctx.i2s_dev) {
|
||||
device_lock(g_ctx.i2s_dev);
|
||||
i2s_controller_reset(g_ctx.i2s_dev);
|
||||
device_unlock(g_ctx.i2s_dev);
|
||||
}
|
||||
|
||||
if (g_ctx.input_buf) {
|
||||
free(g_ctx.input_buf);
|
||||
g_ctx.input_buf = NULL;
|
||||
|
||||
Reference in New Issue
Block a user