private void _shutdownAudio() { foreach (var source in _audioSources.Values.ToArray()) { if (source.TryGetTarget(out var target)) { target.Dispose(); } } foreach (var source in _bufferedAudioSources.Values.ToArray()) { if (source.TryGetTarget(out var target)) { target.Dispose(); } } if (_openALContext != ContextHandle.Zero) { Alc.DestroyContext(_openALContext); } if (_openALDevice != IntPtr.Zero) { Alc.CloseDevice(_openALDevice); } }
private void Dispose(bool manual) { if (!disposed) { if (this.IsCurrent) { this.IsCurrent = false; } if (context_handle != ContextHandle.Zero) { available_contexts.Remove(context_handle); Alc.DestroyContext(context_handle); } if (Device != IntPtr.Zero) { Alc.CloseDevice(Device); } if (manual) { } disposed = true; } }
protected void Dispose(bool bManagedDispose) { this.eOutputDevice = ESoundDeviceType.Unknown; // まず出力停止する(Dispose中にクラス内にアクセスされることを防ぐ) if (bManagedDispose) { #region [ 経緯時間計測用サウンドバッファを解放。] //----------------- if (this.sd経過時間計測用サウンドバッファ != null) { this.sd経過時間計測用サウンドバッファ.tサウンドを停止する(); CCommon.tDispose(ref this.sd経過時間計測用サウンドバッファ); } //----------------- #endregion CCommon.tDispose(this.tmSystemTimer); } if (ctimer != null) { CCommon.tDispose(ref this.ctimer); } //使わなくなったデータをクリーンアップ Alc.MakeContextCurrent(ContextHandle.Zero); Alc.DestroyContext(this.context); Alc.CloseDevice(this.device); }
public void Dispose() { if (!disposed) { devicecount--; disposed = true; GC.SuppressFinalize(this); try { Alc.MakeContextCurrent(new ContextHandle(IntPtr.Zero)); } #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { } if (_hContext.Handle != IntPtr.Zero) { Alc.DestroyContext(_hContext); } if (_hDevice != IntPtr.Zero) { Alc.CloseDevice(_hDevice); } } }
protected void Dispose(bool bManagedDispose) { this.e出力デバイス = ESoundDeviceType.Unknown; // まず出力停止する(Dispose中にクラス内にアクセスされることを防ぐ) if (bManagedDispose) { #region [ 経緯時間計測用サウンドバッファを解放。] //----------------- if (this.sd経過時間計測用サウンドバッファ != null) { this.sd経過時間計測用サウンドバッファ.tサウンドを停止する(); C共通.tDisposeする(ref this.sd経過時間計測用サウンドバッファ); } //----------------- #endregion #region [ 単位繰り上げ用スレッド停止。] //----------------- if (this.th経過時間測定用スレッド != null) { this.th経過時間測定用スレッド.Abort(); this.th経過時間測定用スレッド = null; } //----------------- #endregion C共通.tDisposeする(this.tmシステムタイマ); } if (ctimer != null) { C共通.tDisposeする(ref this.ctimer); } //使わなくなったデータをクリーンアップ Alc.MakeContextCurrent(ContextHandle.Zero); Alc.DestroyContext(this.context); Alc.CloseDevice(this.device); }
public void Close() { if (handle != IntPtr.Zero) { Alc.CloseDevice(handle); } handle = IntPtr.Zero; }
internal static void Cleanup() { Window.Close(); GraphicsContext.Dispose(); Alc.MakeContextCurrent(ContextHandle.Zero); Alc.DestroyContext(AudioContext); Alc.CloseDevice(AudioDevice); }
public void Dispose() { AL.DeleteSources(1, ref _source); Alc.MakeContextCurrent(ContextHandle.Zero); Alc.DestroyContext(_context); Alc.CloseDevice(_device); }
protected override void Dispose(bool disposing) { if (_device != IntPtr.Zero) { Alc.CloseDevice(_device); } _device = IntPtr.Zero; }
public void Dispose() { if (device == IntPtr.Zero) { return; } Alc.CloseDevice(device); device = IntPtr.Zero; }
void shutDownAudio() { ContextHandle alContext = Alc.GetCurrentContext(); IntPtr alDevice = Alc.GetContextsDevice(alContext); ContextHandle emptyContext = ContextHandle.Zero; Alc.MakeContextCurrent(emptyContext); Alc.DestroyContext(alContext); Alc.CloseDevice(alDevice); }
public void CleanAndExit() { ContextHandle alContext = Alc.GetCurrentContext(); IntPtr alDevice = Alc.GetContextsDevice(alContext); ContextHandle emptyContext = ContextHandle.Zero; Alc.MakeContextCurrent(emptyContext); Alc.DestroyContext(alContext); Alc.CloseDevice(alDevice); }
public static void Shutdown() { for (int i = 0; i < _maxSources; i++) { _sources[i].Source.Dispose(); _sources[i].Owner = null; } Alc.DestroyContext(_context); Alc.CloseDevice(_device); }
// --- initialization and deinitialization --- /// <summary>Initializes audio. A call to Deinitialize must be made when terminating the program.</summary> /// <returns>Whether initializing audio was successful.</returns> internal static bool Initialize() { Deinitialize(); switch (Options.Current.SoundRange) { case SoundRange.Low: OuterRadiusFactorMinimum = 2.0; OuterRadiusFactorMaximum = 8.0; OuterRadiusFactorMaximumSpeed = 1.0; break; case SoundRange.Medium: OuterRadiusFactorMinimum = 4.0; OuterRadiusFactorMaximum = 16.0; OuterRadiusFactorMaximumSpeed = 2.0; break; case SoundRange.High: OuterRadiusFactorMinimum = 6.0; OuterRadiusFactorMaximum = 24.0; OuterRadiusFactorMaximumSpeed = 3.0; break; } OuterRadiusFactor = Math.Sqrt(OuterRadiusFactorMinimum * OuterRadiusFactorMaximum); OuterRadiusFactorSpeed = 0.0; OpenAlDevice = Alc.OpenDevice(null); if (OpenAlDevice != IntPtr.Zero) { OpenAlContext = Alc.CreateContext(OpenAlDevice, new int[0]); if (OpenAlContext != ContextHandle.Zero) { Alc.MakeContextCurrent(OpenAlContext); try { AL.SpeedOfSound(343.0f); } catch { Debug.AddMessage(Debug.MessageType.Error, false, "OpenAL 1.1 is required. You seem to have OpenAL 1.0."); } AL.DistanceModel(ALDistanceModel.None); return(true); } AlcError error = Alc.GetError(OpenAlDevice); Alc.CloseDevice(OpenAlDevice); OpenAlDevice = IntPtr.Zero; Debug.AddMessage(Debug.MessageType.Error, false, "The OpenAL context could not be created: " + error); return(false); } ALError devError = AL.GetError(); OpenAlContext = ContextHandle.Zero; Debug.AddMessage(Debug.MessageType.Error, false, "The OpenAL sound device could not be opened: " + AL.GetErrorString(devError)); return(false); }
public void Dispose() { Device = Alc.GetContextsDevice(context); Alc.MakeContextCurrent(OpenTK.ContextHandle.Zero); if (context != OpenTK.ContextHandle.Zero) { Alc.DestroyContext(context); } if (Device != IntPtr.Zero) { Alc.CloseDevice(Device); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var device = Alc.OpenDevice(null); var context = Alc.CreateContext(device, (int[])null); Alc.MakeContextCurrent(context); Application.Run(new MainWindow()); Alc.MakeContextCurrent(OpenTK.ContextHandle.Zero); Alc.DestroyContext(context); Alc.CloseDevice(device); }
// --- initialization and deinitialization --- /// <summary>Initializes audio. A call to Deinitialize must be made when terminating the program.</summary> /// <returns>Whether initializing audio was successful.</returns> internal static void Initialize() { Deinitialize(); switch (Interface.CurrentOptions.SoundRange) { case Interface.SoundRange.Low: OuterRadiusFactorMinimum = 2.0; OuterRadiusFactorMaximum = 8.0; OuterRadiusFactorMaximumSpeed = 1.0; break; case Interface.SoundRange.Medium: OuterRadiusFactorMinimum = 4.0; OuterRadiusFactorMaximum = 16.0; OuterRadiusFactorMaximumSpeed = 2.0; break; case Interface.SoundRange.High: OuterRadiusFactorMinimum = 6.0; OuterRadiusFactorMaximum = 24.0; OuterRadiusFactorMaximumSpeed = 3.0; break; } OuterRadiusFactor = Math.Sqrt(OuterRadiusFactorMinimum * OuterRadiusFactorMaximum); OuterRadiusFactorSpeed = 0.0; OpenAlDevice = Alc.OpenDevice(null); if (OpenAlDevice != IntPtr.Zero) { OpenAlContext = Alc.CreateContext(OpenAlDevice, (int[])null); if (OpenAlContext != ContextHandle.Zero) { Alc.MakeContextCurrent(OpenAlContext); try { AL.SpeedOfSound(343.0f); } catch { //MessageBox.Show(Interface.GetInterfaceString("errors_sound_openal_version"), Interface.GetInterfaceString("program_title"), MessageBoxButtons.OK, MessageBoxIcon.Hand); } AL.DistanceModel(ALDistanceModel.None); return; } Alc.CloseDevice(OpenAlDevice); OpenAlDevice = IntPtr.Zero; //MessageBox.Show(Interface.GetInterfaceString("errors_sound_openal_context"), Interface.GetInterfaceString("program_title"), MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } OpenAlContext = ContextHandle.Zero; //MessageBox.Show(Interface.GetInterfaceString("errors_sound_openal_device"), Interface.GetInterfaceString("program_title"), MessageBoxButtons.OK, MessageBoxIcon.Hand); }
private void CleanUpOpenAL() { Alc.MakeContextCurrent(ContextHandle.Zero); if (_context != ContextHandle.Zero) { Alc.DestroyContext(_context); _context = ContextHandle.Zero; } if (_device != IntPtr.Zero) { Alc.CloseDevice(_device); _device = IntPtr.Zero; } }
public void Dispose() { Alc.MakeContextCurrent(ContextHandle.Zero); if (alContext != ContextHandle.Zero) { Alc.DestroyContext(alContext); alContext = ContextHandle.Zero; } if (alDevice != IntPtr.Zero) { Alc.CloseDevice(alDevice); alDevice = IntPtr.Zero; } Instance = null; }
public void Dispose() { if (_context != ContextHandle.Zero) { Alc.MakeContextCurrent(ContextHandle.Zero); Alc.DestroyContext(_context); } _context = ContextHandle.Zero; if (_device != IntPtr.Zero) { Alc.CloseDevice(_device); } _device = IntPtr.Zero; }
// deinitialize internal static void Deinitialize() { if (OpenAlContext != ContextHandle.Zero) { SoundManager.StopAllSounds(true); SoundManager.UnuseAllSoundsBuffers(); Alc.MakeContextCurrent(ContextHandle.Zero); Alc.DestroyContext(OpenAlContext); OpenAlContext = ContextHandle.Zero; } if (OpenAlDevice != IntPtr.Zero) { Alc.CloseDevice(OpenAlDevice); OpenAlDevice = IntPtr.Zero; } }
/// <summary>Deinitializes audio.</summary> internal static void Deinitialize() { StopAllSounds(); UnloadAllBuffers(); if (OpenAlContext != ContextHandle.Zero) { Alc.MakeContextCurrent(ContextHandle.Zero); Alc.DestroyContext(OpenAlContext); OpenAlContext = ContextHandle.Zero; } if (OpenAlDevice != IntPtr.Zero) { Alc.CloseDevice(OpenAlDevice); OpenAlDevice = IntPtr.Zero; } }
/// <summary> /// /// </summary> private void CleanUpOpenAl() { Alc.MakeContextCurrent(NullContext); if (_context != NullContext) { Alc.DestroyContext(_context); _context = NullContext; } if (_device != IntPtr.Zero) { Alc.CloseDevice(_device); _device = IntPtr.Zero; } _bSoundAvailable = false; }
static void Dispose(ref IntPtr device, ref ContextHandle context) { if (context != ContextHandle.Zero) { Alc.MakeContextCurrent(ContextHandle.Zero); Alc.DestroyContext(context); } context = ContextHandle.Zero; if (device != IntPtr.Zero) { Alc.CloseDevice(device); } device = IntPtr.Zero; }
public static void Teardown() { foreach (object o in Sounds.Keys) { Sound sound = (Sound)Sounds[o]; AL.SourceStop(sound.SourceId); AL.DeleteSource(sound.SourceId); AL.DeleteBuffer(sound.BufferId); } if (Alc.MakeContextCurrent(ContextHandle.Zero)) { Alc.DestroyContext(AudioCtx); if (Alc.CloseDevice(AudioDevice)) { } } }
// initialize internal static void Initialize() { // openal OpenAlDevice = Alc.OpenDevice(null); if (OpenAlDevice != IntPtr.Zero) { OpenAlContext = Alc.CreateContext(OpenAlDevice, (int[])null); if (OpenAlContext != ContextHandle.Zero) { Alc.MakeContextCurrent(OpenAlContext); AL.SpeedOfSound(343.0f); AL.DistanceModel(ALDistanceModel.None); } else { Alc.CloseDevice(OpenAlDevice); OpenAlDevice = IntPtr.Zero; System.Windows.Forms.MessageBox.Show("The sound device could be opened, but the sound context could not be created.", "openBVE", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand); } } else { OpenAlContext = ContextHandle.Zero; System.Windows.Forms.MessageBox.Show("The sound device could not be opened.", "openBVE", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand); } // outer radius switch (Interface.CurrentOptions.SoundRange) { case Interface.SoundRange.Low: OuterRadiusFactorMinimum = 2.0; OuterRadiusFactorMaximum = 8.0; break; case Interface.SoundRange.Medium: OuterRadiusFactorMinimum = 4.0; OuterRadiusFactorMaximum = 16.0; break; case Interface.SoundRange.High: OuterRadiusFactorMinimum = 8.0; OuterRadiusFactorMaximum = 32.0; break; } OuterRadiusFactor = OuterRadiusFactorMaximum; }
public override void Dispose() { base.Dispose(); ///Dispose if (context != ContextHandle.Zero) { Alc.MakeContextCurrent(ContextHandle.Zero); Alc.DestroyContext(context); } context = ContextHandle.Zero; if (device != IntPtr.Zero) { Alc.CloseDevice(device); } device = IntPtr.Zero; }
private void Dispose(bool force) { if (INTERNAL_soundAvailable || force) { Alc.MakeContextCurrent(ContextHandle.Zero); if (_context != ContextHandle.Zero) { Alc.DestroyContext(_context); _context = ContextHandle.Zero; } if (_device != IntPtr.Zero) { Alc.CloseDevice(_device); _device = IntPtr.Zero; } INTERNAL_soundAvailable = false; } }
public void Dispose() { if (Disabled) { return; } lock (playingChannels) { for (int i = 0; i < playingChannels.Length; i++) { for (int j = 0; j < playingChannels[i].Length; j++) { if (playingChannels[i][j] != null) { playingChannels[i][j].Dispose(); } } } } if (streamingThread != null && !streamingThread.ThreadState.HasFlag(ThreadState.Stopped)) { streamingThread.Join(); } for (int i = loadedSounds.Count - 1; i >= 0; i--) { loadedSounds[i].Dispose(); } sourcePools[(int)SourcePoolIndex.Default]?.Dispose(); sourcePools[(int)SourcePoolIndex.Voice]?.Dispose(); if (!Alc.MakeContextCurrent(OpenTK.ContextHandle.Zero)) { throw new Exception("Failed to detach the current ALC context! (error code: " + Alc.GetError(alcDevice).ToString() + ")"); } Alc.DestroyContext(alcContext); if (!Alc.CloseDevice(alcDevice)) { throw new Exception("Failed to close ALC device!"); } }
public void Dispose() { lock (playingChannels) { for (int i = 0; i < SOURCE_COUNT; i++) { if (playingChannels[i] != null) { playingChannels[i].Dispose(); } } } if (streamingThread != null && streamingThread.ThreadState == ThreadState.Running) { streamingThread.Join(); } for (int i = loadedSounds.Count - 1; i >= 0; i--) { loadedSounds[i].Dispose(); } for (int i = 0; i < SOURCE_COUNT; i++) { AL.DeleteSource(ref alSources[i]); ALError alError = AL.GetError(); if (alError != ALError.NoError) { throw new Exception("Failed to delete alSources[" + i.ToString() + "]: " + AL.GetErrorString(alError)); } } if (!Alc.MakeContextCurrent(OpenTK.ContextHandle.Zero)) { throw new Exception("Failed to detach the current ALC context! (error code: " + Alc.GetError(alcDevice).ToString() + ")"); } Alc.DestroyContext(alcContext); if (!Alc.CloseDevice(alcDevice)) { throw new Exception("Failed to close ALC device!"); } }