GStreamer multimedia framework
Find a file
George Kiagiadakis 0ef1e90b34 omx: call handle_messages() only once in acquire_buffer() to avoid potential deadlock
There is one rare case where calling handle_messages() more than once can cause a deadlock
in the video decoder element:

- sink pad thread starts the src pad task (gst_omx_video_dec_loop())
- _video_dec_loop() calls gst_omx_port_acquire_buffer() on dec_out_port
- blocks in gst_omx_component_wait_message() releasing comp->lock and comp->messages_lock
  (initially, there are no buffers configured on that port, so it waits for OMX_EventPortSettingsChanged)
- the sink pad thread pushes a buffer to the decoder with gst_omx_port_release_buffer()
- _release_buffer() grabs comp->lock and sends the buffer to OMX, which consumes it immediately
- EmptyBufferDone gets called at this point, which signals _wait_message() to unblock
- the message from EmptyBufferDone is processed in gst_omx_component_handle_messages()
  called from gst_omx_port_release_buffer()
- gst_omx_port_release_buffer releases comp->lock
- the src pad thread now gets to run, grabbing comp->lock while it exits from _wait_message()
- _acquire_buffer() calls the _handle_messages() on the next line after _wait_message(),
  which does nothing (no pending messages)
- then it goes to "retry:" and calls _handle_messages() again, which also does nothing
  (still no pending messages)
- scheduler switches to a videocore thread that calls EventHandler, informing us about the
  OMX_EventPortSettingsChanged event that just arrived
- EventHandler graps comp->messages_lock, but not comp->lock, so it can run in parallel at
  this point just fine.
- scheduler switches back to the src pad thread (which is in the middle of _acquire_buffer())
- the next _handle_messages() which is right before if (g_queue_is_empty (&port->pending_buffers))
  processes the OMX_EventPortSettingsChanged
- the buffer queue is still empty, so that thread blocks again in _wait_message()
- the sink pad thread tries to acquire the next input port buffer
- _acquire_buffer() also blocks this thread in:
   if (comp->pending_reconfigure_outports) { ... _wait_message() ... }
- DEADLOCK. gstreamer is waiting for omx to do something, omx waits for gstreamer to do something.

By removing those extra _handle_messages() calls, we can ensure that all the checks of
_acquire_buffer() will re-run. In the above case, after the scheduler switches back to
the middle of _acquire_buffer(), the code will enter _wait_message(), which will see that
there are pending messages and will return immediately, going back to "retry:" and
re-doing all the checks properly.

https://bugzilla.gnome.org/show_bug.cgi?id=741854
2015-03-04 09:51:03 +01:00
common@bc76a8b6a2 Automatic update of common submodule 2015-01-12 16:13:35 +01:00
config omxvideoenc: Implement the hack flag GST_OMX_HACK_NO_COMPONENT_RECONFIGURE 2014-08-28 10:45:11 +03:00
examples examples: #define GST_USE_UNSTABLE_API for libgstgl 2014-06-30 15:00:54 +02:00
omx omx: call handle_messages() only once in acquire_buffer() to avoid potential deadlock 2015-03-04 09:51:03 +01:00
tools omx: Use has_suffix() instead of has_prefix() for the Broadcom hack 2012-12-19 12:19:12 +01:00
.gitignore Update .gitignore 2013-02-21 10:14:12 +01:00
.gitmodules Initial commit with build system 2011-06-21 10:52:13 +02:00
Android.mk Enable building with Android's buildsystem 2012-01-19 14:08:12 -03:00
AUTHORS Release 1.0.0 2013-03-22 17:16:33 +01:00
autogen.sh Initial commit with build system 2011-06-21 10:52:13 +02:00
ChangeLog Release 1.2.0 2014-07-23 11:28:12 +02:00
configure.ac Release 1.2.0 2014-07-23 11:28:12 +02:00
COPYING Initial commit with build system 2011-06-21 10:52:13 +02:00
gst-omx.doap Release 1.2.0 2014-07-23 11:28:12 +02:00
INSTALL Initial commit with build system 2011-06-21 10:52:13 +02:00
Makefile.am example: enable testegl 2014-06-25 10:50:54 +01:00
NEWS Release 1.2.0 2014-07-23 11:28:12 +02:00
README omx: Add minimal README file 2011-10-25 14:24:59 +02:00
RELEASE Release 1.2.0 2014-07-23 11:28:12 +02:00

GStreamer OpenMAX IL wrapper plugin
--------------------------

 This plugin wraps available OpenMAX IL components and makes
 them available as standard GStreamer elements.

License:
--------

  This package and its contents are licensend under the GNU Lesser General
Public License (LGPL).

Dependencies:
-------------

 * GStreamer core
 * gst-plugins-base