dlprows / FocusVolumeControl

Stream Deck+ plugin for controlling the focused application's volume
MIT License
3 stars 1 forks source link

Muting app outside of the plugin doesn't get reflected #8

Closed bananacity closed 9 months ago

bananacity commented 9 months ago

So if I mute an app through Windows Volume Mixer manually or using the Elgato volume adjusting plugin it doesn't show it as muted in the plugin.

Adjusting volume manually in Windows volume mixer is reflected correctly however just not when i mute an app

dlprows commented 9 months ago

Yeah, i noticed this in my testing too. What's going on is there's an audio session associated to every device. so headphones, speakers, etc (even if they're not currently connected) and the current logic is that it shows as muted if all of the audio sessions are muted. when it should probably be that its muted if any of the audio sessions are muted.

It shouldn't be too difficult for me to fix, but it might be a few days before i have a chance to work on it

dlprows commented 9 months ago

I had a little bit of time to look at things, and I don't think what i initially thought was happening is what's happening.

Are you using something like voicemeeter to determine volume outputs on an app by app basis, or are you just sending all volume through the volume mixer's output device?

When I'm sending all audio through a single audio device, I'm having no problems with muting outside the plugin reflecting correctly in the plugin. When I assign apps to specific device outputs instead of through the the default output device, things behave very odd until I restart the app that I assigned to a device.

But once I restart them, they behave just fine.

bananacity commented 9 months ago

Ah okay, I do have some usb speakers that I sometimes switch my main windows output device to so its possible certain apps have those speakers saved but the majority of apps don't.

weirdly enough I just tested it out now and muting outside of the plugin is working correctly so maybe it was just csgo that was acting weird yesterday as that's one that i have to set my output device manually inside the game. but yeah seems like it's all working great so I can close this

dlprows commented 9 months ago

There is definitely some weirdness in the windows audio api that I've run into that can definitely account for what you've seen.

Some apps like Discord, and Steam have an audio session on all devices. And there's not a good way of knowing which session its going to actually play to. This is no problem when it comes to changing the volume, or whether its muted, because just apply the change to all sessions for a process. And that way it doesn't matter where you're outputting to.

I've found how to find which output you have a process associated to. for example if you have chrome going to your speakers instead of to the default device. But the apps don't have to respect that choice. For example, if you set your output device to speakers, and in volume mixer you set discord to a bluetooth speaker, and then in the discord app you pick headphones, it will output to headphones, ignoring the selection you made in the volume mixer.

All of this weirdness makes it so that you don't have a 100% correct way of knowing exactly which audio session to change, which is why i change all of them. But It unfortunately means that if they don't all say the same volume and mute status, i don't really know which one is the "right" one to listen to.

So I did my best to reflect changes that are made outside the plugin to the screen, but sometimes its unfortunately wrong. I went with the conservative option for mute which is that if any of the sessions is unmuted, it will show as unmuted, because you might hear something. And I feel like if it shows as muted and it isn't muted, you could have worse problems than if it was the other way around. Luckily, if its showing the wrong thing, you can just click the button to mute from the plugin. But if this is a common pain point, I can look more into it and see about adding a setting so that the user can pick or something like that