I changed code to:
Code: Select all
DLOGD("[1.0] Start codec chip");
audio_board_handle_t board_handle = audio_board_init();
audio_hal_ctrl_codec(board_handle->audio_hal, AUDIO_HAL_CODEC_MODE_BOTH, AUDIO_HAL_CTRL_START);
audio_hal_set_volume(board_handle->audio_hal, 100);
DLOGD( "[2.0] Create i2s stream to read audio data from codec chip");
i2s_stream_cfg_t i2sr_cfg = I2S_STREAM_CFG_DEFAULT();
i2sr_cfg.type = AUDIO_STREAM_READER;
i2sr_cfg.i2s_config.sample_rate = 48000;
i2sr_cfg.out_rb_size = 16 * 1024; // Increase buffer to avoid missing data in bad network conditions
i2sr_cfg.i2s_port = CODEC_ADC_I2S_PORT;
pFileSrcContext->i2s_stream_reader = i2s_stream_init(&i2sr_cfg);
opus_encoder_cfg_t opus_http_cfg = DEFAULT_OPUS_ENCODER_CONFIG();
opus_http_cfg.out_rb_size = 16 * 1024;
audio_element_handle_t opus_decoder = encoder_opus_init(&opus_http_cfg);
rsp_filter_cfg_t rsp_file_cfg = DEFAULT_RESAMPLE_FILTER_CONFIG();
rsp_file_cfg.src_rate = 48000;
rsp_file_cfg.src_ch = 2;
rsp_file_cfg.dest_rate = 16000;
rsp_file_cfg.dest_ch = 1;
rsp_file_cfg.out_rb_size = 16 * 1024;
audio_element_handle_t resample_for_rec = rsp_filter_init(&rsp_file_cfg);
raw_stream_cfg_t cfg = RAW_STREAM_CFG_DEFAULT();
cfg.type = AUDIO_STREAM_READER;
cfg.out_rb_size = 16 * 1024;
pFileSrcContext->raw_stream_reader = raw_stream_init(&cfg);
// ringbuf_handle_t ringbuf1, ringbuf2;
// ringbuf1 = rb_create(RING_BUFFER_SIZE, 1);
// audio_element_set_output_ringbuf(pFileSrcContext->i2s_stream_reader, ringbuf1);
// audio_element_set_input_ringbuf(opus_decoder, ringbuf1);
// ringbuf2 = rb_create(RING_BUFFER_SIZE, 1);
// audio_element_set_output_ringbuf( opus_decoder, ringbuf2);
// audio_element_set_input_ringbuf( pFileSrcContext->raw_stream_reader, ringbuf2);
audio_element_set_event_callback(pFileSrcContext->i2s_stream_reader, audio_element_event_handler, NULL);
audio_element_set_event_callback(opus_decoder, audio_element_event_handler, NULL);
audio_element_set_event_callback(pFileSrcContext->raw_stream_reader, audio_element_event_handler, NULL);
audio_element_set_event_callback(resample_for_rec, audio_element_event_handler, NULL);
DLOGD( "[5.0] Create pipeline");
audio_pipeline_cfg_t pipeline_cfg = DEFAULT_AUDIO_PIPELINE_CONFIG();
pFileSrcContext->pipeline = audio_pipeline_init(&pipeline_cfg);
mem_assert(pFileSrcContext->pipeline);
DLOGD( "[ 5 ] Set up event listener");
esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG();
// esp_periph_set_handle_t set = esp_periph_set_init(&periph_cfg);
audio_event_iface_cfg_t evt_cfg = AUDIO_EVENT_IFACE_DEFAULT_CFG();
pFileSrcContext->evt = audio_event_iface_init(&evt_cfg);
ESP_LOGI(TAG, "[4.1] Listening event from all elements of pipeline");
audio_pipeline_set_listener(pFileSrcContext->pipeline, pFileSrcContext->evt);
ESP_LOGI(TAG, "[4.2] Listening event from peripherals");
// audio_event_iface_set_listener(esp_periph_set_get_event_iface(set), pFileSrcContext->evt);
audio_pipeline_register(pFileSrcContext->pipeline, pFileSrcContext->i2s_stream_reader, "i2sr");
audio_pipeline_register(pFileSrcContext->pipeline, resample_for_rec, "resample");
audio_pipeline_register(pFileSrcContext->pipeline, opus_decoder, "opus");
audio_pipeline_register(pFileSrcContext->pipeline, pFileSrcContext->raw_stream_reader, "my_el");
// audio_pipeline_register(pFileSrcContext->pipeline, i2s_stream_writer, "i2sw");
const char *link_tag[4] = {"i2sr", "resample", "opus", "my_el"};
audio_pipeline_link(pFileSrcContext->pipeline, &link_tag[0], 4);
but I am getting following on the console:
Code: Select all
E (24732) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (24732) task_wdt: - IDLE (CPU 0)
E (24732) task_wdt: Tasks currently running:
E (24732) task_wdt: CPU 0: opus
E (24732) task_wdt: CPU 1: IDLE
E (24732) task_wdt: Print CPU 0 (current core) backtrace
Backtrace:0x40152EAF:0x3FFB0840 0x400851AD:0x3FFB0860 0x400F0731:0x3F9A7560 0x400F1C68:0x3F9A9500 0x400EB0A2:0x3F9AA7D0 0x400ECE66:0x3F9AAC40 0x400ED205:0x3F9AD570 0x400E81C2:0x3F9AD590 0x400E85B1:0x3F9AD600 0x400E3716:0x3F9AD620 0x400E38AA:0x3F9AD650 0x4009387D:0x3F9AD680
0x40152eaf: task_wdt_isr at /Users/ayaz/esp/esp-idf/components/esp_common/src/task_wdt.c:189
0x400851ad: _xt_lowint1 at /Users/ayaz/esp/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1105
0x400f0731: run_prefilter at /builds/adf/esp-adf-libs-source/esp_codec/esp-opus/celt/celt_encoder.c:1135 (discriminator 1)
0x400f1c68: celt_encode_with_ec at /builds/adf/esp-adf-libs-source/esp_codec/esp-opus/celt/celt_encoder.c:1606
0x400eb0a2: opus_encode_native at /builds/adf/esp-adf-libs-source/esp_codec/esp-opus/src/opus_encoder.c:2061
0x400ece66: opus_multistream_encode_native at /builds/adf/esp-adf-libs-source/esp_codec/esp-opus/src/opus_multistream_encoder.c:1073
0x400ed205: opus_multistream_encode at /builds/adf/esp-adf-libs-source/esp_codec/esp-opus/src/opus_multistream_encoder.c:1153
0x400e81c2: opus_encoder_process at /builds/adf/esp-adf-libs-source/esp_processing/esp-wrapper/opus_encoder.c:709
0x400e85b1: _opus_encoder_process at /builds/adf/esp-adf-libs-source/esp_processing/esp-wrapper/opus_encoder.c:858
0x400e3716: audio_element_process_running at /Users/ayaz/.espressif/esp-adf/components/audio_pipeline/audio_element.c:336
0x400e38aa: audio_element_task at /Users/ayaz/.espressif/esp-adf/components/audio_pipeline/audio_element.c:483
0x4009387d: vPortTaskWrapper at /Users/ayaz/esp/esp-idf/components/freertos/port/xtensa/port.c:168
E (24732) task_wdt: Print CPU 1 backtrace
Backtrace:0x40087719:0x3FFB0E40 0x400851AD:0x3FFB0E60 0x4000BFED:0x3FFC3860 0x40093B3D:0x3FFC3870 0x4015317B:0x3FFC3890 0x40153187:0x3FFC38C0 0x400DC36D:0x3FFC38E0 0x40091325:0x3FFC3900 0x4009387D:0x3FFC3920
0x40087719: esp_crosscore_isr at /Users/ayaz/esp/esp-idf/components/esp32/crosscore_int.c:77
0x400851ad: _xt_lowint1 at /Users/ayaz/esp/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:1105
0x40093b3d: vPortExitCritical at /Users/ayaz/esp/esp-idf/components/freertos/port/xtensa/port.c:473
0x4015317b: esp_task_wdt_reset at /Users/ayaz/esp/esp-idf/components/esp_common/src/task_wdt.c:336
0x40153187: idle_hook_cb at /Users/ayaz/esp/esp-idf/components/esp_common/src/task_wdt.c:88
0x400dc36d: esp_vApplicationIdleHook at /Users/ayaz/esp/esp-idf/components/esp_common/src/freertos_hooks.c:51 (discriminator 1)
0x40091325: prvIdleTask at /Users/ayaz/esp/esp-idf/components/freertos/tasks.c:3880 (discriminator 1)
0x4009387d: vPortTaskWrapper at /Users/ayaz/esp/esp-idf/components/freertos/port/xtensa/port.c:168