Repository navigation
Enhancement: Add a three-state per-app volume lock (free, session, persistent) - #130
Merged
Merged
Conversation
Add a lock button to every app row of the mixer. It goes through three states: free, locked until the app exits, and locked also when the app starts again. While locked, the app's slider is disabled and any change to its volume is reverted: the app itself, a game at any time, the Windows mixer, hotkeys, app volume sync and the volume limit. The enforcement is event driven (session volume notifications, no polling) and the audio API is never called from inside a notification callback. Persistent locks are saved in settings.json (General.LockedAppVolumes) and applied each time the app starts, on any device. Apps are matched by AudioProcessModel.Name, like the per-app hotkeys. When Volumey closes, locked apps get back the volume they had before being locked.
Owner
…l rebuilds The lock mode is set on the app's models instead of cycling a button. An app locked until it closes is kept by its name and processes, so a model made again (format change, device re-enabled, a move) or on another device is locked too; a restarted app is free.
The lock button on each row is replaced by a three-part bar (Off, Until closed, Always) under the device box of the opened app, so every app but the System Sounds opens. A locked app's row shows a pill with the mode's icon and word, and its slider and number are greyed. Badges that don't fit next to the name move to a line of their own under it.
Until closed holds the volume, shows a pill and greys the slider; a restarted app is free; Always is saved and locks the app each time it starts; app hotkeys don't change a locked app; a locked app stays locked after a move to another device; the System Sounds have no lock.
The row is named in the Windows display language, which the app saves in General.SystemSoundsName.
Until-closed locks end once none of their processes runs, so a reused process ID doesn't bring one back. A cut-off name or device badge shows its full text in a tooltip. The lock mode's word comes from one converter (keys LockMode_*), the process IDs from AudioProcessModel, NameLinePanel's spacing is constant, and the UI tests share their row and drop-down helpers; TestAudioApp.Start takes a StartVolume.
Every session of a locked app is held and a new one starts at the locked volume; Always holds the app again after Volumey restarts; Until closed ends with a restart.
…e on exit AppVolumeLock holds one app's lock (mode, held volume and the volume it gets back on exit as one VolumeLock record) and keeps its sessions at the volume; AudioProcessModel only owns it. The mixer binds Lock.Mode and Lock.IsOn. The view model keeps every held app with its lock, so a model made again (format change, a move, another device) and a mode change keep the volume from before the lock instead of the held one. A held app's processes are checked with its executable's path, so a reused process ID doesn't keep a lock alive. The modes are named like the lock bar (Off, UntilClosed, Always), and the lock mode name binding is shared by the label and the item names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #47. Partially addresses #69.
What
Each app in the mixer now has a lock button with three states:
While locked:
When Volumey closes, locked apps get back the volume they had before being locked, so nothing stays muted or stuck once Volumey is not running. Persistent locks are kept and applied at the next start.
This solves #47 (apps such as Alexa starting at 100% after a reboot).
It can also be used as a blacklist-like workaround for #69: apps that always start at 100% (e.g. the WhatsApp desktop app) can be locked persistently at 0%, muted or 10%. It is not a full whitelist/blacklist for the "Limit the launched app volume if it is 100%" option.
How
AudioProcessModel: lock state (LockMode), a guard in theVolumesetter and a handler on every session'sVolumeChangedthat puts the locked volume back. New sessions of a locked app get the volume too.AppVolumeLockViewModel(new feature): handles the button, locks the app on all devices, savesGeneral.LockedAppVolumesand applies the saved entries to apps that are running or start later. Closing Volumey releases the locks through it.SessionsListView.xaml: lock button (icon and tooltip per state) and slider disabled while locked.Notes
AudioProcessModel.Name(the executable description), the same mechanism the per-app hotkeys use. Two different apps with the same description would share a lock. If that turns out to be a problem, more fields (e.g. CompanyName, ProductName) could be considered.Testing
Tested only on Windows 10.
Let me know if anything needs changes, and feel free to change anything on top of my branch.