/// <summary> /// Switch the audio endpoint of the given process /// </summary> /// <param name="deviceId">Id of the device</param> /// <param name="role">Which role to switch</param> /// <param name="flow">Which flow to switch</param> /// <param name="processId">ProcessID of the process</param> public void SwitchProcessTo(string deviceId, ERole role, EDataFlow flow, uint processId) { var roles = new[] { ERole.eConsole, ERole.eCommunications, ERole.eMultimedia }; if (role != ERole.ERole_enum_count) { roles = new[] { role }; } ComThread.Invoke((() => { var currentEndpoint = roles.Select(eRole => ExtendPolicyClient.GetDefaultEndPoint(flow, eRole, processId)).FirstOrDefault(endpoint => !string.IsNullOrEmpty(endpoint)); if (deviceId.Equals(currentEndpoint)) { Trace.WriteLine($"Default endpoint for {processId} already {deviceId}"); return; } ExtendPolicyClient.SetDefaultEndPoint(deviceId, flow, roles, processId); })); }
/// <summary> /// Get the device used by the given process /// </summary> /// <param name="flow"></param> /// <param name="role"></param> /// <param name="processId"></param> /// <returns></returns> public string GetUsedDevice(EDataFlow flow, ERole role, uint processId) { return(ComThread.Invoke(() => ExtendPolicyClient.GetDefaultEndPoint(flow, role, processId))); }