Please clarify the units of i2s_config_t.dma_buf_len

dave_see
Posts: 11
Joined: Wed Jan 08, 2020 6:02 pm

Please clarify the units of i2s_config_t.dma_buf_len

Postby dave_see » Tue Apr 14, 2020 7:59 pm

Hello,

In working on an ESP32 audio project, I followed the I2S page example from here:
https://docs.espressif.com/projects/esp ... the-driver

There's an important struct in setting this up of the type i2s_config_t . One of the fields in that struct is dma_buf_len. There's no mention of the units for that variable. I assumed it was bytes since many other ESP-IDF length variables are in units of bytes.

After debugging, and looking at the ESP-IDF source code, it's clear that that variable is in units of audio 'frames' or samples. I determined this by looking at this line of code:
https://github.com/espressif/esp-idf/bl ... i2s.c#L592

Code: Select all

int sample_size = p_i2s_obj[i2s_num]->bytes_per_sample * p_i2s_obj[i2s_num]->channel_num;
And this line of code:
https://github.com/espressif/esp-idf/bl ... i2s.c#L609

Code: Select all

dma->buf[bux_idx] = (char*) heap_caps_calloc(1, dma_buf_len * sample_size, MALLOC_CAP_DMA);
It would be great if the I2S documentation clearly shows that dma_buf_len is in units of audio frames or audio samples.

Warm regards,
Dave

Who is online

Users browsing this forum: No registered users and 3 guests