msdkdec: free unlocked msdk surface before output buffer allocation
!924 (merged) is trying to use video memory for decoding on Linux, which reveals a hidden bug in msdkdec.
For video memory, it is possible that a locked mfx surface is not used indeed and it will be un-locked later in MSDK, so we have to check the associated MSDK surface to find out and free un-used surfaces, otherwise it is easy to exhaust all pre-allocated mfx surfaces and get errors below:
0:00:00.777324879 27290 0x564b65a510a0 ERROR default gstmsdkvideomemory.c:77:gst_msdk_video_allocator_get_surface: failed to get surface available 0:00:00.777429079 27290 0x564b65a510a0 ERROR msdkbufferpool gstmsdkbufferpool.c:260:gst_msdk_buffer_pool_alloc_buffer: failed to create new MSDK memory
Note the sample code in MSDK does similar thing in CBuffering::SyncFrameSurfaces()