我正在尝试使用 Windows 音频会话 API 在当前音频会话的枚举中查找默认音频会话。目前我有一个对 IAudioSessionControl 的引用
rel="nofollow">eConsole
角色以及 IAudioSessionEnumerator
对象,枚举此默认终结点的音频会话,但我需要能够比较 IAudioSessionControl 对象与 IAudioSessionEnumerator::GetSession
。
我希望可以通过比较 IAudioSessionControl 指针的相等性来测试相等性。当我使用 IAudioClient::GetService
。不幸的是,IAudioClient::GetService
返回的这个指针没有出现在 IAudioSessionEnumerator
的音频会话枚举中。此外,通过 多次获取默认音频会话即使使用相同的音频会话 GUID (GUID_NULL
) 和 IAudioSessionManager::GetAudioSessionControl
路由也不会产生相同的 IAudioSessionControl
指针>CrossProcessSession 值。
如何测试给定两个 IAudioSessionControl 指针的音频会话的相等性?是否可以获取给定 IAudioSessionControl 对象的音频会话 GUID 和进程标识符?
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?
发布评论
评论(2)
查看 IAudioSessionControl2::GetSessionIdentifier API,这就是音频子系统用来保存会话音量的方法。如果要在运行时区分会话(同一应用程序的两个实例同时运行),请检查 GetSessionInstanceIdentifier API。
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.
COM 在这里唯一可以帮助您的是对象身份要求。
您从两个对象中查询
IUnknown*
并比较它们。如果这些对象的 IUnknown* 相同,则它们是同一对象,否则它们是不同的对象。当然,实现可能会违反对象标识要求,或者这些不同的对象可能以某种方式映射到同一内部对象。 COM 在这里无法帮助您 - 您必须查找特定于该组件实现的信息。
The only thing COM can help you with here is object identity requirement.
You query
IUnknown*
from both objects and compare them. IfIUnknown*
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.