public string GetDefaultEndPoint(int processId) { int hr; EnsurePolicyConfig(); hr = _sharedPolicyConfig.GetPersistedDefaultAudioEndpoint((uint)processId, _flow, Role.Multimedia | Role.Console, out string deviceId); if (hr == HResult.S_OK) { return(UnpackDeviceId(deviceId)); } else { Exception ex = Marshal.GetExceptionForHR(hr); // If a process doesn't have a persisted default audio endpoint for a DataFlow direction, an ArgumentException is raised. Ignore it. if (ex.GetType() == typeof(ArgumentException)) { return(null); } else { // Some other exception type has occurred but we don't know why. Trace.WriteLine($"{ex}"); return(null); } } }
public static string GetDefaultEndPoint(int processId) { try { EnsurePolicyConfig(); s_sharedPolicyConfig.GetPersistedDefaultAudioEndpoint((uint)processId, EDataFlow.eRender, ERole.eMultimedia | ERole.eConsole, out string deviceId); return(UnpackDeviceId(deviceId)); } catch (Exception ex) { AppTrace.LogWarning(ex); } return(null); }
public string GetDefaultEndPoint(int processId) { try { EnsurePolicyConfig(); _sharedPolicyConfig.GetPersistedDefaultAudioEndpoint((uint)processId, _flow, ERole.eMultimedia | ERole.eConsole, out string deviceId); return(UnpackDeviceId(deviceId)); } catch (Exception ex) { Trace.WriteLine($"{ex}"); } return(null); }