媒体基金会:另一种调用 IMFActivate::ShutdownObject 的方法?
这是关于 Media Foundation 中的 IMFActivate::ActivateObject
和 IMFActivate::ShutdownObject
的问题。
根据MSDN,调用ActivateObject
的组件负责调用ShutdownObject
。
但有两个示例不遵循此规则:
http: //msdn.microsoft.com/en-us/library/dd388503%28VS.85%29.aspx
和
http://msdn.microsoft.com/en-us/library/dd317912%28VS.85%29.aspx
在这两个示例中,他们调用ActivateObject
,然后释放IMFActivate
接口,而不调用ShutdownObject
方法。
这会导致内存泄漏,对吧?或者还有其他方法来释放对象占用的资源?
(我可以使用 IMFMediaSource::Shutdown
来释放对象,而不是使用 IMFActivate::ShutdownObject
)
提前致谢。
Here is a question about IMFActivate::ActivateObject
and IMFActivate::ShutdownObject
in Media Foundation.
According to MSDN, the component that calls ActivateObject
is responsible for calling ShutdownObject
.
But there are two examples not following this rule:
http://msdn.microsoft.com/en-us/library/dd388503%28VS.85%29.aspx
and
http://msdn.microsoft.com/en-us/library/dd317912%28VS.85%29.aspx
In these two examples, they call ActivateObject
and then release IMFActivate
interface without calling ShutdownObject
method.
This is going to lead to memory leaking, right? Or there is another way to release the resource occupied by the object?
(Can I use IMFMediaSource::Shutdown
to release the object instead of using IMFActivate::ShutdownObject
)
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您使用完激活的对象后,您应该调用
IMFActivate::ShutdownObject
,这是对的。但是,请注意,相关示例正在实例化要在输出参数中返回的 IMFMediaSource。如果 CreateVideoDeviceSource 在它实例化的 IMFMediaSource 上执行 ShutdownObject,然后将其交还给您,则它将处于关闭状态,因此可能无法使用。
要回答您应该对此做什么的问题,您可能可以在使用完之后使用
pMyMediaSource->Shutdown()
。更多信息:IMFActivate 在 Media Foundation 中的其他用途是允许在不同的进程中实例化 MF 对象(很有用,因为 MF Media Session 将在单独的进程中播放受 DRM 保护的内容);在这种情况下,MF 媒体会话确实会在您提供的任何 IMFActivates 上调用
IMFActivate::ShutdownObject
。You're right that you're supposed to call
IMFActivate::ShutdownObject
when you're done using the object you activated. However, notice that the sample in question is instantiating an IMFMediaSource to be returned in an out param.If CreateVideoDeviceSource were to do a ShutdownObject on the IMFMediaSource it instantiated and then hand it back to you, it would be in a shut-down state and therefore probably unusable.
To answer your question about what you're supposed to do about this, you can probably get away with a
pMyMediaSource->Shutdown()
after you're all done using it.More info: IMFActivate's other use in Media Foundation is for allowing an MF object to be instantiated in a different process (useful because the MF Media Session will play DRM-protected content in a separate process); in that case, the MF Media Session will indeed call
IMFActivate::ShutdownObject
on any IMFActivates you gave it.