Exemplo n.º 1
0
        public void SetDefaultEndPoint(string deviceId, EDataFlow flow, IEnumerable <ERole> roles, uint processId)
        {
            Trace.WriteLine($"ExtendedPolicyClient SetDefaultEndPoint {deviceId} [{flow}] {processId}");
            try
            {
                if (string.IsNullOrEmpty(deviceId))
                {
                    return;
                }

                using var deviceIdStr = HSTRING.FromString(GenerateDeviceId(deviceId, flow));
                foreach (var eRole in roles)
                {
                    PolicyConfig.SetPersistedDefaultAudioEndpoint(processId, flow, eRole, deviceIdStr);
                }
            }
            catch (COMException e) when((e.ErrorCode & ErrorConst.COM_ERROR_MASK) == ErrorConst.COM_ERROR_NOT_FOUND)
            {
                throw new DeviceNotFoundException($"Can't set default as {deviceId}", e, deviceId);
            }
            catch (Exception ex)
            {
                Trace.WriteLine($"{ex}");
            }
        }
Exemplo n.º 2
0
        static void SetNodeValueString(string str, IXmlDocument xmldoc, IXmlNode node)
        {
            IXmlText textNode;

            using (var hStrign_str = HSTRING.FromString(str))
                ComFunctions.CheckHRESULT(xmldoc.CreateTextNode(hStrign_str, out textNode));
            AppendNode(node, (IXmlNode)textNode);
        }
Exemplo n.º 3
0
        static IXmlElement CreateElement(IXmlDocument xmldoc, string elementName)
        {
            IXmlElement element;

            using (var hStrign_elementName = HSTRING.FromString(elementName))
                ComFunctions.CheckHRESULT(xmldoc.CreateElement(hStrign_elementName, out element));
            return(element);
        }
Exemplo n.º 4
0
        static IXmlNodeList GetNodes(IXmlDocument xmldoc, string tagName)
        {
            IXmlNodeList nodes;

            using (var hStrign_tagName = HSTRING.FromString(tagName))
                ComFunctions.CheckHRESULT(xmldoc.GetElementsByTagName(hStrign_tagName, out nodes));
            return(nodes);
        }
        public static IAudioPolicyConfigFactory Create()
        {
            var iid = GuidGenerator.CreateIID(typeof(IAudioPolicyConfigFactory));

            using var name = HSTRING.FromString("Windows.Media.Internal.AudioPolicyConfig");
            ComBase.RoGetActivationFactory(name, ref iid, out object factory);
            return(factory.As <IAudioPolicyConfigFactory>());
        }
Exemplo n.º 6
0
        static void SetImageSrc(IXmlDocument xmldoc, string imagePath)
        {
            IXmlNode imageNode = GetNode(xmldoc, "image");
            IXmlNode srcAttribute;

            using (var hString_name = HSTRING.FromString("src"))
                ComFunctions.CheckHRESULT(imageNode.Attributes.GetNamedItem(hString_name, out srcAttribute));
            SetNodeValueString(imagePath, xmldoc, srcAttribute);
        }
Exemplo n.º 7
0
 static void SetAttribute(IXmlElement node, string attributeName, string attributeValue)
 {
     using (var hString_attributeName = HSTRING.FromString(attributeName))
         using (var hString_attributeValue = HSTRING.FromString(attributeValue))
             ComFunctions.CheckHRESULT(node.SetAttribute(hString_attributeName, hString_attributeValue));
 }