Loading ogg into memory versus file problem

I am using the ogg decoder from Tor-Einar Jarnbjo and have no problem when setting things up to read from a file. When I try and load the file into memory as a byte array and then use the decoder, I get an exception.


                        // Reading from a file
                        physOggStream = new FileStream(new RandomAccessFile(fileName, "r"));
                                    
// Reading file into memory
                        FileInputStream fileInputStream = new FileInputStream(sourceFile);
                        audioSamples = new byte[(int)sourceFile.length()];
                        fileInputStream.read(audioSamples);
                        fileInputStream.close();
                        ByteArrayInputStream baInputStream = new ByteArrayInputStream(audioSamples);
                        physOggStream = new BasicStream(baInputStream);
                        
                        // get the first logical Ogg stream
                        los = (LogicalOggStream) physOggStream.getLogicalStreams().iterator().next();
                        vs = new VorbisStream(los);

You can see by the comments which version is which. The one line file reading works fine with the last two lines of code. If I use the byte array, the new VorbisStream() throws an index out of bounds exception. I get an error about the header being wrong before that.

Can someone point me to what I’m doing wrong?

Regards,
Dr. A.

After poking around in the ogg code, I discovered the problem. The BasicStream class didn’t set a reference to the passed in InputStream, which ends up manifesting as an error latter on. My code was actually right for once. :wink:

I wanted to submit the bug fix to the author but the site appears to be down. Anyone know how to get ahold of the author for the ogg decoder? The site is -

http://www.j-ogg.de/

Regards,
Dr. A>