Commit graph

81 commits

Author SHA1 Message Date
Nicolas Dufresne 8c3bd103ff omx: Add a method to send message 2013-01-14 10:37:13 +01:00
Sebastian Dröge 2d913c6773 omx: Atomic ops are not required anymore for the reconfiguration 2013-01-14 10:37:06 +01:00
Sebastian Dröge a42f27547d omx: Implement new approach for locking that should solve all deadlocks on RPi
No mutex is locked while calling any OpenMAX functions anymore
and everything from the OpenMAX callbacks is inserted into a message
queue and handled from outside the callbacks.

Also there's only a single mutex and condition variable per component
now for handling anything from OpenMAX callbacks and a single mutex
for keeping our component/port state sane.
2013-01-14 10:36:32 +01:00
Sebastian Dröge e026926951 omx: Fix another race condition in the recursive mutex
Between lock() and begin_recursion() it was possible for another thread to
try to do a recursive_lock(). This would block because the mutex was already
locked(), but not ready for recursive locking yet. unlock() would never
happen in the original thread because it was waiting for the other thread
to finish first.

Happened on the Raspberry Pi.
2012-12-20 17:46:36 +01:00
Sebastian Dröge b93d86abbe omx: Use has_suffix() instead of has_prefix() for the Broadcom hack 2012-12-19 12:19:12 +01:00
Sebastian Dröge 5105daba1a omx: Add hack to load and initialize libbcm_host.so
Needed on the Raspberry Pi. Patch based on a patch by
George Kiagiadakis <george.kiagiadakis@collabora.com>
2012-12-19 11:31:51 +01:00
Sebastian Dröge 2481ceb8c4 omx: Update to new GLib thread API 2012-11-12 11:29:48 +01:00
George Kiagiadakis f93feb2644 omx: fix debug statement 2012-09-03 12:37:02 +03:00
George Kiagiadakis 8a669ee308 omx: use recursive_lock inside set_last_error(), since this function may be called from an event handler 2012-09-03 12:36:53 +03:00
Tim-Philipp Müller 3f963f87fb omx: fix plugin name for new GST_PLUGIN_DEFINE API 2012-08-03 19:32:13 +01:00
George Kiagiadakis 7b3dac67af omx: Fix spelling mistake found by lintian: s/Seperate/Separate/ 2012-05-08 16:16:00 +03:00
George Kiagiadakis 158775f497 Implement a new custom recursive mutex type and fix locking in callbacks so that in-context calls are allowed.
According to the OMX specification, implementations are allowed to call
callbacks in the context of their function calls. However, our callbacks
take locks and this causes deadlocks if the unerlying OMX implementation
uses this kind of in-context calls.

A solution to the problem would be a recursive mutex. However, a normal
recursive mutex does not fix the problem because it is not guaranteed
that the callbacks are called from the same thread. What we see in Broadcom's
implementation for example is:

- OMX_Foo is called
- OMX_Foo waits on a condition
- A callback is executed in a different thread
- When the callback returns, its calling function
  signals the condition that OMX_Foo waits on
- OMX_Foo wakes up and returns

The solution I came up with here is to take a second lock inside the callback,
but only if recursion is expected to happen. Therefore, all calls to OMX
functions are guarded by calls to gst_omx_rec_mutex_begin_recursion() / _end_recursion(),
which effectively tells the mutex that at this point we want to allow calls
to _recursive_lock() to succeed, although we are still holding the master lock.
2012-05-07 17:01:16 +03:00
George Kiagiadakis 5c15caef8e omx: Add hack to disable setting roles to components.
Conflicts:

	omx/gstomx.c
