媒体基金会:另一种调用 IMFActivate::ShutdownObject 的方法?

发布于 2024-08-04 19:01:30 字数 867 浏览 1 评论 0原文

这是关于 Media Foundation 中的 IMFActivate::ActivateObjectIMFActivate::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 技术交流群。

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

发布评论

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

评论(1

抚你发端 2024-08-11 19:01:30

当您使用完激活的对象后,您应该调用 IMFActivate::ShutdownObject ,这是对的。但是,请注意,相关示例正在实例化要在输出参数中返回的 IMFMediaSource。

HRESULT CreateVideoDeviceSource(IMFMediaSource **ppSource)

如果 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.

HRESULT CreateVideoDeviceSource(IMFMediaSource **ppSource)

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文