コード例 #1
0
        internal static void PopulateCaptureDevices()
        {
            // clear microphones
            _allMicrophones.Clear();

            Default = null;

            // default device
            string defaultDevice = ALC.GetString(IntPtr.Zero, ALCGetString.CaptureDefaultDeviceSpecifier);

#if WINDOWS || DESKTOPGL
            // enumarating capture devices
            IntPtr deviceList = ALC.alcGetString(IntPtr.Zero, (int)ALCGetString.CaptureDeviceSpecifier);

            // we need to marshal a string array
            string?deviceIdentifier = Marshal.PtrToStringAnsi(deviceList);
            while (!string.IsNullOrEmpty(deviceIdentifier))
            {
                var microphone = new Microphone(deviceIdentifier);
                _allMicrophones.Add(microphone);
                if (deviceIdentifier == defaultDevice)
                {
                    Default = microphone;
                }

                deviceList      += deviceIdentifier.Length + 1;
                deviceIdentifier = Marshal.PtrToStringAnsi(deviceList);
            }
#else
            // Xamarin platforms don't provide a handle to alGetString that allow to marshal string
            // arrays so we're basically only adding the default microphone
            Microphone microphone = new Microphone(defaultDevice);
            _allMicrophones.Add(microphone);
            Default = microphone;
#endif
        }