public OggVorbisEncodedStream(byte[] buffer)
        {
            //this.buffer = buffer;
            rawStream = new MemoryStream(buffer);

            //Open
            file = new NativeOggVorbisFile();

            NativeCallbacks callbacks = new NativeCallbacks();

            callbacks.ReadFunction = new ReadFunctionDelegate(this.RawStreamRead);
            callbacks.TellFunction = new TellFunctionDelegate(this.RawStreamTell);
            callbacks.SeekFunction = new SeekFunctionDelegate(this.RawStreamSeek);

            int result = 0;

            if ((result = OggVorbisFile.NativeOpenCallbacks(buffer, file, IntPtr.Zero, 0, callbacks)) != 0)
            {
                throw new OggVorbisException(String.Format("Error {0} during open", result));
            }

            //Get info
            info = new VorbisInfo(OggVorbisFile.NativeGetInfo(file, -1));

            //Get lengths of the stream
            pcmLength = OggVorbisFile.NativeGetLength(file, -1);    // -1 to entire bitstream
            rawLength = OggVorbisFile.NativeGetRawLength(file, -1); // -1 to entire bitstream
            duration  = OggVorbisFile.NativeGetDuration(file, -1);  // -1 to entire bitstream

            //Update info
            info.Duration = duration;
        }
        public OggVorbisFileStream(string filename)
        {
            //Open File
            file = new NativeOggVorbisFile();

            //if (ov_open(stream.SafeFileHandle, ref vf, IntPtr.Zero,0) == 0)
            // fopen for Win32!
            if (OggVorbisFile.NativeFOpen(filename, file) != 0)
            {
                throw new OggVorbisException("Error during fopen");
            }

            //Get info
            info = new VorbisInfo(OggVorbisFile.NativeGetInfo(file, -1));

            //Get lengths of the stream
            pcmLength = OggVorbisFile.NativeGetLength(file, -1);    // -1 to entire bitstream
            rawLength = OggVorbisFile.NativeGetRawLength(file, -1); // -1 to entire bitstream
            duration  = OggVorbisFile.NativeGetDuration(file, -1);  // -1 to entire bitstream

            //Update info
            info.Duration = duration;
        }