示例#1
0
        public unsafe void UpdateAudio(byte[] samples)
        {
            int processed = 0;
            int alBuffer  = 0;

            while (true)
            {
                AL.GetSource(audioSource, ALGetSourcei.BuffersProcessed, out processed);

                while (processed-- > 0)
                {
                    AL.SourceUnqueueBuffers(audioSource, 1, ref alBuffer);
                    AL.DeleteBuffer(alBuffer);
                    queueLength--;
                }

                if (queueLength < 5 || fastForward)
                {
                    break;
                }
            }

            if (queueLength < 5)
            {
                alBuffer = AL.GenBuffer();
                AL.BufferData(alBuffer, ALFormat.Stereo16, samples, 44100);
                AL.SourceQueueBuffer(audioSource, alBuffer);
                queueLength++;
            }

            if (AL.GetSourceState(audioSource) != ALSourceState.Playing)
            {
                AL.SourcePlay(audioSource);
            }
        }
        public static void ClearResources()
        {
            foreach (Geometry value in geometryDictionary.Values)
            {
                value.Delete();
            }
            geometryDictionary.Clear();

            foreach (int value in textureDictionary.Values)
            {
                GL.DeleteTexture(value);
            }
            textureDictionary.Clear();

            foreach (int value in audioDictionary.Values)
            {
                AL.DeleteBuffer(value);
            }
            audioDictionary.Clear();

            foreach (Shader value in shaderDictionary.Values)
            {
                value.Delete();
            }
            shaderDictionary.Clear();
        }
示例#3
0
 public static void Dispose()
 {
     foreach (var clip in AudioClip.AudioClips)
     {
         AL.DeleteBuffer(clip.BufferID);
     }
 }
示例#4
0
        /// <summary>
        /// Деструктор
        /// </summary>
        public void Dispose()
        {
            AL.DeleteSource(AlSource);
            AL.DeleteBuffer(AlBuffer);

            Console.WriteLine($"AL: Audio data {AlSource}:{AlBuffer} removed from memory");
        }
示例#5
0
 /// <summary>
 /// Cleans Up all resources
 /// </summary>
 public static void CleanUp()
 {
     foreach (var t in textureDictionary)
     {
         t.Value.Delete();
     }
     textureDictionary.Clear();
     foreach (var s in shaderDictionary)
     {
         s.Value.Delete();
     }
     shaderDictionary.Clear();
     foreach (var g in geometryDictionary)
     {
         g.Value.CleanUp();
     }
     geometryDictionary.Clear();
     foreach (var a in audioDictionary)
     {
         AL.DeleteBuffer(a.Value);
     }
     audioDictionary.Clear();
     foreach (var f in frameBufferDictionary)
     {
         f.Value.CleanUp();
     }
     frameBufferDictionary.Clear();
     materialDictionary.Clear();
 }
示例#6
0
 public void Shutdown()
 {
     if (s_audio.noSound)
     {
         return;
     }
     AL.DeleteBuffer(buffer);
 }
示例#7
0
 private void CleanupSource()
 {
     if (alSource > -1)
     {
         AL.DeleteBuffer(alBuffer);
         AL.DeleteSource(alSource);
     }
 }
示例#8
0
 public void Dispose()
 {
     if (!disposed)
     {
         al.DeleteBuffer(bufferIndex);
         disposed = true;
     }
 }
示例#9
0
 public void Stop()
 {
     SetVolume(0);
     AL.SourceStop(source);
     AL.Source(source, ALSourcei.Buffer, 0);
     AL.DeleteSource(source);
     AL.DeleteBuffer(buffer);
 }
示例#10
0
 public static void Close()
 {
     foreach (int myBuffer in audioDictionary.Values)
     {
         AL.DeleteBuffer(myBuffer);
     }
     audioDictionary.Clear();
 }