[英]Changing audio renderer endpoint while playing
I'm writing an audio player using Microsoft Media Foundation.我正在使用 Microsoft Media Foundation 编写音频播放器。 I wonder is it possible to change the playback device without re-creating the session?
我想知道是否可以在不重新创建会话的情况下更改播放设备?
IMFActivate *m_p_sink_activate;
...
m_p_sink_activate->SetString(MF_AUDIO_RENDERER_ATTRIBUTE_ENDPOINT_ID, name_device);
This doesn't take effect if the audio is already being played.如果音频已经在播放,这不会生效。
Btw, the media player provided by Microsoft.Windows.SDK.Contracts (Windows.Media.Playback.MediaPlayer) does it perfectly.顺便说一句,Microsoft.Windows.SDK.Contracts (Windows.Media.Playback.MediaPlayer) 提供的媒体播放器做得很完美。 When I change m_mediaPlayer.AudioDevice, the audio stream is redirected to the assigned device immediately.
当我更改 m_mediaPlayer.AudioDevice 时,音频流会立即重定向到指定的设备。 So I wonder if this is also possible for MSMF.
所以我想知道这是否也适用于 MSMF。
So far I have a way could do this job,到目前为止,我有办法完成这项工作,
You could refer to MS sample TopoEdit for detail.您可以参考 MS 示例 TopoEdit 了解详细信息。
One side effect is that each time SetTopology cause huge memory growth.一个副作用是每次 SetTopology 都会导致巨大的内存增长。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.