OMX component handles are leaked in case of initialization failures
I'm working on Qt-based media application to be running on RPi4 (Debian Buster).
The application occasionally instantiates GStreamer
playbin pipelines to play h264 files.
playbin on my setup uses
omxhdmiaudiosink element to output the sound.
It also tries to use
omxh264dec element to decode h264 videos. The element in turn grabs the handle for
OMX.broadcom.video_decode component and then fails to grab handle for
OMX.broadcom.egl_render component (missing on Mesa driver on RPi4). As a result
omxh264dec fails, but leaves
OMX.broadcom.video_decode handle held by the process.
It seems that OMX component handles are shared between various components and limited by 100.
After playing 100 videos there is no more free component handles. On the following attempts to grab
OMX.broadcom.audio_render component also fail. As a result GStreamer selects alternative audio back-ends which are less efficient and cause weird playback experience.
Please make proper clean up of grabbed OMX handles in case of initialization failures.
P.S.: As a workaround it's possible to set lower rank for omx*dec elements via