Пример #1
0
        /// <summary>
        /// Creates a new AudioBuffer.
        /// </summary>
        /// <param name="format">The AudioFormat.</param>
        /// <returns>OpenALAudioBuffer.</returns>
        internal OpenALAudioBuffer CreateAudioBuffer(OpenALAudioFormat format)
        {
            var audioBuffer = new OpenALAudioBuffer(format, this);

            lock (_audioBuffers)
            {
                _audioBuffers.Add(audioBuffer);
            }

            return(audioBuffer);
        }
Пример #2
0
 /// <summary>
 /// Destroys the AudioBuffer.
 /// </summary>
 /// <param name="audioBuffer">The OpenALAudioBuffer.</param>
 internal void DestroyAudioBuffer(OpenALAudioBuffer audioBuffer)
 {
     if (_disposing)
     {
         return;             //avoid deadlock
     }
     lock (_audioBuffers)
     {
         _audioBuffers.Remove(audioBuffer);
     }
 }
Пример #3
0
        /// <summary>
        /// Initializes the audio provider with the given audio source.
        /// </summary>
        /// <param name="audioSource">The AudioSource.</param>
        public void Initialize(IAudioSource audioSource)
        {
            var openALAudioSource = audioSource as OpenALAudioSource;

            if (openALAudioSource == null)
            {
                throw new InvalidOperationException("The specified audio source does not match the AudioProvider type.");
            }

            //clean old playback if existent
            if (_audioBuffer != null)
            {
                _audioBuffer.Dispose();
            }

            _audioSource = audioSource;
            var audioFormat = DetectAudioFormat(openALAudioSource.WaveFormat);

            _audioBuffer = OpenALDevice.DefaultDevice.CreateAudioBuffer(audioFormat);
            _audioBuffer.PlaybackChanged += AudioBufferPlaybackChanged;
            Volume = _volume;
            Pan    = _pan;
            _audioBuffer.Initialize(openALAudioSource.WaveData, openALAudioSource.WaveFormat);
        }
Пример #4
0
        /// <summary>
        /// Destroys the AudioBuffer.
        /// </summary>
        /// <param name="audioBuffer">The OpenALAudioBuffer.</param>
        internal void DestroyAudioBuffer(OpenALAudioBuffer audioBuffer)
        {
            if (_disposing) return; //avoid deadlock

            lock (_audioBuffers)
            {
                _audioBuffers.Remove(audioBuffer);
            }
        }
Пример #5
0
        /// <summary>
        /// Creates a new AudioBuffer.
        /// </summary>
        /// <param name="format">The AudioFormat.</param>
        /// <returns>OpenALAudioBuffer.</returns>
        internal OpenALAudioBuffer CreateAudioBuffer(OpenALAudioFormat format)
        {
            var audioBuffer = new OpenALAudioBuffer(format, this);
            lock (_audioBuffers)
            {
                _audioBuffers.Add(audioBuffer);
            }

            return audioBuffer;
        }
Пример #6
0
        /// <summary>
        /// Initializes the audio provider with the given audio source.
        /// </summary>
        /// <param name="audioSource">The AudioSource.</param>
        public void Initialize(IAudioSource audioSource)
        {
            var openALAudioSource = audioSource as OpenALAudioSource;
            if (openALAudioSource == null)
            {
                throw new InvalidOperationException("The specified audio source does not match the AudioProvider type.");
            }

            //clean old playback if existent
            if (_audioBuffer != null)
            {
                _audioBuffer.Dispose();
            }

            _audioSource = audioSource;
            var audioFormat = DetectAudioFormat(openALAudioSource.WaveFormat);
            _audioBuffer = OpenALDevice.DefaultDevice.CreateAudioBuffer(audioFormat);
            _audioBuffer.PlaybackChanged += AudioBufferPlaybackChanged;
            Volume = _volume;
            Pan = _pan;
            _audioBuffer.Initialize(openALAudioSource.WaveData, openALAudioSource.WaveFormat);
        }