Ejemplo n.º 1
0
        public static Fin <Unit> WriteTotalSamples(FileStream stream, ulong sampleCount)
        {
            stream.Seek(FlacSamplesOffset, SeekOrigin.Begin);

            // we're writing over the top of other bits, so read first
            Span <byte> buffer    = stackalloc byte[5];
            int         bytesRead = stream.Read(buffer);

            if (bytesRead != buffer.Length)
            {
                return(FileTooShort);
            }

            // flac files have an unsigned 36-bit integer for total sample duration!
            BinaryHelpers.Write36BitUnsignedBigEndianIgnoringFirstNibble(buffer, sampleCount);

            stream.Seek(FlacSamplesOffset, SeekOrigin.Begin);
            stream.Write(buffer);

            return(Unit.Default);
        }