如何获得正确的设备符号链接到音频捕获设备? [英] How to get correct device symbolic link to audio capture device?

查看:144
本文介绍了如何获得正确的设备符号链接到音频捕获设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

推荐答案

您好Artyom

Hi Artyom

因为您使用的是MF_DEVSOURCE属性  ;我假设您正在创建"设备来源"使用
MFCreateDeviceSource

Since you are using MF_DEVSOURCE attributes i assume that you are creating "Device Sources" by using MFCreateDeviceSource ?

为什么要尝试获取音频设备的符号链接?

Why are you trying to get the symbolic link of an audio device ?

您是否在Media Foundation之外的其他API中创建设备?

Are you creating devices in other API's outside of Media Foundation ?

通常的方法是完全按照
MFCreateDeviceSource
doc。对于 视频设备来源 使用符号链接 并创建音频设备来源使用端点ID。因此,要创建音频设备来源,请使用以下两个属性:

The normal way would be to create Device Sources exactly as described in the MFCreateDeviceSource doc. For Video Device Sources use the symbolic link and to create Audio Device Sources use the endpoint ID. So to create a Audio Device Source use these 2 attributes :

MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE

MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE

MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_ENDPOINT_ID

MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_AUDCAP_ENDPOINT_ID

对于" Stream Routing " (以及 所以听设备
和会话更改) 您需要注册  IMMNotificationClient &
IAudioSessionControl 回调。如果你不想
实现一些复杂的Stream Routing并且只想听硬件设备更改(例如总是拥有当前默认设备的友好名称)那么这就足够了:

For "Stream Routing" ( and so listen to device and session changes ) you need to register an IMMNotificationClient and a IAudioSessionControl callback. If you dont want to implement some complicated Stream Routing and just want to listen to hardware device changes ( for example to always have the friendly name of a current default device ) then this is enough :

1。创建IMMDeviceEnumerator。

1. Create IMMDeviceEnumerator.

2。从类别中枚举设备或致电 GetDefaultEndpoint 以获取默认的渲染/捕获设备。

2. Enumerate the devices from a category or call GetDefaultEndpoint to get the default render/capture device.

3. 在端点设备上调用 GetId

3. Call GetId on the endpoint device.

4. :使用 MFCreateDeviceSource

5创建设备来源。 成功创建源后,请在设备枚举器上调用 RegisterEndpointNotificationCallback

5. When the source was created successfully call RegisterEndpointNotificationCallback on the Device Enumerator.

6。收听所有音频系统中的设备更改。

6. Listen to all the audio device changes in the system.

如果编写自定义媒体源,则必须同时实现回调接口,IMMNotificationClient和IAudio SessionControl。但这比仅仅听取名称更改更难。它涉及大量编码。如果你计划实施Stream
路由坚持这两条主要规则:

If you write a custom Media Source you have to implement both callback interfaces, IMMNotificationClient and IAudioSessionControl. But this is way harder than just listening to name changes. It involves a lot of coding. If you plan to implement Stream Routing stick to these 2 main rules :

-
IMMNotificationClient
用于监听系统范围的硬件设备更改。

- Implementation and registration of IMMNotificationClient is to listen to system wide hardware device changes.

-
IAudioSessionControl 用于收听会话更改(由您开通的流)

- Implementation and registration of IAudioSessionControl is to listen to session changes ( streams opened by you )

来自IAudioSessionControl的事件通常会在您获得系统范围的硬件更改之前发生,但不一定是这样。如果你想进行自动流路由,你必须实现两个回调。

The Events from IAudioSessionControl normaly occur slightly before you get system wide hardware changes, but its not necessarily that way. If you want to do automatic Stream Routing you have to implement both callbacks.

Normaly来源 MFCreateDeviceSource 正在自己这样做。您不需要收听设备或流式更改。只有当您编写自己的自定义
媒体资源或者您希望拥有当前默认设置的友好名称时,才需要这样做。\\ n / nbsp;设备。

Normaly sources created by MFCreateDeviceSource are doing this by themself. You dont need to listen to device or stream changes. It is only necessary if you write your own Custom Media Source or if you want to have the friendly name of a current default device.

如果你想要渲染/捕获默认设备的友好名称,只需注册一个IMMNotificationClient回调,就像我从第1-6点所描述的那样。

If you want the friendly name for the render/capture default device just register an IMMNotificationClient callback like i described from point 1-6.

使用MSDN指南:

https://msdn.microsoft.com/de-de/library/windows/desktop/dd756610(v = vs.85).aspx

https://msdn.microsoft.com /de-de/library/windows/desktop/dd756609(v=vs.85).aspx

https://msdn.microsoft.com/de-de/library/windows/desktop/dd756611(v=vs.85 )的.asp x

敬请问,

Francis


这篇关于如何获得正确的设备符号链接到音频捕获设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