summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunjun Ko <zzoon@igalia.com>2018-03-08 11:38:30 -0900
committerSreerenj Balachandran <sreerenj.balachandran@intel.com>2018-03-08 11:38:30 -0900
commitc9faf0d612d7e73fbca16f1c227b181d851c5ae9 (patch)
tree30a5e2aceaafc42e2a5e979ccee909aabc0b1505
parent37ef61586adaa295902515d69fca0f30b0e7ecaa (diff)
msdk: manage child sessions on parent GstMsdkContext
Sometimes parent context is released before its children get released. In this case MFXClose of parent session fails. To make sure that child sessions are closed before closing a parent session, Parent context needs to manage child sessions and close them first when it's released. https://bugzilla.gnome.org/show_bug.cgi?id=793412
-rw-r--r--sys/msdk/gstmsdkcontext.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/sys/msdk/gstmsdkcontext.c b/sys/msdk/gstmsdkcontext.c
index 352148f87..44474743b 100644
--- a/sys/msdk/gstmsdkcontext.c
+++ b/sys/msdk/gstmsdkcontext.c
@@ -59,6 +59,7 @@ struct _GstMsdkContextPrivate
GstMsdkContextJobType job_type;
gint shared_async_depth;
GMutex mutex;
+ GList *child_session_list;
#ifndef _WIN32
gint fd;
VADisplay dpy;
@@ -214,15 +215,28 @@ gst_msdk_context_init (GstMsdkContext * context)
}
static void
+release_child_session (gpointer session)
+{
+ mfxStatus status;
+
+ mfxSession _session = session;
+ status = MFXDisjoinSession (_session);
+ if (status != MFX_ERR_NONE)
+ GST_WARNING ("failed to disjoin (%s)", msdk_status_to_string (status));
+ msdk_close_session (_session);
+}
+
+static void
gst_msdk_context_finalize (GObject * obj)
{
GstMsdkContext *context = GST_MSDK_CONTEXT_CAST (obj);
GstMsdkContextPrivate *priv = context->priv;
- if (priv->is_joined) {
- MFXDisjoinSession (priv->session);
+ /* child sessions will be closed when the parent session is closed */
+ if (priv->is_joined)
goto done;
- }
+ else
+ g_list_free_full (priv->child_session_list, release_child_session);
msdk_close_session (priv->session);
g_mutex_clear (&priv->mutex);
@@ -284,6 +298,8 @@ gst_msdk_context_new_with_parent (GstMsdkContext * parent)
priv->is_joined = TRUE;
priv->hardware = parent_priv->hardware;
priv->job_type = parent_priv->job_type;
+ parent_priv->child_session_list =
+ g_list_prepend (parent_priv->child_session_list, priv->session);
#ifndef _WIN32
priv->dpy = parent_priv->dpy;
priv->fd = parent_priv->fd;