Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to preload I2S DMA buffer with actual data (IDFGH-6847) #8471

Closed
CarlosDerSeher opened this issue Feb 26, 2022 · 5 comments
Closed
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Feature Request Feature request for IDF

Comments

@CarlosDerSeher
Copy link

If I want to start audio at a precise moment in time this will be kind of hard with the current implementation of I2S driver. There is no mechanism to fill the whole DMA buffer with actual data before starting transmission. Instead the driver will tx zero samples and if done it will send the now free tx buffer using a queue which will enable the user to add new data using i2_write(). I couldn't find a reliable solution to start audio at a precise moment using combinations of i2s_stop(), i2s_zero_dma(), i2s_write() and i2s_start() there has always been some jitter.

A possible solution I could think of would be to add the possibility to register a custom callback function in i2s_driver_install() which will be called from i2s_start(). This callback should be given access to the full I2S object so we can manipulate buffers and this object directly, giving users more low level control on i2s.

@CarlosDerSeher CarlosDerSeher added the Type: Feature Request Feature request for IDF label Feb 26, 2022
@espressif-bot espressif-bot added the Status: Opened Issue is new label Feb 26, 2022
@github-actions github-actions bot changed the title Add possibility to preload I2S DMA buffer with actual data Add possibility to preload I2S DMA buffer with actual data (IDFGH-6847) Feb 26, 2022
@L-KAYA
Copy link
Collaborator

L-KAYA commented Feb 28, 2022

Yes, the current driver has a lot of limitations, so we are now planning to have a driver-NG on i2s driver. It's a good idea to have an API that can send the valid data at the time that you call it. The new driver of I2S will release in v5.0.

@CarlosDerSeher
Copy link
Author

CarlosDerSeher commented Mar 2, 2022

@L-KAYA I see, so when is v5.0 expected to be released? And such functionality will be included there? At current master, after quickly checking, I didn't see much difference in how the driver works/is setup

@egnor
Copy link

egnor commented Jul 27, 2022

I bumped into this as well. The I2S driver has certainly changed a lot in master, and the documentation is more extensive. However, on inspection, this particular buffering limitation/bug/misfeature appears not to have changed.

If handle->msg_queue were prefilled on start with every buffer (since they're all empty), we would at least not have to wait for an entire buffer loop-through of silence before any sound comes out the way we do now.

If it were possible to call i2s_channel_write() (the i2s_write() equivalent in the new API) with the peripheral in READY but not RUNNING state, then that would allow a full buffer from the jump.

(In general the buffering approach of this driver leaves something to be desired...)

@CarlosDerSeher
Copy link
Author

That's a pitty. I have to say I didn't look into master recently because I solved my problem by pulling in i2s driver code as a custom component and adding a function which will prefill DMA buffers with valid data and resets all pointers. It still would be nice to have a API which can do that natively...

@espressif-bot espressif-bot added Status: Selected for Development Issue is selected for development Status: In Progress Work is in progress Status: Reviewing Issue is being reviewed and removed Status: Opened Issue is new Status: Selected for Development Issue is selected for development Status: In Progress Work is in progress labels Jan 5, 2023
@espressif-bot espressif-bot added Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: Reviewing Issue is being reviewed Resolution: NA Issue resolution is unavailable labels Feb 22, 2023
@CarlosDerSeher
Copy link
Author

Looks promising. Thanks for the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Feature Request Feature request for IDF
Projects
None yet
Development

No branches or pull requests

4 participants