コード例 #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);
            }
        }
コード例 #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);
        }
コード例 #3
0
        public static void LoadSettings(string path, int timeout)
        {
            var wrapper = new AudioWrapper();

            var xml = new XmlDocument();

            xml.Load(path);

            foreach (var flow in DataFlowTypesToWork)
            {
                foreach (var role in RoleTypesToWork)
                {
                    var selectSingleNode = xml.SelectSingleNode(string.Format("/config/{0}-{1}", flow, role));
                    if (selectSingleNode == null)
                    {
                        continue;
                    }
                    SetWithTimeout(wrapper, flow, role, selectSingleNode.InnerText, timeout);
                }
            }
        }