Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run background process to keep conhost audio session active. #452

Merged
merged 1 commit into from
Jul 16, 2019

Conversation

maxhora
Copy link
Collaborator

@maxhora maxhora commented Jul 12, 2019

"Mute Terminal" functionality enhancement discussed in previous PR #437 (comment)

  • Tray process on startup searches for available conhost audio sessions. If no audio session is available, detached cmd.exe process is spawned to play bell sound. Tray process searches for conhost audio session again and sets relevant mute state.
  • Since first spawned cmd.exe process seats in OS background, Fluent will play only single bell sound on very first launch of Tray process (and will not play sound on "Mute Terminal" option change or on each run of Tray process as it does currently).

Copy link
Contributor

@mjs mjs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just a few things.

FluentTerminal.SystemTray/Utilities.cs Outdated Show resolved Hide resolved
FluentTerminal.SystemTray/Utilities.cs Outdated Show resolved Hide resolved
FluentTerminal.SystemTray/Utilities.cs Outdated Show resolved Hide resolved
if (isAudioSessionMuted != null)
{
audioSessionFound = true;
}
}
catch (Exception) { }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is hiding exceptions like this really a good idea? Can you be more specific about the kind of exceptions you're wanting to squash here? What about logging?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally, I was not able to get any exception on 1809/1903 and just removed try/catch block


cmdProcess.Kill();
if (deviceMuted != true)
{
VolumeControl.SetDefaultAudioEndpointMute(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be a in try-finally to ensure the audio endpoint is always unmuted even if something goes wrong.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have removed muting of device as it was discussed ( in next PR will attempt to mute audio session on its early start )

FluentTerminal.SystemTray/Utilities.cs Show resolved Hide resolved
@@ -569,44 +569,58 @@ internal static void SaveFile(string path, string content)
}
}

internal static void MuteTerminal(bool mute)
private static bool MuteConhost(bool mute, int attemptCount)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are there different attemptCount values for different call sites?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have removed looping completely

bool? deviceMuted = VolumeControl.GetDefaultAudioEndpointMute();
if (deviceMuted != true)
{
VolumeControl.SetDefaultAudioEndpointMute(true);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjs what do you think if to remove muting of audio device completely and let it play bell sound? So far it's 3-4 reports from different people to explain why the sound suddenly disappears.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I saw those reports.

If the bell plays then people will probably complain about that... it might be less confusing than muting I guess.

Terminus lets the user disable the terminal bell (or use a visual bell) and they use xtermjs too. It might be good to dig into how they do it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjs will check Terminus. Initially, I have seen that Fluent passes some option to xterm to configure bell, but I haven't seen any difference in real behavior.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bellStyle: options.bellStyle,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind about Terminus. I've just played around with it and its terminal beep suppression doesn't work.

@maxhora maxhora force-pushed the mr/enhance-muting-upstream branch from 86477f4 to 1650cef Compare July 16, 2019 18:28
@maxhora
Copy link
Collaborator Author

maxhora commented Jul 16, 2019

@felixse please take a look to have this merged, thanks

@felixse felixse merged commit 0749d9e into felixse:master Jul 16, 2019
maxhora added a commit to maxhora/FluentTerminal that referenced this pull request Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants