Question on ADF's i2s_stream_cfg_t i2s_stream.h -- what is "buffer_len"?

count_zero
Posts: 3
Joined: Fri May 26, 2023 3:51 pm

Question on ADF's i2s_stream_cfg_t i2s_stream.h -- what is "buffer_len"?

Postby count_zero » Fri May 26, 2023 4:32 pm

This question is just out of pure curiosity and to know how the code I'm using actually works. I had some code that used an older version of ADF (I believe 2.3 or so), which would use ADF's i2s_stream (esp-adf/components/audio_stream/include/i2s_stream.h). When updating ADF to the current version in master branch, some of my code broke, and after wandering around in the source, I found that the new version had an extra element in the structure i2s_stream_cfg_t "buffer_len", which if I did not initilaized, the audio would just not run (the code would all run without a problem or errors, but the audio would just not work -- and all the warning I would get is "AUDIO_THREAD: Make sure selected the `CONFIG_SPIRAM_BOOT_INIT` and `CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY` by `make menuconfig", which I get anyway even when the audio runs by setting buffer_len to 3600). Thankfully, it all was fixed just by adding that extra line setting .buffer_len = 3600. However, I don't think the documentation is clear as to what this parameter is exactly. Is it related to the ringbuffer used to connect the distinct elements? If so, isn't the rinbuffer size determined by the other parameters (out_rb_size, task_stack, etc)? If not so, what is this buffer used for? Why was it added to the i2s_stream_cfg_t structure?

tempo.tian
Posts: 40
Joined: Wed Jun 22, 2022 12:10 pm

Re: Question on ADF's i2s_stream_cfg_t i2s_stream.h -- what is "buffer_len"?

Postby tempo.tian » Wed May 31, 2023 8:40 am

Buffer_len is added to fix the issue when play 24bits, the buffer needs sample aligned, if use 1024 it will have issue.
It is added recently and initialized using I2S_STREAM_CFG_DEFAULT()
If your example do not not the macro to do the initialization and assign value manually. It will have issue.

Who is online

Users browsing this forum: No registered users and 24 guests