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; }