mediafoundation: Fix resource leak

IMFActivate would hold its internal objects unless user call ShutdownObject(),
even if we release the IMFActivate. Here internal objects may
include Direct3D objects, such as texture, device handle for example.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2087>
This commit is contained in:
Seungha Yang 2021-03-16 17:56:51 +09:00 committed by GStreamer Marge Bot
parent 58e451325b
commit 1d6cdbdc90
2 changed files with 14 additions and 0 deletions

View file

@ -74,6 +74,7 @@ struct _GstMFSourceReader
/* protected by lock */
GstQueueArray *queue;
IMFActivate *activate;
IMFMediaSource *source;
IMFSourceReader *reader;
@ -307,6 +308,8 @@ gst_mf_source_reader_open (GstMFSourceReader * self, IMFActivate * activate)
return FALSE;
}
self->activate = activate;
activate->AddRef ();
self->source = source.Detach ();
self->reader = reader.Detach ();
@ -332,6 +335,12 @@ gst_mf_source_reader_close (GstMFSourceReader * self)
{
gst_clear_caps (&self->supported_caps);
if (self->activate) {
self->activate->ShutdownObject ();
self->activate->Release ();
self->activate = NULL;
}
if (self->media_types) {
g_list_free_full (self->media_types,
(GDestroyNotify) gst_mf_stream_media_type_free);

View file

@ -1040,6 +1040,11 @@ gst_mf_transform_close (GstMFTransform * object)
gst_mf_transform_flush (object);
/* Otherwise IMFTransform will be alive even after we release the IMFTransform
* below */
if (object->activate)
object->activate->ShutdownObject ();
if (object->callback_object) {
object->callback_object->Release ();
object->callback_object = nullptr;