Skip to content

Commit

Permalink
Solving for a little bit more bugginess
Browse files Browse the repository at this point in the history
  • Loading branch information
steinerd committed Apr 30, 2022
1 parent c743718 commit 88fd0a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
17 changes: 9 additions & 8 deletions AudioSwitcherPlugin/AudioSwitcherPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,27 @@ public AudioSwitcherPlugin()
if (Instance == null)
Instance = this;

if (this.AudioController == null)
if (this.ActiveDevices == null)
{
this.ActiveDevices = new ConcurrentStack<CoreAudioDevice>();
}

if (this.AudioController == null)
{
// Without this delay the Audio Knob (if used) stops working....
Task.Factory.StartNew(async () =>
{
await Task.Delay(TimeSpan.FromSeconds(10));
await Task.Delay(TimeSpan.FromSeconds(15));
this.AudioController = new CoreAudioController();
this.RefreshDevices();
});
}

if (this.ActiveDevices == null)
{
this.ActiveDevices = new ConcurrentStack<CoreAudioDevice>();
}

}

public override void Load() => this.LoadPluginIcons();

public override void Unload() => this.AudioController.Dispose();
public override void Unload() { }

private void OnApplicationStarted(Object sender, EventArgs e) { }

Expand Down
12 changes: 3 additions & 9 deletions AudioSwitcherPlugin/PressToTalkCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,14 @@ public bool PTTState

public CoreAudioDevice DefaultCommunicationDevice =>
AudioSwitcherPlugin.Instance.AudioController.GetDefaultDevice(AudioSwitcher.AudioApi.DeviceType.Capture, AudioSwitcher.AudioApi.Role.Communications);
public PressToTalkCommand() : base("PTT", "Hold to PTT", "Audio") { }
public PressToTalkCommand() : base("PTT", "Hold to PTT", "Controls") { }

public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChange(String propertyName)
{
if (propertyName == nameof(this.PTTState))
{
if (this.PTTState)
this.DefaultCommunicationDevice.Mute(false);

if (!this.PTTState)
this.DefaultCommunicationDevice.Mute(true);
{
this.DefaultCommunicationDevice.Mute(!this.PTTState);
}

PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
Expand Down Expand Up @@ -81,8 +77,6 @@ protected override Boolean ProcessTouchEvent(String actionParameter, DeviceTouch
return true;
}



protected override BitmapImage GetCommandImage(String actionParameter, PluginImageSize imageSize)
{
var builder = new BitmapBuilder(imageSize);
Expand Down

0 comments on commit 88fd0a4

Please sign in to comment.