TagLib.MusePack.StreamHeader.ReadSv8Properties C# (CSharp) Method

ReadSv8Properties() private method

private ReadSv8Properties ( File file ) : void
file File
return void
        private void ReadSv8Properties(File file)
        {
            bool foundSH = false;

            while (!foundSH)
            {
                ByteVector packetType = file.ReadBlock(2);

                uint packetSizeLength = 0;
                bool eof = false;

                ulong packetSize = ReadSize(file, ref packetSizeLength, ref eof);
                if (eof)
                {
                    break;
                }

                ulong payloadSize = packetSize - 2 - packetSizeLength;
                ByteVector data = file.ReadBlock((int)payloadSize);

                if (packetType == "SH")
                {
                    foundSH = true;

                    if (payloadSize <= 5)
                    {
                        break;
                    }

                    int pos = 4;
                    version = data[pos];
                    pos += 1;
                    frames = (uint)ReadSize(data, ref pos);
                    if (pos > (uint)payloadSize - 3)
                    {
                        break;
                    }

                    ulong beginSilence = ReadSize(data, ref pos);
                    if (pos > (uint)payloadSize - 2)
                    {
                        break;
                    }

                    ushort flags = data.Mid(pos, 1).ToUShort(true);

                    sample_rate = sftable[(flags >> 13) & 0x07];
                    channels = ((flags >> 4) & 0x0F) + 1;

                    framecount = frames - beginSilence;
                }
                else if (packetType == "SE")
                {
                    break;
                }
                else
                {
                    file.Seek((int)payloadSize, SeekOrigin.Current);
                }
            }
        }