How does my existing app change the master volume on Vista?

After I posted the "How do I set the master volume in Vista", DanT commented:

Thanks Larry.  I'll have to send a link to this to the people at Griffin so they can fix my PowerMate.  I loved this volume knob on XP.  On Vista it only changes the volume for itself which is somewhat less than useful.

It turns out that we expected that this would be a common issue for our customers, so we built a mechanism into Vista to allow legacy applications to control the hardware using the old mixer APIs (I hinted about this in my original volume posts, but at the time we'd not finalized our plans, so I couldn't comment any more about it).

On Vista, the mixer APIs detect if your application is running in XP compatibility mode, and if your application is running in XP mode, it disables the virtualized mixer and instead allows the application to directly interact with the hardware.


Now this won't work for all applications (the XP mixer used to lie about the capabilities of the hardware (for instance it would create a fake volume control for audio hardware that didn't have a hardware volume control (like my laptop)), the Vista mixer won't lie), but it can be used to get existing applications (like the PowerMate application listed above) working on Vista.

Comments (15)

  1. Anonymous says:

    How would I do the same if I wanted to control my app’s volume control.  Particularly if I’d like a UI element inside my app to reflect changes in Vista’s Mixer UI.

  2. Anonymous says:

    Sometimes I’m in awe at the lengths Microsoft goes to when maintaining compatibility for applications. From obscure things like fake stack construction for programs that like to grovel internals to pleasantly surprising things like this.

    I know first hand from my own development efforts that it usually not the easy route, especially in such a complex product like Windows. I think most of us customers who have had nasty experiences with application vendors that don’t "pay their taxes" (to borrow a phrase) would agree. Hats off.

  3. By default, the mixer APIs in Vista are per-application.  So if you don’t do anything, you’re controlling your per-application volume.

    This is for those relatively few control panel type applications that really MUST control the master volume

  4. Anonymous says:

    On a completely un-related note, how do you feel about being a Hagrid look-a-like 🙂

  5. Anonymous says:

    Excellent news, this means that the pesky Realplayer finally has met its foe.

    Windows Media Player, Winamp etc. are all good citizens on my XP, changing only their own volume and leaving the master volume as it is. Except for Realplayer. Slide the volume down, and it slides the master volume down. But with some luck not on Vista!

    Rgrds Henry

  6. Henry, apps like Real Player are exactly the reason we chose to shim the mixer APIs.

  7. Anonymous says:

    Is "XP compatibility mode" the application compatibility settings, or just the lack of the Vista aware manifest items?

    My apps sole use is to change the master volume (it docks to the side of my car PCs touchscreen)

  8. Anonymous says:

    The problem, of course, being that apparantly it’s now *easier* to mess up the entire system, and therefore RealPlayer will get code along the lines of this: if( UsingVista() ) messUpWithLessEffort(); else messUpWithLotsOfEffort();

    Either that or the RealPlayer authors were just not smart enough to realise there was a problem, and they’ll be happy that Vista protects them from themselves.

    What’s up with optimists?  Are they delusional, or just deficient?   🙂

  9. Dean, it’s the application compatibility settings – go to the exe, click "Compatibility", select For Windows XP.

  10. J. Edward Sanchez says:

    If you want to control the volume of your own app in Windows Vista, do you have to use the old mixer API (shudder)? Or is there a new and easier way to do it?

  11. J. Edward: There’s always waveOutSetVolume and waveOutGetVolume 🙂

    There’s also a new easier way, but it’s not that much easier, I’ll discuss that in a post soon (maybe tomorrow).

  12. Anonymous says:

    Will this XP compatibility mode allow me to somehow set the default playback device? On my Vista HTPC which I’ve had to resort to automating registry changes when I launch Media Center. I’d really like Media Center (and zoomplayer) to use my spdif connection automatically while other apps (ie IE7) should still use my computer speakers/headphones. I understand the Vista Audio Stack was built to support this, but the functionality was removed from the control panel in a RC release of Vista.

  13. Shawn, no, we’ve NEVER supported 3rd party apps changing the default playback device.

  14. Anonymous says:

    Ok I didn’t know that. My problem is that the concept of playback device changed from acutal physical device (ie soundblaster 16) to end point connection (ie speakers or spdif) now … correct? In XP i could use send audio to my spdif and headphone jack, but in Vista I have to choose one. Is there anyway to get this functionality back?

  15. Anonymous says:

    My problem is similar to Shawn’s.  My requirements are simple: Send the output from Windows Media Player to a USB device that broadcasts audio wirelessly, and send the output from everything else to the desktop speakers.  With XP, I had no problem with this.  With Vista, I have found no way to accomplish that.

Skip to main content