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
This commit is contained in:
parent
37ef61586a
commit
c9faf0d612
@ -59,6 +59,7 @@ struct _GstMsdkContextPrivate
|
|||||||
GstMsdkContextJobType job_type;
|
GstMsdkContextJobType job_type;
|
||||||
gint shared_async_depth;
|
gint shared_async_depth;
|
||||||
GMutex mutex;
|
GMutex mutex;
|
||||||
|
GList *child_session_list;
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
gint fd;
|
gint fd;
|
||||||
VADisplay dpy;
|
VADisplay dpy;
|
||||||
@ -213,16 +214,29 @@ gst_msdk_context_init (GstMsdkContext * context)
|
|||||||
g_mutex_init (&priv->mutex);
|
g_mutex_init (&priv->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
gst_msdk_context_finalize (GObject * obj)
|
gst_msdk_context_finalize (GObject * obj)
|
||||||
{
|
{
|
||||||
GstMsdkContext *context = GST_MSDK_CONTEXT_CAST (obj);
|
GstMsdkContext *context = GST_MSDK_CONTEXT_CAST (obj);
|
||||||
GstMsdkContextPrivate *priv = context->priv;
|
GstMsdkContextPrivate *priv = context->priv;
|
||||||
|
|
||||||
if (priv->is_joined) {
|
/* child sessions will be closed when the parent session is closed */
|
||||||
MFXDisjoinSession (priv->session);
|
if (priv->is_joined)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
else
|
||||||
|
g_list_free_full (priv->child_session_list, release_child_session);
|
||||||
|
|
||||||
msdk_close_session (priv->session);
|
msdk_close_session (priv->session);
|
||||||
g_mutex_clear (&priv->mutex);
|
g_mutex_clear (&priv->mutex);
|
||||||
@ -284,6 +298,8 @@ gst_msdk_context_new_with_parent (GstMsdkContext * parent)
|
|||||||
priv->is_joined = TRUE;
|
priv->is_joined = TRUE;
|
||||||
priv->hardware = parent_priv->hardware;
|
priv->hardware = parent_priv->hardware;
|
||||||
priv->job_type = parent_priv->job_type;
|
priv->job_type = parent_priv->job_type;
|
||||||
|
parent_priv->child_session_list =
|
||||||
|
g_list_prepend (parent_priv->child_session_list, priv->session);
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
priv->dpy = parent_priv->dpy;
|
priv->dpy = parent_priv->dpy;
|
||||||
priv->fd = parent_priv->fd;
|
priv->fd = parent_priv->fd;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user