示例#1
0
        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;
        }
示例#2
0
 internal static int GetID(AudioBuffer buffer)
 {
     return (buffer == null) ? (NullBufferID) : (buffer.ID);
 }
示例#3
0
 public void CaptureSamples(AudioBuffer buffer, int sampleCount)
 {
     buffer.BufferData(format, frequency, CaptureSamples(sampleCount));
 }
示例#4
0
 public void CaptureSamples(AudioBuffer buffer)
 {
     CaptureSamples(buffer, AvaliabeSampleCount);
 }
示例#5
0
 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();
     }
 }
示例#6
0
 /// <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);
 }
示例#7
0
 /// <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();
     }
 }