WaveOverFlacStream keeps returning -1

Jan 20, 2014 at 10:14 AM
I am making a WP8 App that loads FLAC stream then convert it to WAV stream so i could easily manipulate audio data.
public List<byte> ReadToEnd(System.IO.Stream streams)
{
    
    using (FlacReader flac = new FlacReader(streams, true))
    {
        using (WaveOverFlacStream wav = new WaveOverFlacStream(flac))
        {
            long originalPosition = 0;
            if (wav.CanSeek)
            {
                originalPosition = wav.Position;
                wav.Position = 0;
            }
            try
            {
                byte[] readBuffer = new byte[4096];

                int totalBytesRead = 0, bytesRead;
                if (wav.CanRead)
                    while ((bytesRead = wav.Read(readBuffer, totalBytesRead, readBuffer.Length - totalBytesRead)) > 0)
                    {//never pass this line
                        totalBytesRead += bytesRead;
                        if (totalBytesRead == readBuffer.Length)
                        {
                            .....
i tried with several flac files and reader always stops at Position ~45 with ReadByte returning -1 while reading metadata