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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4088>
This commit is contained in:
Tong Wu 2022-11-24 11:00:15 +08:00 committed by GStreamer Marge Bot
parent 123c8d14c1
commit 8105d2044d

View file

@ -197,9 +197,7 @@ allocate_output_surface (GstMsdkDec * thiz)
GstMemory *mem = NULL; GstMemory *mem = NULL;
mfxFrameSurface1 *mfx_surface = NULL; mfxFrameSurface1 *mfx_surface = NULL;
gint n = 0; gint n = 0;
guint retry_times = gst_util_uint64_scale_ceil (GST_USECOND, guint retry_times = 1000;
thiz->param.mfx.FrameInfo.FrameRateExtD,
thiz->param.mfx.FrameInfo.FrameRateExtN);
#ifdef _WIN32 #ifdef _WIN32
GstMapInfo map_info; GstMapInfo map_info;
#endif #endif
@ -207,7 +205,7 @@ allocate_output_surface (GstMsdkDec * thiz)
/* Free un-unsed msdk surfaces firstly, hence the associated mfx /* Free un-unsed msdk surfaces firstly, hence the associated mfx
* surfaces will be moved from used list to available list */ * surfaces will be moved from used list to available list */
if (!gst_msdkdec_free_unlocked_msdk_surfaces (thiz, FALSE)) { 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 /* It is MediaSDK/oneVPL's requirement that only the pre-allocated
* surfaces can be used during the whole decoding process. * surfaces can be used during the whole decoding process.
* In the case of decoder plus multi-encoders, it is possible * 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 * available for decoder. So here we need to wait until there is at
* least one surface is free for decoder. * least one surface is free for decoder.
*/ */
n++;
g_usleep (1000); g_usleep (1000);
if (gst_msdkdec_free_unlocked_msdk_surfaces (thiz, TRUE)) if (gst_msdkdec_free_unlocked_msdk_surfaces (thiz, TRUE))
break; 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)) if ((gst_buffer_pool_acquire_buffer (thiz->alloc_pool, &out_buffer, NULL))