static string DumpSession(string indent, IAudioDeviceSessionInternal session) { string flags = session.IsDesktopApp ? "Desktop " : "Modern "; if (session.IsSystemSoundsSession) { flags += "SystemSounds "; } bool isAlive = false; try { using (Process.GetProcessById(session.ProcessId)) { } isAlive = true; } catch (Exception) { } StringBuilder sb = new StringBuilder(); sb.AppendLine(indent + $"{session.DisplayName}"); sb.AppendLine(indent + $" [{session.State}]: {session.Volume.ToVolumeInt()}%{(session.IsMuted ? " (Muted)" : "")} {flags}pid:{session.ProcessId} {(!isAlive ? "(dead)" : "")}"); sb.AppendLine(indent + $" AppId: {session.AppId} id={session.Id}"); sb.AppendLine(indent + $" IconPath: {session.IconPath}"); sb.AppendLine(indent + $" GroupingParam: {session.GroupingParam}"); var persisted = ((IAudioDeviceManagerWindowsAudio)session.Parent.Parent).GetDefaultEndPoint(session.ProcessId); if (!string.IsNullOrWhiteSpace(persisted)) { sb.AppendLine(indent + $" Persisted Endpoint: {persisted}"); } return(sb.ToString()); }
private static void DumpSession(StringBuilder builder, string indent, IAudioDeviceSessionInternal session) { var typeText = session.IsSystemSoundsSession ? "SystemSounds" : (session.IsDesktopApp ? "Desktop" : "Modern"); builder.AppendLine(indent + $"{session.DisplayName}"); builder.AppendLine(indent + $" ({typeText}) ({session.State}) {session.Volume.ToVolumeInt()}%{(session.IsMuted ? " (Muted)" : "")} Id: {session.Id}"); builder.AppendLine(indent + $" AppId: {session.AppId} ProcessId: {session.ProcessId} Alive: {IsProcessAlive(session.ProcessId)}"); builder.AppendLine(indent + $" IconPath: {session.IconPath}"); builder.AppendLine(indent + $" GroupingParam: {session.GroupingParam}"); var persisted = ((IAudioDeviceManagerWindowsAudio)session.Parent.Parent).GetDefaultEndPoint(session.ProcessId); if (!string.IsNullOrWhiteSpace(persisted)) { builder.AppendLine(indent + $" Persisted Endpoint Id: {persisted}"); } }