Example #1
0
        internal unsafe void Process(ReadOnlySpan <int> leftBuffer, ReadOnlySpan <int> rightBuffer)
        {
            Span <IntPtr> buffers = stackalloc IntPtr[]
            {
                new IntPtr(Unsafe.AsPointer(ref MemoryMarshal.GetReference(leftBuffer))),
                new IntPtr(Unsafe.AsPointer(ref MemoryMarshal.GetReference(rightBuffer)))
            };

            if (!SafeNativeMethods.StreamEncoderProcess(
                    _handle,
                    MemoryMarshal.GetReference(buffers),
                    (uint)leftBuffer.Length))
            {
                throw new AudioEncodingException($"FLAC encountered error {GetState()} while processing samples.");
            }
        }