From 8105d2044d74806f3b8dc921e9ab841bc2757c40 Mon Sep 17 00:00:00 2001 From: Tong Wu Date: Thu, 24 Nov 2022 11:00:15 +0800 Subject: [PATCH] msdkdec: expand retry times to 1s One-frame sleep time is not enough to wait until there is a surface unlocked from downstream. Now expand it to 1s and add a return when fail. Part-of: --- subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c index dcb1272e69..9c0ad6f6bc 100644 --- a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c +++ b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkdec.c @@ -197,9 +197,7 @@ allocate_output_surface (GstMsdkDec * thiz) GstMemory *mem = NULL; mfxFrameSurface1 *mfx_surface = NULL; gint n = 0; - guint retry_times = gst_util_uint64_scale_ceil (GST_USECOND, - thiz->param.mfx.FrameInfo.FrameRateExtD, - thiz->param.mfx.FrameInfo.FrameRateExtN); + guint retry_times = 1000; #ifdef _WIN32 GstMapInfo map_info; #endif @@ -207,7 +205,7 @@ allocate_output_surface (GstMsdkDec * thiz) /* Free un-unsed msdk surfaces firstly, hence the associated mfx * surfaces will be moved from used list to available list */ if (!gst_msdkdec_free_unlocked_msdk_surfaces (thiz, FALSE)) { - while (n < retry_times) { + for (n = 0; n < retry_times; n++) { /* It is MediaSDK/oneVPL's requirement that only the pre-allocated * surfaces can be used during the whole decoding process. * In the case of decoder plus multi-encoders, it is possible @@ -215,11 +213,14 @@ allocate_output_surface (GstMsdkDec * thiz) * available for decoder. So here we need to wait until there is at * least one surface is free for decoder. */ - n++; g_usleep (1000); if (gst_msdkdec_free_unlocked_msdk_surfaces (thiz, TRUE)) break; } + if (n == retry_times) { + GST_WARNING ("No available unlocked msdk surfaces"); + return NULL; + } } if ((gst_buffer_pool_acquire_buffer (thiz->alloc_pool, &out_buffer, NULL))