1

Resolved

InvalidDataException "Reservoir did not have enough bytes!" with some files

description

When I'm trying to play some files using NAudio and NLayer, I'm getting PlaybackStopped event with the following exception:

InvalidDataException: Reservoir did not have enough bytes!
at NLayer.Decoder.BitReservoir.Get1Bit()
at NLayer.Decoder.Huffman.Decode(BitReservoir br, Int32 table, Single& x, Single& y)
at NLayer.Decoder.LayerIIIDecoder.ReadSamples(Int32 sfBits, Int32 gr, Int32 ch)
at NLayer.Decoder.LayerIIIDecoder.DecodeFrame(IMpegFrame frame, Single[] ch0, Single[] ch1)
at NLayer.MpegFrameDecoder.DecodeFrameImpl(IMpegFrame frame, Array dest, Int32 destOffset)
at NLayer.MpegFrameDecoder.DecodeFrame(IMpegFrame frame, Byte[] dest, Int32 destOffset)
at NLayer.NAudioSupport.Mp3FrameDecompressor.DecompressFrame(Mp3Frame frame, Byte[] dest, Int32 destOffset)
at NAudio.Wave.Mp3FileReader.Read(Byte[] sampleBuffer, Int32 offset, Int32 numBytes)
at NAudio.Wave.WaveOutBuffer.OnDone()
at NAudio.Wave.WaveOutEvent.DoPlayback()
at NAudio.Wave.WaveOutEvent.PlaybackThread()

I can't attach the file because it's larger then 4mb.

comments

ioctlLR wrote Aug 21, 2014 at 4:54 PM

We really need the file... You might try pastebin... If you can't figure out a place to upload it, comment here and we can walk you through uploading just the offending portion of the file.

If you upload the whole file somewhere, please include how far into the file the error occurs (# of samples / timecode / # of bytes / etc.).

vetalcore wrote Aug 21, 2014 at 5:38 PM

I've shared it on Google drive

The error occures at the beginning (00:02.795; 986112 bytes).

ioctlLR wrote Aug 25, 2014 at 1:37 PM

Wow... NLayer doesn't have a clue how to handle this file (and the other two you submitted). I'll try to finish debugging the issue as soon as I can, but it's going to take me a little while.

Just curious: Can you re-encode the source audio using a different MP3 encoder? If so, does that file also make NLayer choke?

ioctlLR wrote Sep 11, 2014 at 10:14 PM

Check out the latest source update. I found some bugs in the BitReservoir that were causing all kinds of problems with this file and the other two you submitted.

wrote Sep 11, 2014 at 10:14 PM