private int FillBuffer(AudioBuffer audioBuffer) { int bytes; int totalBytes = 0; int length = buffer.Length; while (totalBytes < length && (bytes = stream.Read(buffer, totalBytes, length - totalBytes)) > 0) totalBytes += bytes; audioBuffer.BufferData(stream.Format, stream.Frequency, buffer, totalBytes); return totalBytes; }
internal static int GetID(AudioBuffer buffer) { return (buffer == null) ? (NullBufferID) : (buffer.ID); }
public void CaptureSamples(AudioBuffer buffer, int sampleCount) { buffer.BufferData(format, frequency, CaptureSamples(sampleCount)); }
public void CaptureSamples(AudioBuffer buffer) { CaptureSamples(buffer, AvaliabeSampleCount); }
internal void EnqueueBufferInternal(int id, AudioBuffer buffer) { try { queueLock.AcquireWriterLock(Timeout.Infinite); Al.alSourceQueueBuffers(ID, 1, ref id); OpenAlException.CheckAl(); queue.AddLast(buffer); } finally { queueLock.ReleaseWriterLock(); } }
/// <summary> /// Enqueues a Buffer for playing /// </summary> /// <param name="buffer">the buffer to be queued</param> public void EnqueueBuffer(AudioBuffer buffer) { EnqueueBufferInternal(AudioBuffer.GetID(buffer), buffer); }
/// <summary> /// Dequeues a Range of buffers /// </summary> /// <param name="count">the number of buffers to dequeue</param> /// <returns>An array of AudioBuffers</returns> public AudioBuffer[] DequeueBufferRange(int count) { try { queueLock.AcquireWriterLock(Timeout.Infinite); DequeueBuffersInternal(count); AudioBuffer[] rv = new AudioBuffer[count]; for (int pos = 0; pos < count; ++pos) { rv[pos] = queue.First.Value; queue.RemoveFirst(); } return rv; } finally { queueLock.ReleaseWriterLock(); } }