/// <summary> /// Releases any buffers that have been fully written to the output device /// </summary> /// <param name="bytesRead">The amount of bytes written in the last device write</param> private void UpdateReleasedBuffers(int bytesRead) { bool bufferReleased = false; while (bytesRead > 0) { if (m_ReservedBuffers.TryPeek(out SoundIoBuffer buffer)) { if (buffer.Length > bytesRead) { buffer.Length -= bytesRead; bytesRead = 0; } else { bufferReleased = true; bytesRead -= buffer.Length; m_ReservedBuffers.TryDequeue(out buffer); ReleasedBuffers.Enqueue(buffer.Tag); } } } if (bufferReleased) { OnBufferReleased(); } }
/// <summary> /// Flush all track buffers /// </summary> public bool FlushBuffers() { m_Buffer.Clear(); if (m_ReservedBuffers.Count > 0) { foreach (var buffer in m_ReservedBuffers) { ReleasedBuffers.Enqueue(buffer.Tag); } OnBufferReleased(); return(true); } return(false); }