Compare commits

...
9 Commits
Author SHA1 Message Date
ckaczor 46fce20771 Raise auto changed event
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 34s
2026-08-18 15:38:58 -04:00
ckaczor d28f421ea3 Try hooking up talking state to mute state
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 34s
2026-08-18 15:36:01 -04:00
ckaczor 5aeefebc47 Add logging and track mute state
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 33s
2026-08-18 15:18:25 -04:00
ckaczor ca956f207b Adjust mute detection/logging
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 33s
2026-08-18 14:59:20 -04:00
ckaczor ad212e7416 Log volume notifications
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 33s
2026-08-18 14:52:56 -04:00
ckaczor 8c63b93d09 Tweak logging and change settings string
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 33s
2026-08-18 14:43:22 -04:00
ckaczor 6ba4854bd8 Fix update check URL
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 32s
2026-08-18 13:14:46 -04:00
ckaczor 2be5b86b17 Fix a few architecture flags
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 31s
2026-08-18 13:09:01 -04:00
ckaczor a75a2d8926 Update main with latest code
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 34s
2026-08-18 13:05:35 -04:00
8 changed files with 59 additions and 33 deletions
+3 -4
View File
@@ -4,7 +4,6 @@ on:
push:
branches:
- main
- develop
workflow_dispatch:
@@ -32,6 +31,6 @@ jobs:
run: |
export PATH="$PATH:/root/.dotnet/tools"
dotnet tool install -g vpk
#vpk [win] download gitea --channel win-x86 --repoUrl https://gitea.kaczorzoo.net/ckaczor/WorkIndicator
vpk [win] pack --channel win-x64 -u WorkIndicator -v ${{ steps.version.outputs.version }} -p publish --packTitle "Work Indicator" --shortcuts StartMenuRoot --framework net10.0-x64-desktop
vpk [win] upload gitea --channel win-x64 --repoUrl https://gitea.kaczorzoo.net/ckaczor/WorkIndicator --publish --releaseName "${{ steps.version.outputs.version }}" --token ${{ secrets.VPK_TOKEN }}
vpk [win] download gitea --channel win-x86 --repoUrl https://gitea.kaczorzoo.net/ckaczor/WorkIndicator
vpk [win] pack --channel win-x86 -u WorkIndicator -v ${{ steps.version.outputs.version }} -p publish --packTitle "Work Indicator" --shortcuts StartMenuRoot --framework net10.0-x86-desktop
vpk [win] upload gitea --channel win-x86 --repoUrl https://gitea.kaczorzoo.net/ckaczor/WorkIndicator --publish --releaseName "${{ steps.version.outputs.version }}" --token ${{ secrets.VPK_TOKEN }}
+21 -11
View File
@@ -3,17 +3,14 @@ using NAudio.CoreAudioApi.Interfaces;
using Serilog;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows.Threading;
namespace WorkIndicator;
internal class AudioDevice : IAudioSessionEventsHandler
{
private readonly ILogger _logger;
private readonly MMDevice _device;
private readonly Dispatcher _dispatcher;
private readonly string _friendlyName;
private readonly Dictionary<string, AudioSessionControl> _sessions = new();
public delegate void AudioSessionsChangedDelegate();
@@ -24,15 +21,17 @@ internal class AudioDevice : IAudioSessionEventsHandler
{
_logger = Log.ForContext<AudioDevice>();
_dispatcher = Dispatcher.CurrentDispatcher;
_friendlyName = device.DeviceFriendlyName;
IsMuted = device.AudioEndpointVolume.Mute;
_device = device;
_logger.Information("AudioDevice: {name} {muted}", _friendlyName, IsMuted);
_device.AudioSessionManager.AudioSessionControl.RegisterEventClient(this);
_device.AudioSessionManager.OnSessionCreated += AudioSessionManager_OnSessionCreated;
device.AudioEndpointVolume.OnVolumeNotification += AudioEndpointVolume_OnVolumeNotification;
device.AudioSessionManager.AudioSessionControl.RegisterEventClient(this);
device.AudioSessionManager.OnSessionCreated += AudioSessionManager_OnSessionCreated;
_device.AudioSessionManager.RefreshSessions();
var sessions = _device.AudioSessionManager.Sessions;
device.AudioSessionManager.RefreshSessions();
var sessions = device.AudioSessionManager.Sessions;
for (var i = 0; i < sessions.Count; i++)
{
@@ -40,6 +39,15 @@ internal class AudioDevice : IAudioSessionEventsHandler
}
}
private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
{
_logger.Information("AudioEndpointVolume_OnVolumeNotification: {name} {muted}", _friendlyName, data.Muted);
IsMuted = data.Muted;
AudioSessionsChanged?.Invoke();
}
private void AudioSessionManager_OnSessionCreated(object sender, IAudioSessionControl newSession)
{
var session = new AudioSessionControl(newSession);
@@ -61,9 +69,11 @@ internal class AudioDevice : IAudioSessionEventsHandler
public int ActiveSessionCount => _sessions.Values.Count(s => s.State == AudioSessionState.AudioSessionStateActive);
public bool IsMuted { get; private set; }
void IAudioSessionEventsHandler.OnVolumeChanged(float volume, bool isMuted)
{
_dispatcher.Invoke(() => { Debug.WriteLine($"{_device.DeviceFriendlyName}: {volume} {isMuted} {_device.AudioEndpointVolume.Mute}"); });
_logger.Information("OnVolumeChanged: {name} {volume} {isMuted}", _friendlyName, volume, isMuted);
}
void IAudioSessionEventsHandler.OnDisplayNameChanged(string displayName)
+20 -10
View File
@@ -1,20 +1,26 @@
using NAudio.CoreAudioApi;
using NAudio.CoreAudioApi.Interfaces;
using System.Collections.Generic;
using System.Linq;
using Serilog;
using System.Collections.Generic;
namespace WorkIndicator;
internal enum MicrophoneStatus
{
NotUsed,
UsedMuted,
UsedNotMuted
}
internal class AudioWatcher : IMMNotificationClient
{
private readonly ILogger _logger = Log.ForContext<AudioWatcher>();
private readonly MMDeviceEnumerator _deviceEnumerator = new();
private readonly Dictionary<string, AudioDevice> _inputDevices = new();
public delegate void MicrophoneInUseChangedDelegate(bool microphoneInUse);
public delegate void MicrophoneStatusChangedDelegate(MicrophoneStatus microphoneStatus);
public event MicrophoneInUseChangedDelegate MicrophoneInUseChanged;
public event MicrophoneStatusChangedDelegate MicrophoneStatusChanged;
public void Start()
{
@@ -43,12 +49,12 @@ internal class AudioWatcher : IMMNotificationClient
_inputDevices[captureDevice.ID] = audioDevice;
MicrophoneInUseChanged?.Invoke(MicrophoneInUse());
MicrophoneStatusChanged?.Invoke(GetMicrophoneStatus());
}
private void AudioDevice_AudioSessionsChanged()
{
MicrophoneInUseChanged?.Invoke(MicrophoneInUse());
MicrophoneStatusChanged?.Invoke(GetMicrophoneStatus());
}
private void HandleRemovedDevice(string deviceId)
@@ -57,7 +63,7 @@ internal class AudioWatcher : IMMNotificationClient
_inputDevices.Remove(deviceId);
MicrophoneInUseChanged?.Invoke(MicrophoneInUse());
MicrophoneStatusChanged?.Invoke(GetMicrophoneStatus());
}
public void Stop()
@@ -68,11 +74,15 @@ internal class AudioWatcher : IMMNotificationClient
_deviceEnumerator.Dispose();
}
public bool MicrophoneInUse()
public MicrophoneStatus GetMicrophoneStatus()
{
var totalActiveSessionCount = _inputDevices.Sum(i => i.Value.ActiveSessionCount);
foreach (var inputDevice in _inputDevices.Values)
{
if (inputDevice.ActiveSessionCount > 0)
return inputDevice.IsMuted ? MicrophoneStatus.UsedMuted : MicrophoneStatus.UsedNotMuted;
}
return totalActiveSessionCount > 0;
return MicrophoneStatus.NotUsed;
}
void IMMNotificationClient.OnDeviceStateChanged(string deviceId, DeviceState newState)
+6 -1
View File
@@ -1,10 +1,13 @@
using System;
using System.Diagnostics;
using Serilog;
namespace WorkIndicator.Delcom
{
public class StoplightIndicator : IDisposable
{
private readonly ILogger _logger;
public enum Light
{
Green,
@@ -25,6 +28,8 @@ namespace WorkIndicator.Delcom
public StoplightIndicator()
{
_logger = Log.ForContext<StoplightIndicator>();
Device = new Delcom();
Device.Open();
@@ -74,7 +79,7 @@ namespace WorkIndicator.Delcom
_yellow = yellow;
_green = green;
Debug.WriteLine($"Red: {_red}, Yellow: {_yellow}, Green: {_green}");
_logger.Information("Red: {red}, Yellow: {yellow}, Green: {green}", _red, _yellow, _green);
port1 = port1.SetBitValue((int) Light.Green, green == LightState.Off);
port1 = port1.SetBitValue((int) Light.Yellow, yellow == LightState.Off);
+6 -4
View File
@@ -30,7 +30,7 @@ namespace WorkIndicator
Properties.Settings.Default.PropertyChanged += HandleSettingChange;
AudioWatcher.MicrophoneInUseChanged += AudioWatcher_MicrophoneInUseChanged;
AudioWatcher.MicrophoneStatusChanged += AudioWatcher_MicrophoneStatusChanged;
AudioWatcher.Start();
_initialized = true;
@@ -50,7 +50,7 @@ namespace WorkIndicator
UpdateLights();
}
private static void AudioWatcher_MicrophoneInUseChanged(bool microphoneInUse)
private static void AudioWatcher_MicrophoneStatusChanged(MicrophoneStatus microphoneStatus)
{
UpdateLights();
}
@@ -90,9 +90,11 @@ namespace WorkIndicator
if (status == Status.Auto)
{
if (AudioWatcher.MicrophoneInUse())
var microphoneStatus = AudioWatcher.GetMicrophoneStatus();
if (microphoneStatus != MicrophoneStatus.NotUsed)
{
status = Status.OnPhone;
status = microphoneStatus == MicrophoneStatus.UsedMuted ? Status.OnPhone : Status.Talking;
}
else
{
+1 -1
View File
@@ -188,7 +188,7 @@ namespace WorkIndicator.Properties {
}
/// <summary>
/// Looks up a localized string similar to Settings.
/// Looks up a localized string similar to Settings....
/// </summary>
public static string NotificationIconContextMenuSettings {
get {
+1 -1
View File
@@ -201,7 +201,7 @@ Would you like to download and install it now?</value>
<value>Talking</value>
</data>
<data name="NotificationIconContextMenuSettings" xml:space="preserve">
<value>Settings</value>
<value>Settings...</value>
</data>
<data name="StatusFree" xml:space="preserve">
<value>Free</value>
+1 -1
View File
@@ -11,7 +11,7 @@ internal static class UpdateCheck
{
private static UpdateManager _updateManager;
public static UpdateManager UpdateManager => _updateManager ??= new UpdateManager(new GithubSource("https://github.com/ckaczor/WorkIndicator", null, false));
public static UpdateManager UpdateManager => _updateManager ??= new UpdateManager(new GiteaSource("https://gitea.kaczorzoo.net/ckaczor/WorkIndicator", null, false));
public static string LocalVersion => (UpdateManager.CurrentVersion ?? new SemanticVersion(0, 0, 0)).ToString();