如何唯一识别 DirectShow 音频渲染器过滤器?

发布于 2024-11-18 01:07:55 字数 63 浏览 1 评论 0原文

正如我刚刚发现的那样,友好的名称并不能保证是唯一的。如果我可以从该标识符实例化过滤器而无需枚举它们,那就加分了。

As I just found out the hard way, friendly names are not guaranteed to be unique. Bonus points if I can instantiate the filter from that identifier without having to enumerate them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

避讳 2024-11-25 01:07:55

包装 WaveOut 设备的渲染器过滤器可以通过 WaveOutId 来识别。那些包装的 DirectSound 设备可以通过 DSGuid 来识别。

ICreateDevEnum* devices;
if (CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (LPVOID*)&devices) == S_OK)
{
    IEnumMoniker* enumerator;
    if (devices->CreateClassEnumerator(CLSID_AudioRendererCategory, &enumerator, 0) == S_OK)
    {
        IMoniker* moniker;
        while (enumerator->Next(1, &moniker, NULL) == S_OK)
        {
            IPropertyBag* properties;
            if (moniker->BindToStorage(NULL, NULL, IID_IPropertyBag, (void**)&properties) == S_OK)
            {
                VARIANT variant;
                VariantInit(&variant);
                if (properties->Read(L"WaveOutId", &variant, NULL) == S_OK)
                {
                    // variant.lVal now contains the id of the wrapped WaveOut device.
                }
                else if (properties->Read(L"DSGuid", &variant, NULL) == S_OK)
                {
                    // variant.bstrVal now contains an uppercase GUID.
                    // It's the same GUID you would get from DirectSoundEnumerate.
                }
                VariantClear(&variant);
                properties->Release();
            }
            moniker->Release();
        }
        enumerator->Release();
    }
    devices->Release();
}

Renderer filters wrapping WaveOut devices can be identified by WaveOutId. Those wrapping DirectSound devices can be identified by DSGuid.

ICreateDevEnum* devices;
if (CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (LPVOID*)&devices) == S_OK)
{
    IEnumMoniker* enumerator;
    if (devices->CreateClassEnumerator(CLSID_AudioRendererCategory, &enumerator, 0) == S_OK)
    {
        IMoniker* moniker;
        while (enumerator->Next(1, &moniker, NULL) == S_OK)
        {
            IPropertyBag* properties;
            if (moniker->BindToStorage(NULL, NULL, IID_IPropertyBag, (void**)&properties) == S_OK)
            {
                VARIANT variant;
                VariantInit(&variant);
                if (properties->Read(L"WaveOutId", &variant, NULL) == S_OK)
                {
                    // variant.lVal now contains the id of the wrapped WaveOut device.
                }
                else if (properties->Read(L"DSGuid", &variant, NULL) == S_OK)
                {
                    // variant.bstrVal now contains an uppercase GUID.
                    // It's the same GUID you would get from DirectSoundEnumerate.
                }
                VariantClear(&variant);
                properties->Release();
            }
            moniker->Release();
        }
        enumerator->Release();
    }
    devices->Release();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文