Пример #1
0
 void OnSystemChanged(object sender, EventArgs e)
 {
     _suspendDeviceChanged = true;
     try
     {
         XtService s = _platform.GetService((XtSystem)_system.SelectedItem);
         _streamType.DataSource   = GetStreamTypes(s);
         _streamType.SelectedItem = StreamType.Render;
         ClearDevices();
         var defaultInputId  = s.GetDefaultDeviceId(false);
         var defaultOutputId = s.GetDefaultDeviceId(true);
         using var inputList  = s.OpenDeviceList(XtEnumFlags.Input);
         using var outputList = s.OpenDeviceList(XtEnumFlags.Output);
         var inputs  = GetDeviceInfos(s, inputList, defaultInputId);
         var outputs = GetDeviceInfos(s, outputList, defaultOutputId);
         _input.SystemChanged(s, inputs);
         _output.SystemChanged(s, outputs);
         _serviceCaps.Text           = s.GetCapabilities().ToString();
         _secondaryInput.DataSource  = new List <DeviceInfo>(inputs);
         _secondaryOutput.DataSource = new List <DeviceInfo>(outputs);
         _defaultInput.Text          = defaultInputId == null ? "[None]" : inputList.GetName(defaultInputId);
         _defaultOutput.Text         = defaultOutputId == null ? "[None]" : outputList.GetName(defaultOutputId);
     } finally
     {
         _suspendDeviceChanged = false;
     }
     FormatOrDeviceChanged();
 }
Пример #2
0
        public static void Main()
        {
            XtAudio.SetOnError(OnError);
            using XtPlatform platform = XtAudio.Init("Sample", IntPtr.Zero);
            try
            {
                XtVersion version = XtAudio.GetVersion();
                Console.WriteLine("Version: " + version.major + "." + version.minor);
                XtSystem pro = platform.SetupToSystem(XtSetup.ProAudio);
                Console.WriteLine("Pro Audio: " + pro + " (" + (platform.GetService(pro) != null) + ")");
                XtSystem system = platform.SetupToSystem(XtSetup.SystemAudio);
                Console.WriteLine("System Audio: " + system + " (" + (platform.GetService(system) != null) + ")");
                XtSystem consumer = platform.SetupToSystem(XtSetup.ConsumerAudio);
                Console.WriteLine("Consumer Audio: " + consumer + " (" + (platform.GetService(consumer) != null) + ")");

                foreach (XtSystem s in platform.GetSystems())
                {
                    XtService service = platform.GetService(s);
                    using XtDeviceList all = service.OpenDeviceList(XtEnumFlags.All);
                    Console.WriteLine("System: " + s);
                    Console.WriteLine("  Capabilities: " + service.GetCapabilities());
                    string defaultInput = service.GetDefaultDeviceId(false);
                    if (defaultInput != null)
                    {
                        string name = all.GetName(defaultInput);
                        Console.WriteLine("  Default input: " + name + " (" + defaultInput + ")");
                    }
                    string defaultOutput = service.GetDefaultDeviceId(true);
                    if (defaultOutput != null)
                    {
                        string name = all.GetName(defaultOutput);
                        Console.WriteLine("  Default output: " + name + " (" + defaultOutput + ")");
                    }
                    using XtDeviceList inputs = service.OpenDeviceList(XtEnumFlags.Input);
                    Console.WriteLine("  Input device count: " + inputs.GetCount());
                    PrintDevices(service, inputs);
                    using XtDeviceList outputs = service.OpenDeviceList(XtEnumFlags.Output);
                    Console.WriteLine("  Output device count: " + outputs.GetCount());
                    PrintDevices(service, outputs);
                }
            } catch (XtException e)
            { Console.WriteLine(XtAudio.GetErrorInfo(e.GetError())); } catch (Exception e)
            { Console.WriteLine(e.Message); }
        }