> 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"?
>

Mmh, let me see... well it seems that (with the current buffer size 
settings), the release build (compiled with -O3 -march=native 
-openmp-simd), consumes about 12.5 MiB (and 0% CPU...strange?!?). Memory 
consumption seems stable in the interval [12.1-12.7 MiB].
I copy the memory I receive into the *encodedBuffer * . It should be big 
enough so that it never overflows, but I keep writing to, and reading from, 
it (all in the same thread), so that it should stay almost constant in size 
(actually for robustness, I discard old encoded samples in case of 
overflows).
The catch is that OpenAL tells me when one of its queued buffers needs a 
refill, so I can read from the encodedBuffer and use memmove (bad solution) 
to remove the used chunk of memory.

Ah, correction sorry, looks like the onprogress callback in 
> emscripten_async_wget2_data() *doesn't* have a pointer to the data that's 
> downloaded so far, you only get the number of bytes downloaded, but not the 
> bytes themselves. You only get the data when the entire download is 
> finished in the onload callback :(
>
> So I guess you're out of luck and the only way to stream partial data is 
> via HTTP range requests (which as far as I know are not supported by the 
> emscripten_wget* functions).
>

Yep! 
...what about <emscripten/fetch.h> 
<https://emscripten.org/docs/api_reference/fetch.html#streaming-downloads> 
streaming downloads ? Well, the note says: This currently only works in 
Firefox as it uses ‘moz-chunked-arraybuffer’.... so I'm not sure if it's 
worth trying it or not...

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/emscripten-discuss/12533302-a939-4672-853f-442a85e282b1o%40googlegroups.com.

Reply via email to