Ejemplo n.º 1
0
        private static void SetWithTimeout(AudioWrapper wrapper, AudioWrapper.EDataFlow flow, AudioWrapper.ERole role,
                                           string devId, int timeout)
        {
            var endTime = Environment.TickCount + timeout * 1000;

            for (;;)
            {
                wrapper.SetDefaultDevice(flow, role, devId);
                if (wrapper.GetDefaultDevice(flow, role) == devId || (timeout != -1 && Environment.TickCount > endTime))
                {
                    return;
                }
                Thread.Sleep(1000);
            }
        }
Ejemplo n.º 2
0
        public static void SaveSettings(string path, int timeout)
        {
            var wrapper = new AudioWrapper();

            var xml = new XmlDocument();

            xml.LoadXml("<config></config>");

            foreach (var flow in DataFlowTypesToWork)
            {
                foreach (var role in RoleTypesToWork)
                {
                    var node = xml.CreateElement(string.Format("{0}-{1}", flow, role));
                    node.InnerText = wrapper.GetDefaultDevice(flow, role);
                    xml.DocumentElement.AppendChild(node);
                }
            }

            xml.Save(path);
        }