/// <summary> /// Sets up the hardware resources used by the controller. /// </summary> private ALController() { if (AL.NativeLibrary == IntPtr.Zero) { throw new DllNotFoundException( "Couldn't initialize OpenAL because the native binaries couldn't be found."); } if (!Open()) { throw new AudioHardwareException( "OpenAL device could not be initialized, see console output for details."); } Efx = new EffectsExtension(Device); if (ALC.IsExtensionPresent(Device, "ALC_EXT_CAPTURE")) { Microphone.PopulateCaptureDevices(); } // We have hardware here and it is ready _allSources = new uint[MaxNumberOfSources]; AL.GenSources(_allSources); ALHelper.CheckError("Failed to generate sources."); // TODO: allow more effects if (Efx.IsAvailable) { Filter = Efx.GenFilter(); } _availableSources = new Queue <uint>(_allSources); _sourcesInUse = new HashSet <uint>(); }
/// <summary> /// Disposes the <see cref="ALController"/>. /// </summary> /// <param name="disposing">If true, the managed resources are to be disposed.</param> private void Dispose(bool disposing) { if (!_isDisposed) { if (disposing) { Streamer.Dispose(); if (Filter != 0 && Efx.IsAvailable) { Efx.DeleteFilter(Filter); } SoundEffectInstancePool.DisposeInstances(); AL.DeleteSources(_allSources); ALHelper.CheckError("Failed to delete source."); Microphone.StopMicrophones(); DestroyContexts(); } _isDisposed = true; } }
private void PlatformResume() { AL.SourcePlay(SourceId.Value); ALHelper.CheckError("Failed to play the source."); }
public double GetSourceCurrentPosition(uint sourceId) { AL.GetSource(sourceId, ALGetSourcei.SampleOffset, out int pos); ALHelper.CheckError("Failed to set source offset."); return(pos); }
private void PlatformPause() { AL.SourcePause(SourceId.Value); ALHelper.CheckError("Failed to pause the source."); }