コード例 #1
0
        private OpenALSoundController()
        {
            try
            {
                this.context = new AudioContext();
            }
            catch (Exception ex)
            {
                OpenALSoundController.Log("Last error in enumerator is " + AudioDeviceEnumerator.LastError);
                int num = (int)MessageBox.Show("Error initializing audio subsystem. Game will now exit.\n(see debug log for more details)", "OpenAL Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                throw;
            }
            OpenALSoundController.Log("Sound manager initialized!");
            int[]  data1          = new int[1];
            IntPtr contextsDevice = Alc.GetContextsDevice(Alc.GetCurrentContext());

            Alc.GetInteger(contextsDevice, AlcGetInteger.AttributesSize, 1, data1);
            int[] data2 = new int[data1[0]];
            Alc.GetInteger(contextsDevice, AlcGetInteger.AllAttributes, data1[0], data2);
            for (int index = 0; index < data2.Length; ++index)
            {
                if (data2[index] == 4112)
                {
                    OpenALSoundController.Log("Available mono sources : " + (object)data2[index + 1]);
                    break;
                }
            }
            this.filterId = ALHelper.Efx.GenFilter();
            ALHelper.Efx.Filter(this.filterId, EfxFilteri.FilterType, 1);
            ALHelper.Efx.Filter(this.filterId, EfxFilterf.LowpassGain, 1f);
            ALHelper.Efx.Filter(this.filterId, EfxFilterf.LowpassGainHF, 1f);
            AL.DistanceModel(ALDistanceModel.InverseDistanceClamped);
            this.freeBuffers = new ConcurrentStack <int>();
            this.ExpandBuffers(256);
            this.allocatedBuffers   = new Dictionary <SoundEffect, OpenALSoundController.BufferAllocation>();
            this.staleAllocations   = new List <KeyValuePair <SoundEffect, OpenALSoundController.BufferAllocation> >();
            this.filteredSources    = new HashSet <int>();
            this.activeSoundEffects = new List <SoundEffectInstance>();
            this.freeSources        = new ConcurrentStack <int>();
            this.ExpandSources(64);
        }