Question

I am trying to use the Windows Audio Session API to locate the default audio session within the enumeration of current audio sessions. Currently I have a reference to the IAudioSessionControl of the default session of the audio render endpoint in the eConsole role as well as an IAudioSessionEnumerator object that enumerates the audio sessions of this default endpoint, but I need to be able to compare the IAudioSessionControl object that I have for equality with the IAudioSessionControl objects returned by IAudioSessionEnumerator::GetSession.

I was hoping that I could test for equality by comparing the IAudioSessionControl pointers for equality. This works when I obtain the IAudioSessionControl for the default session multiple times using IAudioClient::GetService. Unfortunately, this pointer returned by IAudioClient::GetService does not appear in the enumeration of audio sessions by the IAudioSessionEnumerator. Also, obtaining the default audio session multiple times via the IAudioSessionManager::GetAudioSessionControl route does not yield identical IAudioSessionControl pointers even when using the same audio session GUID (GUID_NULL) and CrossProcessSession value.

How do I test for equality of audio sessions given two IAudioSessionControl pointers? Is it possible to obtain the audio session GUID and process identifier of a given IAudioSessionControl object?

Was it helpful?

Solution

Look at the IAudioSessionControl2::GetSessionIdentifier API, that's what the audio subsystem uses to persist session volumes. If you want to distinguish sessions at runtime (two instances of the same app running at the same time), check the GetSessionInstanceIdentifier API.

OTHER TIPS

The only thing COM can help you with here is object identity requirement.

You query IUnknown* from both objects and compare them. If IUnknown* of those objects is the same it's the same object, otherwise those are distinct objects.

Of course the implementation could violate the object identity requirement or those distinct objects might somehow map onto the same internal object. COM can't help you here - you have to find information specific to that component implementation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top