concentus.oggfile icon indicating copy to clipboard operation
concentus.oggfile copied to clipboard

Library does not work if input stream cannot provide Length

Open Licho1 opened this issue 1 year ago • 5 comments

Some streams, for example chunked network stream produced by httpclient do not have .Length property. If you try to read this stream, it will crash internally on initialize.

Licho1 avatar Nov 18 '23 19:11 Licho1

Stream stream = await new HttpClient().GetStreamAsync("http://durandal.dnsalias.net/goons/casserole.opus");
OpusOggReadStream readStream = new OpusOggReadStream(new OpusDecoder(48000, 2), stream);
readStream.DecodeNextPacket();

Works fine for me? Can you provide repro code?

lostromb avatar Nov 18 '23 21:11 lostromb

whoops, never mind. It doesn't throw an exception, but it does stop working....

lostromb avatar Nov 18 '23 21:11 lostromb

Hmmmm yeah, the exception is being thrown from StreamReadBuffer when it's trying to seek to the beginning of a page, on the assumption that the page has been buffered locally from the network. This codebase is forked from NVorbis which has since changed a lot and removed this entire code path.

I don't know if there is a quick fix. The whole point of the buffered intermediate stream seems like it was supposed to make short-term seeking possible, but it doesn't actually work (I didn't write this code)

lostromb avatar Nov 18 '23 21:11 lostromb

whoops, never mind. It doesn't throw an exception, but it does stop working....

Yeah exception is caught internally.. sorry for bad explanation

Licho1 avatar Nov 20 '23 22:11 Licho1

I might have fixed this with #23, but I don't quite remember as that code has been hanging around for a few months and I don't fully remember it.

lostromb avatar May 07 '24 17:05 lostromb