msdk: sink context reference

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6398>
This commit is contained in:
Víctor Manuel Jáquez Leal 2024-04-02 18:18:14 +02:00 committed by GStreamer Marge Bot
parent c83b69d146
commit 3b4b979ec4

View file

@ -412,6 +412,7 @@ GstMsdkContext *
gst_msdk_context_new (gboolean hardware)
{
GstMsdkContext *obj = g_object_new (GST_TYPE_MSDK_CONTEXT, NULL);
gst_object_ref_sink (obj);
if (obj && !gst_msdk_context_open (obj, hardware)) {
gst_object_unref (obj);
@ -437,15 +438,18 @@ GstMsdkContext *
gst_msdk_context_new_with_parent (GstMsdkContext * parent)
{
mfxStatus status;
GstMsdkContext *obj = g_object_new (GST_TYPE_MSDK_CONTEXT, NULL);
GstMsdkContextPrivate *priv = obj->priv;
GstMsdkContextPrivate *parent_priv = parent->priv;
GstMsdkContext *obj;
GstMsdkContextPrivate *priv;
GstMsdkContextPrivate *parent_priv;
mfxVersion version;
mfxIMPL impl;
MsdkSession child_msdk_session;
mfxHandleType handle_type = 0;
mfxHDL handle = NULL, hardware_handle = NULL;
g_return_val_if_fail (GST_IS_MSDK_CONTEXT (parent), NULL);
parent_priv = parent->priv;
status = MFXQueryIMPL (parent_priv->session.session, &impl);
if (status == MFX_ERR_NONE)
@ -454,7 +458,6 @@ gst_msdk_context_new_with_parent (GstMsdkContext * parent)
if (status != MFX_ERR_NONE) {
GST_ERROR ("Failed to query the session attributes (%s)",
msdk_status_to_string (status));
gst_object_unref (obj);
return NULL;
}
@ -471,7 +474,6 @@ gst_msdk_context_new_with_parent (GstMsdkContext * parent)
if (status != MFX_ERR_NONE || !handle) {
GST_ERROR ("Failed to get session handle (%s)",
msdk_status_to_string (status));
gst_object_unref (obj);
return NULL;
}
}
@ -488,7 +490,6 @@ gst_msdk_context_new_with_parent (GstMsdkContext * parent)
if (status != MFX_ERR_NONE) {
GST_ERROR ("Failed to create a child mfx session (%s)",
msdk_status_to_string (status));
gst_object_unref (obj);
return NULL;
}
@ -501,7 +502,6 @@ gst_msdk_context_new_with_parent (GstMsdkContext * parent)
GST_ERROR ("Failed to set a HW handle (%s)",
msdk_status_to_string (status));
MFXClose (child_msdk_session.session);
gst_object_unref (obj);
return NULL;
}
}
@ -513,11 +513,14 @@ gst_msdk_context_new_with_parent (GstMsdkContext * parent)
GST_ERROR ("Failed to join two sessions (%s)",
msdk_status_to_string (status));
MFXClose (child_msdk_session.session);
gst_object_unref (obj);
return NULL;
}
#endif
obj = g_object_new (GST_TYPE_MSDK_CONTEXT, NULL);
gst_object_ref_sink (obj);
priv = obj->priv;
/* Set loader to NULL for child session */
priv->session.loader = NULL;
priv->session.session = child_msdk_session.session;
@ -553,6 +556,7 @@ gst_msdk_context_new_with_va_display (GstObject * display_obj,
return NULL;
obj = g_object_new (GST_TYPE_MSDK_CONTEXT, NULL);
gst_object_ref_sink (obj);
priv = obj->priv;
priv->display = gst_object_ref (va_display);
@ -603,6 +607,7 @@ gst_msdk_context_new_with_d3d11_device (GstD3D11Device * device,
HRESULT hr;
obj = g_object_new (GST_TYPE_MSDK_CONTEXT, NULL);
gst_object_ref_sink (obj);
priv = obj->priv;
priv->device = gst_object_ref (device);