diff options
author | Seungha Yang <seungha@centricular.com> | 2020-08-13 02:24:52 +0900 |
---|---|---|
committer | GStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2020-08-13 07:05:36 +0000 |
commit | 5ffd2c64a0cca7b55e280d61d225e45858bc4aa0 (patch) | |
tree | 5aa1393881f36e11e108b6109d3df63c930ee9e2 | |
parent | 9123b9ba3992d7f9cb8ccec4171e24c68ad6becd (diff) |
mediafoundation: Call MFShutdown when destroying plugin
MFStartup and MFShutdown should be paired as documented in
https://docs.microsoft.com/en-us/windows/win32/api/mfapi/nf-mfapi-mfstartup#remarks
Otherwise valgrind-like tools would report false positive memory leak.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1512>
-rw-r--r-- | sys/mediafoundation/plugin.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/sys/mediafoundation/plugin.c b/sys/mediafoundation/plugin.c index 509b15fad..923f5b03e 100644 --- a/sys/mediafoundation/plugin.c +++ b/sys/mediafoundation/plugin.c @@ -43,6 +43,12 @@ GST_DEBUG_CATEGORY (gst_mf_transform_debug); #define GST_CAT_DEFAULT gst_mf_debug +static void +plugin_deinit (gpointer data) +{ + MFShutdown (); +} + static gboolean plugin_init (GstPlugin * plugin) { @@ -85,6 +91,17 @@ plugin_init (GstPlugin * plugin) gst_mf_aac_enc_plugin_init (plugin, GST_RANK_SECONDARY); gst_mf_mp3_enc_plugin_init (plugin, GST_RANK_SECONDARY); + /* So that call MFShutdown() when this plugin is no more used + * (i.e., gst_deinit). Otherwise valgrind-like tools would complain + * about un-released media foundation resources. + * + * NOTE: MFStartup and MFShutdown can be called multiple times, but the number + * of each MFStartup and MFShutdown call should be identical. This rule is + * simliar to that of CoInitialize/CoUninitialize pair */ + g_object_set_data_full (G_OBJECT (plugin), + "plugin-mediafoundation-shutdown", "shutdown-data", + (GDestroyNotify) plugin_deinit); + return TRUE; } |