2012-05-03 13:21:18 +02:00
Arun Raghavan 34a83c184e omx: Fix trivial debug print bug 2012-04-26 09:42:54 +05:30
Arun Raghavan 9e4cddee7e omxvideodec: Add hack for Ducati components not returning from drain
This happens on the Galaxy Nexus, and causes the pipeline to hang waiting
endlessly for a drain. The hack replaces the wait with a wait + 500ms timeout.
2012-04-26 09:42:52 +05:30
Arun Raghavan 036cd16756 omx: Fix deadlock between ending a flush and the event handler
gst_omx_port_set_flushing() calls OMX_FillThisBuffer at the end of a flush
without releasing the port lock, and this can cause a deadlock with the
EventHandler. This patches fixes this by dropping the lock for the duration of
the fill buffer call.
2012-04-26 09:42:50 +05:30
Olivier Crête ff2603a727 Port to Gst 0.11 2012-04-13 12:16:34 -04:00
Sebastian Dröge 9e6665e8f8 omx: Add hack for encoder components that don't allow empty EOS buffers 2011-12-09 12:24:01 +01:00
Sebastian Dröge 0cb32a4ebd omx: Improve debugging of buffer handling 2011-12-05 13:18:09 +01:00
Sebastian Dröge 47d66cadfa omx: Only disabling of a port is like flushing, enabling is like unflushing 2011-11-17 14:38:54 -08:00
Sebastian Dröge c144ebd054 omx: Enabling/disabling a port is also like flushing
The component returns all buffers to us and shouldn't get any
new buffers passed anymore.
2011-11-17 14:11:51 -08:00
Sebastian Dröge 70b735da82 omx: Fix debug level for flushing in wrong state from ERROR to DEBUG
It's not really an error and doesn't matter at all if flush is called
when the component is not running.
2011-11-15 09:47:55 -08:00
Sebastian Dröge 6736a39671 omx: Add XXX to the nOffset reset hack comment for QCOM 2011-11-14 09:13:06 -08:00
Sebastian Dröge b66fd610d6 omx: Always reset buffer flags for output ports, even in flushing/error state 2011-11-09 15:41:02 +01:00
Sebastian Dröge 1d071c05dc omx: Also properly release buffers when in error state 2011-11-08 08:24:49 +01:00
Jonas Larsson 0682012181 omx: Properly release buffers during flushing
We can't pass them back to OMX_FillThisBuffer() or OMX_EmptyThisBuffer()
but instead of doing nothing we have to put them back into our queue.
Otherwise the buffer is leaked and we will have too few buffers in
the future.
2011-11-08 08:24:49 +01:00
Sebastian Dröge fa6881c1cc omx: Reset buffer flags to 0 after it was consumed by the component or the element
Some implementations don't reset the flags and the standard is not
really clear on the expected behaviour. Let's just always reset the
flags as they're not valid at this point anymore.
2011-11-04 09:04:16 +01:00
Sebastian Dröge 72fa93956b omx: Remove QCOM hack to reset nOffset in EmptyBufferDone
This is now done in a generic way that does not require any
hacks because it will work without any side effects on any
OMX implementation.
2011-10-14 10:27:47 +02:00
Sebastian Dröge 2750a8869b omx: Reset nOffset to 0 in EmptyBufferDone if nFilledLen is 0
Some OMX implementations don't reset nOffset when the complete
buffer is emptied but instead only reset nFilledLen. We reset
nOffset to 0 if nFilledLen == 0, which is safe to do because
the offset *must* be 0 if the buffer is not filled at all.

Seen in QCOM's OMX implementation.
2011-10-14 10:26:21 +02:00
Sebastian Dröge 792cdb7d1f omxvideodec: New hack for QCOM to recreate the component instead of reconfiguring it on caps changes 2011-09-28 10:35:31 +02:00
Sebastian Dröge a7f77e22a4 omx: Change a g_assert() into a GST_WARNING_OBJECT() 2011-09-27 12:28:22 +02:00
Sebastian Dröge 837fc4ca66 omx: Add hack for Qualcomm's OMX implementation to manually reset nOffset in EmptyBufferDone 2011-09-26 13:05:23 +02:00
Sebastian Dröge f0fe1148b7 omx: Wait until the Executing state is reached before calling OMX_FillThisBuffer()
This correctly works around the QCOM race condition that happens when calling
FTB after setting the new state and before reaching it.
2011-09-14 10:16:41 +02:00
Sebastian Dröge 422ca1796b omxaacenc: Add initial version of OpenMAX AAC encoder element 2011-08-16 10:49:21 +02:00
Sebastian Dröge 9dcaf5c2bb omx: Don't hold any locks while calling OMX_SendCommand()
It might call into one of the callbacks and lead to deadlocks, e.g.
with the Qualcomm OMX implementation.
2011-08-10 09:49:57 +02:00
Sebastian Dröge 0bb345a16d omx: Move some code 2011-08-10 09:32:01 +02:00
Sebastian Dröge e413b8403c omx: Reset pending reconfigure output ports when changing the state from Executing to any lower state 2011-08-10 09:23:10 +02:00
Sebastian Dröge 25fd0594f5 omx: Fix crash when setting last error after the ports were freed 2011-08-10 09:08:00 +02:00
Sebastian Dröge 9678efdf88 omx: Free component structure 2011-08-10 09:03:52 +02:00
Sebastian Dröge 52a422f637 omx: Make component destruction safer 2011-08-10 09:02:52 +02:00
Sebastian Dröge 8fd4eaae69 omx: Set pAppPrivate of buffers to NULL when deallocating buffers
This prevents usage of freed memory later if the OMX component
has weird behaviour.
2011-08-10 08:55:18 +02:00
Sebastian Dröge cb001aa85f omx: Add some assertions to check if the buffer pAppPrivate is still correct 2011-08-10 08:51:54 +02:00
Sebastian Dröge 825d435d7d omx: Only prevent setting a higher state if the component is in an error state 2011-08-08 12:12:58 +02:00
Sebastian Dröge 2c4dcf418a omx: Improve debugging in param/config getter/setter wrappers 2011-08-03 15:35:01 +02:00
Sebastian Dröge aced7478ab omx: Add a hacks flag for the Qualcomm 7x30 OMX_FillThisBuffer() race and make it optional 2011-08-01 13:22:05 +02:00
Sebastian Dröge cba41896a6 omx: Add workaround for QCOM 7x30 race condition 2011-07-29 13:56:59 +02:00
Sebastian Dröge b085e11c37 omxh263enc: Add H.263 encoder element 2011-07-29 12:06:21 +02:00
Sebastian Dröge f2b456e2e6 omx: Add wrapper functions for OMX_[GS]et{Config,Parameter} 2011-07-28 12:16:43 +02:00
Sebastian Dröge 35850e7233 omx: Add macro to initialize OpenMAX structures 2011-07-28 12:16:43 +02:00
Sebastian Dröge 1fa3b2662e omx: Ensure that the pAppPrivate pointer in OMX buffers is set correctly 2011-07-25 15:05:08 +02:00