On the best way to stream-save a remote mp3 playlist #871
-
What i try to achieve is the following, there is a set of 5 or 10 mp3 files, stored online, and i try to save them to the SD-MMC while ((almost) immediately streaming the first one, later next files will be played from the SD once frist file playback finishes. Files in most cases are HTTPS but are accessed with the non secure client (HTTPClient), which saves some processing overhead, i found that the average performance without modifying the SDK config (which would imply recompiling all the core libraries) is around 80KB/s (on aws), but it can be lower, like 48KB/s in my test below (https://file-examples.com/storage/fe629099fc646eff79529f9/2017/11/file_example_MP3_2MG.mp3).
speed is total time / total datas received, These timings are obviously flawed especially for stream::read because it is obvious it has spent the most time here but it doesnt show, i suspect because the stream api stores in a buffer in the background and all we do in stream::read is to read from the ram buffer, so the real time spent reading from server ends up in idle count. Regarding the SD it seems accurate although very slow (278KB/s). What would be the best strategy to integrate this with arduino-audio-tools? Of course the fact that download is faster than audio streaming implies the first file will still be playing when the next file will start downloading, i am not sure wether the sd_mmc driver can allow to read and write two separate files concurently, and also if it can allow to read the same files in two separate instances (the case of the first file which will be both downloaded to and read from at the begining of the process). Any pointer will be much appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 6 replies
-
Two alternative proposals:
|
Beta Was this translation helpful? Give feedback.
-
It is documented that after starting A2DP some memory can not be released any more and that after releasing some other memory, A2DP can not be started any more! So you better now what you are doing and I don't think that your goal can be achieved! |
Beta Was this translation helpful? Give feedback.
-
I don't remember, but I think that it was to be compatible with the Arduino BluetoothSerial. |
Beta Was this translation helpful? Give feedback.
-
I committed a change to activate SPP only on request. I think this is a better solution and should save some unnecessary memory allocation |
Beta Was this translation helpful? Give feedback.
-
Nor do I, the 148’400 are measured bytes per second with one single download. So my recommendation would have actually been the second proposed option. But this has the disadvantage that the file is only available after it has been played. |
Beta Was this translation helpful? Give feedback.
Two alternative proposals: