3

I currently have this code, iterating over the audio session controls of the default device (not shown):

int sessionCount;
hr = audioSessionEnumerator->GetCount(&sessionCount);
if (FAILED(hr)) {
    throw HRESULTException("audioSessionEnumerator->GetCount", hr);
}

IAudioSessionControl *audioSessionControl;
for (int i = 0; i < sessionCount; ++i) {
    hr = audioSessionEnumerator->GetSession(i, &audioSessionControl);
    if (FAILED(hr)) {
        throw HRESULTException("audioSessionEnumerator->GetSession", hr);
    }

    LPWSTR displayName;
    hr = audioSessionControl->GetDisplayName(&displayName);
    if (FAILED(hr)) {
        throw HRESULTException("audioSessionControl->GetDisplayName", hr);
    }

    std::wcout << displayName << std::endl;

    CoTaskMemFree(displayName);

    audioSessionControl->Release();
}

audioSessionEnumerator->Release();

My mixer currently looks like this: Mixer

The expected output is:

Steam Client Bootstrapper
melodysheep - The Face of Creation
System Sounds

However, the output seen is:

(blank line)
(blank line)
@%SystemRoot%\System32\AudioSrv.Dll,-202

Output

Which is the same as the output when GetDisplayName is replaced with GetIconPath.

What problem occurs in the code above to cause this issue? If more code must be shown, please inform me.

the6p4c
  • 644
  • 5
  • 17

1 Answers1

6

If you read the remarks for both GetDisplayName and GetIconName in MSDN you'll see that the functions can return NULL if no-one has set them. The GetIconName page also then remarks that the sndvol application (which you've got a screenshot of) will actually look up the icon of the main window if it's NULL, and therefore by induction will lookup the main window title for the display name if it doesn't exist.

You probably want to query for the IAudioSessionControl2 interface which has a GetProcessId method which might return you the client process id. At which point you can use things like this and this to try and extract the values from the main window to be consistent.

Community
  • 1
  • 1
tyranid
  • 13,028
  • 1
  • 32
  • 34