> Main problem is that I just wanted to add some minimal code changes to support emscripten.
Yep, that would be preferrable. But I think curl's streaming callback isn't easy to map to the emscripten_wget* functions.
However note that both methods (curl with CURLOPT_WRITEFUNCTION and emscripten_wget2_data()) don't have any guarantees how much data has actually been loaded before the callbacks are called (that's why I'm using HTTP range-requests basically), I think this means that a lot of audio data will be queued up in RAM (basically the entire file size) because there's no way to pause the download to allow the audio playback to catch up. Don't you see RAM usage explode in your example for "infinite streams"?
So basically, you could try replacing the call to curl_easy_perform() with a call to emscripten_async_wget2_data(), and maybe the onprogress callback is performing similar to the curl WRITEFUNCTION callback. One difference will definitely be the emscripten_async_wget2_data() will not block but instead return immediately, you need to use the provided callbacks to check whether the download has finished, and also should use one of the emscripten_request_animation_frame_* functions to periodically check what on the status of the download (which basically requires to split your code into an initialization-part, and a per-frame part).
Hope this helps!
-Floh.