eshaz/wasm-audio-decoders

Odd bug maybe related: Could not enqueue bytes for decoding.

NHQ opened this issue · 2 comments

NHQ commented

Greetings, I have this module working in a single web page, from an encoder directly to the decoder, nice. But when I have piped the same encoded ogg chunks over a network (i.e. through a node stream) the decoder does nothing with the data (no onDecode events fired), and after several attempts issues up the error Could not enqueue bytes for decoding. You may also have invalid Ogg Opus file. The second part is not true; I have verified the chunks are exactly the same both sides of the network. I really doubt this is an issue with the decoder, but I have to check. Also the error is claimed to be uncaught, despite all attempts, and seems to be uncatchable this side of wasm. I have tried checking for the decoder to be ready, freeing it, etc.

eshaz commented

Thanks for reaching out. I'm assuming you're using ogg-opus-decoder.

Could you check to see how large the each chunk is when you have the Ogg data being sent through the Node stream? Also, could you try increasing your highWaterMark value when you create the Readable stream and see if this helps or if it changes the error? That value should be able to control how large each data chunk is when it flows through your stream pipeline. https://nodejs.org/api/stream.html#stream_buffering

What might be happening is that the chunks being sent through the Node stream are too small and are causing libopusfile to fail to detect the full Ogg page header. I've noticed that the Ogg page detection isn't very resilient and it doesn't handle partial Ogg page headers very well, if at all. This library essentially wraps libopusfile's callback based interface for decoding and doesn't have much more functionality beyond that at this point.

This may be related to the other issue you're seeing in #4

NHQ commented

I may be wrong about #4 in that I don't know what it takes to construct an Ogg stream without all the pages. My bug in both cases was simply not having all the pages from the start. It would be optimal if an Ogg stream could be started from any point in a cast, then all client (decoders) could share a single encoder, like for a live stream, which is my case.

All systems nominal, nice work and thanks.