From 6c887f982e94d503abbed0efb30e65342e1dcb3a Mon Sep 17 00:00:00 2001 From: Haihao Xiang Date: Wed, 9 Jan 2019 12:19:50 +0800 Subject: [PATCH] msdk: check whether mfx function call fails And log the failures for debugging --- sys/msdk/gstmsdkcontext.c | 8 ++++++++ sys/msdk/gstmsdkenc.c | 13 ++++++++++--- sys/msdk/gstmsdkvpp.c | 6 ++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/sys/msdk/gstmsdkcontext.c b/sys/msdk/gstmsdkcontext.c index f1615ad603..6ff36ef2b9 100644 --- a/sys/msdk/gstmsdkcontext.c +++ b/sys/msdk/gstmsdkcontext.c @@ -307,6 +307,14 @@ gst_msdk_context_new_with_parent (GstMsdkContext * parent) if (priv->hardware) { status = MFXVideoCORE_SetHandle (priv->session, MFX_HANDLE_VA_DISPLAY, (mfxHDL) parent_priv->dpy); + + if (status != MFX_ERR_NONE) { + GST_ERROR ("Setting VA handle failed (%s)", + msdk_status_to_string (status)); + g_object_unref (obj); + return NULL; + } + } #endif diff --git a/sys/msdk/gstmsdkenc.c b/sys/msdk/gstmsdkenc.c index 51899047fd..33f23845d9 100644 --- a/sys/msdk/gstmsdkenc.c +++ b/sys/msdk/gstmsdkenc.c @@ -351,9 +351,14 @@ gst_msdkenc_init_encoder (GstMsdkEnc * thiz) status = MFXVideoVPP_GetVideoParam (session, &thiz->vpp_param); if (status < MFX_ERR_NONE) { + mfxStatus status1; GST_ERROR_OBJECT (thiz, "Get VPP Parameters failed (%s)", msdk_status_to_string (status)); - MFXVideoVPP_Close (session); + status1 = MFXVideoVPP_Close (session); + if (status1 != MFX_ERR_NONE && status1 != MFX_ERR_NOT_INITIALIZED) + GST_WARNING_OBJECT (thiz, "VPP close failed (%s)", + msdk_status_to_string (status1)); + goto no_vpp; } else if (status > MFX_ERR_NONE) { GST_WARNING_OBJECT (thiz, "Get VPP Parameters returned: %s", @@ -689,8 +694,10 @@ gst_msdkenc_finish_frame (GstMsdkEnc * thiz, MsdkEncTask * task, * is used in MSDK samples * #define MSDK_ENC_WAIT_INTERVAL 300000 */ - MFXVideoCORE_SyncOperation (gst_msdk_context_get_session (thiz->context), - task->sync_point, 300000); + if (MFXVideoCORE_SyncOperation (gst_msdk_context_get_session (thiz->context), + task->sync_point, 300000) != MFX_ERR_NONE) + GST_WARNING_OBJECT (thiz, "failed to do sync operation"); + if (!discard && task->output_bitstream.DataLength) { GstBuffer *out_buf = NULL; guint8 *data = diff --git a/sys/msdk/gstmsdkvpp.c b/sys/msdk/gstmsdkvpp.c index 027037bd18..a6a9f0415b 100644 --- a/sys/msdk/gstmsdkvpp.c +++ b/sys/msdk/gstmsdkvpp.c @@ -701,8 +701,10 @@ gst_msdkvpp_transform (GstBaseTransform * trans, GstBuffer * inbuf, * is used in MSDK samples * #define MSDK_VPP_WAIT_INTERVAL 300000 */ - if (sync_point) - MFXVideoCORE_SyncOperation (session, sync_point, 300000); + if (sync_point && + MFXVideoCORE_SyncOperation (session, sync_point, + 300000) != MFX_ERR_NONE) + GST_WARNING_OBJECT (thiz, "failed to do sync operation"); /* More than one output buffers are generated */ if (status == MFX_ERR_MORE_SURFACE) {