void IDualityBackend.Init() { AudioLibraryLoader.LoadAudioLibrary(); // Initialize OpenTK, if not done yet DefaultOpenTKBackendPlugin.InitOpenTK(); Log.Core.Write("Available devices:" + Environment.NewLine + "{0}", AudioContext.AvailableDevices.ToString(d => d == AudioContext.DefaultDevice ? d + " (Default)" : d, "," + Environment.NewLine)); // Create OpenAL audio context this.context = new AudioContext(); Log.Core.Write("Current device: {0}", this.context.CurrentDevice); // Create extension interfaces try { this.extFx = new EffectsExtension(); if (!this.extFx.IsInitialized) { this.extFx = null; } } catch (Exception) { this.extFx = null; } activeInstance = this; // Log all OpenAL specs for diagnostic purposes LogOpenALSpecs(); // Generate OpenAL source pool for (int i = 0; i < 256; i++) { int newSrc = AL.GenSource(); if (!Backend.DefaultOpenTK.AudioBackend.CheckOpenALErrors(true)) { this.sourcePool.Push(newSrc); } else { break; } } this.availSources = this.sourcePool.Count; Log.Core.Write("{0} sources available", this.sourcePool.Count); // Set up the streaming thread this.streamWorkerEnd = false; this.streamWorkerQueue = new List <NativeAudioSource>(); this.streamWorkerQueueEvent = new AutoResetEvent(false); this.streamWorker = new Thread(ThreadStreamFunc); this.streamWorker.IsBackground = true; this.streamWorker.Start(); }
void IDualityBackend.Init() { AudioLibraryLoader.LoadAudioLibrary(); Log.Core.Write("Available devices:" + Environment.NewLine + "{0}", AudioContext.AvailableDevices.ToString(d => d == AudioContext.DefaultDevice ? d + " (Default)" : d, "," + Environment.NewLine)); // Create OpenAL audio context this.context = new AudioContext(); Log.Core.Write("Current device: {0}", this.context.CurrentDevice); // Generate OpenAL source pool for (int i = 0; i < 256; i++) { int newSrc = AL.GenSource(); if (!Backend.DefaultOpenTK.AudioBackend.CheckOpenALErrors(true)) { this.sourcePool.Push(newSrc); } else { break; } } this.availSources = this.sourcePool.Count; Log.Core.Write("{0} sources available", this.sourcePool.Count); // Set up the streaming thread this.streamWorkerEnd = false; this.streamWorkerQueue = new List <NativeAudioSource>(); this.streamWorkerQueueEvent = new AutoResetEvent(false); this.streamWorker = new Thread(ThreadStreamFunc); this.streamWorker.IsBackground = true; this.streamWorker.Start(); activeInstance = this; }
void IDualityBackend.Shutdown() { // Shut down the streaming thread if (this.streamWorker != null) { this.streamWorkerEnd = true; if (!this.streamWorker.Join(1000)) { this.streamWorker.Abort(); } this.streamWorkerQueueEvent.Dispose(); this.streamWorkerEnd = false; this.streamWorkerQueueEvent = null; this.streamWorkerQueue = null; this.streamWorker = null; } if (activeInstance == this) { activeInstance = null; } // Clear OpenAL source pool foreach (int alSource in this.sourcePool) { AL.DeleteSource(alSource); } // Shut down OpenAL context if (this.context != null) { this.context.Dispose(); this.context = null; } AudioLibraryLoader.UnloadAudioLibrary(); }
void IDualityBackend.Shutdown() { // Shut down the streaming thread if (this.streamWorker != null) { this.streamWorkerEnd = true; if (!this.streamWorker.Join(1000)) { this.streamWorker.Abort(); } this.streamWorkerQueueEvent.Dispose(); this.streamWorkerEnd = false; this.streamWorkerQueueEvent = null; this.streamWorkerQueue = null; this.streamWorker = null; } if (activeInstance == this) activeInstance = null; // Clear OpenAL source pool foreach (int alSource in this.sourcePool) { AL.DeleteSource(alSource); } // Shut down OpenAL context if (this.context != null) { this.context.Dispose(); this.context = null; } AudioLibraryLoader.UnloadAudioLibrary(); }
void IDualityBackend.Init() { AudioLibraryLoader.LoadAudioLibrary(); Log.Core.Write("Available devices:" + Environment.NewLine + "{0}", AudioContext.AvailableDevices.ToString(d => d == AudioContext.DefaultDevice ? d + " (Default)" : d, "," + Environment.NewLine)); // Create OpenAL audio context this.context = new AudioContext(); Log.Core.Write("Current device: {0}", this.context.CurrentDevice); // Generate OpenAL source pool for (int i = 0; i < 256; i++) { int newSrc = AL.GenSource(); if (!Backend.DefaultOpenTK.AudioBackend.CheckOpenALErrors(true)) this.sourcePool.Push(newSrc); else break; } this.availSources = this.sourcePool.Count; Log.Core.Write("{0} sources available", this.sourcePool.Count); // Set up the streaming thread this.streamWorkerEnd = false; this.streamWorkerQueue = new List<NativeAudioSource>(); this.streamWorkerQueueEvent = new AutoResetEvent(false); this.streamWorker = new Thread(ThreadStreamFunc); this.streamWorker.IsBackground = true; this.streamWorker.Start(); activeInstance = this; }
void IDualityBackend.Init() { AudioLibraryLoader.LoadAudioLibrary(); // Initialize OpenTK, if not done yet DefaultOpenTKBackendPlugin.InitOpenTK(); Log.Core.Write("Available devices:" + Environment.NewLine + "{0}", AudioContext.AvailableDevices.ToString(d => d == AudioContext.DefaultDevice ? d + " (Default)" : d, "," + Environment.NewLine)); // Create OpenAL audio context this.context = new AudioContext(); Log.Core.Write("Current device: {0}", this.context.CurrentDevice); // Create extension interfaces try { this.extFx = new EffectsExtension(); if (!this.extFx.IsInitialized) this.extFx = null; } catch (Exception) { this.extFx = null; } activeInstance = this; // Log all OpenAL specs for diagnostic purposes LogOpenALSpecs(); // Generate OpenAL source pool for (int i = 0; i < 256; i++) { int newSrc = AL.GenSource(); if (!Backend.DefaultOpenTK.AudioBackend.CheckOpenALErrors(true)) this.sourcePool.Push(newSrc); else break; } this.availSources = this.sourcePool.Count; Log.Core.Write("{0} sources available", this.sourcePool.Count); // Set up the streaming thread this.streamWorkerEnd = false; this.streamWorkerQueue = new List<NativeAudioSource>(); this.streamWorkerQueueEvent = new AutoResetEvent(false); this.streamWorker = new Thread(ThreadStreamFunc); this.streamWorker.IsBackground = true; this.streamWorker.Start(); }