Search code examples
c#audiovolumewasapi

VolumeMixer Name Policy


After working with WASAPI i'm unable to understand what's the policy that uses sndvol32 (volume mixer) for show the name of the process.

Obviously "0" processId is System Sounds

Then, there are some hints i could obtain: - If you set a DisplayName in the AudioSession it uses the displayname. - If not, it uses the name of the window OR the FileDescription field of the exe.

I haven't be able to understand how chooses to use the name of the window OR the filedescription. For example, for Steam it uses "Steam Client Bootstrappeer" even when the Steam Window is open (which MainWindow Title is "Steam"). For spotify always uses the MainWindow Title field.

There are some other issues like: when is a system app (like screen keyboard) it uses the name set in the manifest file.

Is a mess, so inconsistent.

Anyone knows more precisely how does it do?

For more info I'm using my own custom wrapper in c# for all the COM interfaces family (similar to NAudio an others, but i wan't to build it myself to learn)


Solution

  • Finally i'll get a little bit satisfactory answer.

    SndVol32.exe (VolumeMixer) is kind of a mess. The basic work is:

    1. -If DisplayName is set in a random choosen session of the group (same grouping param) picks and shows DisplayName.
    2. -If not, it displays the mainwindowtitle and is listening to changes (with issues).
    3. -If there isn't a window (HWnd=0x0) it shows the ProductName of the MainModule file of the process.

    One more thing!

    This doesn't work for UWP Apps. For UWP Apps sndvol achieves to read the "DisplayName" of the Appxmanifest.xml of the App, even when is a resource reference (example <DisplayName>ms-resource:......</DisplayName>)

    One more thing!

    SndVol32 listen to MainWindowTitle changes (wineventhooks? winhooks? nevermind) BUT doesn't listen for windows minimized to tray or renormalized from tray events (example):

    • If you open your VolumeMixer window with Spotify open it will show the names of the songs (mainwindowtitle).
    • If you close to tray, it will show the name of the last song playing, but never changes again until you open again the window
    • If you play from stop from tray it will show only "Spotify" (Product Name).