Commit 3110f379 authored by Haihao Xiang's avatar Haihao Xiang Committed by Víctor Manuel Jáquez Leal

msdk: don't reset the external frame allocator

In gst-msdk, a mfx session may be shared between different gst
elements, each element tries to set the frame allocator. However, per
the MSDK documation[1], the behavior is undefined if reset the frame
allocator while the previous allocator is in use. Fortunately all
elements use the same frame allocator, so we can avoid to call
MFXVideoCORE_SetFrameAllocator again.

[1]: https://software.intel.com/en-us/node/628430#MFXVideoCORE3
parent a0943aec
Pipeline #14295 passed with stages
in 39 minutes and 15 seconds
......@@ -75,6 +75,5 @@ gst_msdk_set_frame_allocator (GstMsdkContext * context)
.Free = gst_msdk_frame_free,
};
MFXVideoCORE_SetFrameAllocator (gst_msdk_context_get_session (context),
&gst_msdk_frame_allocator);
gst_msdk_context_set_frame_allocator (context, &gst_msdk_frame_allocator);
}
......@@ -366,8 +366,7 @@ gst_msdk_set_frame_allocator (GstMsdkContext * context)
.Free = gst_msdk_frame_free,
};
MFXVideoCORE_SetFrameAllocator (gst_msdk_context_get_session (context),
&gst_msdk_frame_allocator);
gst_msdk_context_set_frame_allocator (context, &gst_msdk_frame_allocator);
}
gboolean
......
......@@ -47,6 +47,7 @@ struct _GstMsdkContextPrivate
GList *cached_alloc_responses;
gboolean hardware;
gboolean is_joined;
gboolean has_frame_allocator;
GstMsdkContextJobType job_type;
gint shared_async_depth;
GMutex mutex;
......@@ -597,3 +598,25 @@ gst_msdk_context_add_shared_async_depth (GstMsdkContext * context,
{
context->priv->shared_async_depth += async_depth;
}
void
gst_msdk_context_set_frame_allocator (GstMsdkContext * context,
mfxFrameAllocator * allocator)
{
GstMsdkContextPrivate *priv = context->priv;
g_mutex_lock (&priv->mutex);
if (!priv->has_frame_allocator) {
mfxStatus status;
status = MFXVideoCORE_SetFrameAllocator (priv->session, allocator);
if (status != MFX_ERR_NONE)
GST_ERROR ("Failed to set frame allocator");
else
priv->has_frame_allocator = 1;
}
g_mutex_unlock (&priv->mutex);
}
......@@ -142,6 +142,10 @@ gst_msdk_context_get_shared_async_depth (GstMsdkContext * context);
void
gst_msdk_context_add_shared_async_depth (GstMsdkContext * context, gint async_depth);
void
gst_msdk_context_set_frame_allocator (GstMsdkContext * context,
mfxFrameAllocator * allocator);
G_END_DECLS
#endif /* GST_MSDK_CONTEXT_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment