douardda / snapclient-esp-adf

A simple snapclient for the esp32 and esp32s2 platforms using the esp-adf framwork
5 stars 5 forks source link

Nice solid work :-) #1

Open jorgenkraghjakobsen opened 3 years ago

jorgenkraghjakobsen commented 3 years ago

I cannot figure out how to implement the sync concept in the ADF pipe line framework. My only suggesting would be a dynamic pipeline buffer element that will delay output according to playback delay set from snapserver. Still an snap client audio source in the ADF with simple sync model will be of grate value. There are lots of WIP pase on from my imp. but let gets solved on the way. /J

douardda commented 3 years ago

thx. Same, not sure how could the latency be managed and got the same idea of an audio buffer element handling the (re)synchronization task. But I've not started working on this idea yet. TBH, I still don't really understand how the latency control works and how to implement it properly to gain synchronous snapclients. I need to study more your implementation as well as the upstream snapclient one to try to figure it.

miLORD1337 commented 3 years ago

Maybe estimate how fast/slow the frames should be played to reach sync within a set timeframe and then interpolate between frames to reach the estimated playback speed would work? This could of course lead to dropped frames if playback speed has to be fast...

CarlosDerSeher commented 2 years ago

I did a lot of testing and tried lots of things and came to the conclusion that it is impossible to get good syncing using ADF pipelines. There is just too much unknown and unpredictable processing delay. Also how IDF's i2s driver works is problematic in my opinion. You can't fill DMA buffers before starting transmission, so there will always be the delay of the full DMA length because i2s interrupt will just give you a DMA descriptor after it finished transmission. This probably could be worked around though because DMA buffers size is fixed and delay therefore known, using zero_dma() function and i2s_sop() this could be predictable set. Still I found it impossible to get exact sync using pipelines, even getting repeatable sync points was impossible. For some reason this was always deviating to some amount. I dropped ADF completely except board init parts which I add as custom components, also i modified I2S driver to get perfect syncing.

How is work going on your end regarding this issue? It still would be nice to get this work with an unmodified SDK