2

I am implementing the callback methods from MMNotificationClient to get notified of audio device changes.

When I change the "spatial sound" settings for the Windows audio driver, then MMNotificationClient::OnPropertyValueChanged() gets called multiple times.

However, I am unsure how to interpret the PROPERTYKEY value that is supplied to this method in any meaningful way.

I can simply print the raw key data, e.g.

printf("  -->Changed device property "
              "{%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x}#%d\n",
              key.fmtid.Data1, key.fmtid.Data2, key.fmtid.Data3,
              key.fmtid.Data4[0], key.fmtid.Data4[1],
              key.fmtid.Data4[2], key.fmtid.Data4[3],
              key.fmtid.Data4[4], key.fmtid.Data4[5],
              key.fmtid.Data4[6], key.fmtid.Data4[7],
              key.pid);

This gives me output such as:

 -->Changed device property {1e94c58f-3e40-4ddb-b10c-a86d8b870a31}#2

But how do I get from this e.g. the name of a property that has changed?

The Microsoft Docs are very unclear on this.

j b
  • 5,147
  • 5
  • 41
  • 60
  • You shouldn't need to convert propertykeys to names at runtime. If your code doesn't recognize a property, it should just ignore it. – Raymond Chen Mar 27 '21 at 05:26
  • @RaymondChen Thanks but how do I find out what the keys actually correspond to? Is there a pre-defined list somewhere? For example if the user changes a spatial sound setting or "volume" how does my code recognise that property? – j b Mar 27 '21 at 10:06
  • Since anyone can define a property key, there is no central location that gathers all property keys. Some are in `mfplay.h`, some in `mfidl.h`, some in `mmdeviceapi.h`... In general, the documentation a feature should explain what property keys it uses. The specific one you show above does not appear to be documented. – Raymond Chen Mar 27 '21 at 14:37
  • In theory PSGetNameFromPropertyKey or PSGetPropertyDescription should work (I would expect this from a good OS if there is NO documentation about what properties to expect at all), unfortunately the functions don't help :( – dev_null May 09 '23 at 12:31
  • 1
    there is a good list in the bottom of the file of what it might be (the list is not full) https://github.com/mvaneerde/blog/blob/develop/audioendpoints/audioendpoints/stringify.cpp and it seems an initial author's blogpost https://matthewvaneerde.wordpress.com/2011/06/13/how-to-enumerate-audio-endpoint-immdevice-properties-on-your-system/ – dev_null May 09 '23 at 12:43

0 Answers0