diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2013-03-01 11:18:18 +0100 |
---|---|---|
committer | Josep Torra <n770galaxy@gmail.com> | 2013-03-01 12:20:51 +0100 |
commit | bf202055fb5b9d37517dfa796bb7fd036170f7c7 (patch) | |
tree | 50142f6ca2e4747a248efe9b169b48cfc823d751 | |
parent | 67eee959a66e292c3c8e4d4b4e3032e08127ec6b (diff) |
omx: Handle errors more gracefully
Conflicts:
omx/gstomx.c
-rw-r--r-- | omx/gstomx.c | 99 | ||||
-rw-r--r-- | omx/gstomx.h | 3 |
2 files changed, 19 insertions, 83 deletions
diff --git a/omx/gstomx.c b/omx/gstomx.c index 45d95c7..cb74643 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -742,7 +742,6 @@ done: GST_ERROR_OBJECT (comp->parent, "Error setting state from %d to %d: %s (0x%08x)", old_state, state, gst_omx_error_to_string (err), err); - gst_omx_component_set_last_error (comp, err); } return err; } @@ -832,10 +831,6 @@ gst_omx_component_get_state (GstOMXComponent * comp, GstClockTime timeout) done: g_mutex_unlock (comp->lock); - /* If we waited and timed out this component is unusable now */ - if (!signalled) - gst_omx_component_set_last_error (comp, OMX_ErrorTimeout); - GST_DEBUG_OBJECT (comp->parent, "Returning state %d", ret); return ret; @@ -916,28 +911,6 @@ gst_omx_component_get_port (GstOMXComponent * comp, guint32 index) } /* NOTE: Uses comp->lock and comp->messages_lock */ -void -gst_omx_component_set_last_error (GstOMXComponent * comp, OMX_ERRORTYPE err) -{ - g_return_if_fail (comp != NULL); - - if (err == OMX_ErrorNone) - return; - - g_mutex_lock (comp->lock); - GST_ERROR_OBJECT (comp->parent, "Setting last error: %s (0x%08x)", - gst_omx_error_to_string (err), err); - /* We only set the first error ever from which - * we can't recover anymore. - */ - if (comp->last_error == OMX_ErrorNone) - comp->last_error = err; - g_mutex_unlock (comp->lock); - - gst_omx_component_send_message (comp, NULL); -} - -/* NOTE: Uses comp->lock and comp->messages_lock */ OMX_ERRORTYPE gst_omx_component_get_last_error (GstOMXComponent * comp) { @@ -1136,23 +1109,26 @@ gst_omx_component_close_tunnel (GstOMXComponent * comp1, GstOMXPort * port1, return err; } -void +OMX_ERRORTYPE gst_omx_port_get_port_definition (GstOMXPort * port, OMX_PARAM_PORTDEFINITIONTYPE * port_def) { GstOMXComponent *comp; + OMX_ERRORTYPE err; - g_return_if_fail (port != NULL); + g_return_val_if_fail (port != NULL, OMX_ErrorBadParameter); comp = port->comp; GST_OMX_INIT_STRUCT (port_def); port_def->nPortIndex = port->index; - gst_omx_component_get_parameter (comp, OMX_IndexParamPortDefinition, + err = gst_omx_component_get_parameter (comp, OMX_IndexParamPortDefinition, port_def); if (comp->hacks & GST_OMX_HACK_PORT_ACTUAL_COUNT_IS_MINIMUM) port_def->nBufferCountMin = port->min_buffer_count; + + return err; } OMX_ERRORTYPE @@ -1381,9 +1357,6 @@ done: gst_omx_component_handle_messages (comp); g_mutex_unlock (comp->lock); - if (err != OMX_ErrorNone) - gst_omx_component_set_last_error (comp, err); - return err; } @@ -1527,7 +1500,7 @@ gst_omx_port_set_flushing (GstOMXPort * port, gboolean flush) "Failed to pass buffer %p (%p) to port %u: %s (0x%08x)", buf, buf->omx_buf->pBuffer, port->index, gst_omx_error_to_string (err), err); - goto error; + goto done; } GST_DEBUG_OBJECT (comp->parent, "Passed buffer %p (%p) to component", buf, buf->omx_buf->pBuffer); @@ -1544,14 +1517,6 @@ done: g_mutex_unlock (comp->lock); return err; - -error: - { - g_mutex_unlock (comp->lock); - gst_omx_component_set_last_error (comp, err); - g_mutex_lock (comp->lock); - goto done; - } } /* NOTE: Uses comp->lock and comp->messages_lock */ @@ -1576,6 +1541,9 @@ gst_omx_port_is_flushing (GstOMXPort * port) return flushing; } +static OMX_ERRORTYPE gst_omx_port_deallocate_buffers_unlocked (GstOMXPort * + port); + /* NOTE: Must be called while holding comp->lock, uses comp->messages_lock */ static OMX_ERRORTYPE gst_omx_port_allocate_buffers_unlocked (GstOMXPort * port, @@ -1619,7 +1587,7 @@ gst_omx_port_allocate_buffers_unlocked (GstOMXPort * port, GST_ERROR_OBJECT (comp->parent, "Failed to configure number of buffers of port %u: %s (0x%08x)", port->index, gst_omx_error_to_string (err), err); - goto error; + goto done; } GST_DEBUG_OBJECT (comp->parent, @@ -1657,7 +1625,8 @@ gst_omx_port_allocate_buffers_unlocked (GstOMXPort * port, GST_ERROR_OBJECT (comp->parent, "Failed to allocate buffer for port %u: %s (0x%08x)", port->index, gst_omx_error_to_string (err), err); - goto error; + gst_omx_port_deallocate_buffers_unlocked (port); + goto done; } GST_DEBUG_OBJECT (comp->parent, "Allocated buffer %p (%p)", buf, @@ -1680,14 +1649,6 @@ done: port->index, gst_omx_error_to_string (err), err); return err; - -error: - { - g_mutex_unlock (comp->lock); - gst_omx_component_set_last_error (comp, err); - g_mutex_lock (comp->lock); - goto done; - } } /* NOTE: Uses comp->lock and comp->messages_lock */ @@ -1895,7 +1856,7 @@ gst_omx_port_set_enabled_unlocked (GstOMXPort * port, gboolean enabled) GST_ERROR_OBJECT (comp->parent, "Failed to send enable/disable command to port %u: %s (0x%08x)", port->index, gst_omx_error_to_string (err), err); - goto error; + goto done; } if ((err = comp->last_error) != OMX_ErrorNone) { @@ -1914,14 +1875,6 @@ done: (enabled ? "enabled" : "disabled"), gst_omx_error_to_string (err), err); return err; - -error: - { - g_mutex_unlock (comp->lock); - gst_omx_component_set_last_error (comp, err); - g_mutex_lock (comp->lock); - goto done; - } } static OMX_ERRORTYPE @@ -1996,12 +1949,12 @@ gst_omx_port_wait_buffers_released_unlocked (GstOMXPort * port, GST_ERROR_OBJECT (comp->parent, "Got error while waiting for port %u to release all buffers: %s (0x%08x)", port->index, gst_omx_error_to_string (err), err); - goto error; + goto done; } else if (!signalled) { GST_ERROR_OBJECT (comp->parent, "Timeout waiting for port %u to release all buffers", port->index); err = OMX_ErrorTimeout; - goto error; + goto done; } done: @@ -2014,14 +1967,6 @@ done: gst_omx_error_to_string (err), err); return err; - -error: - { - g_mutex_unlock (comp->lock); - gst_omx_component_set_last_error (comp, err); - g_mutex_lock (comp->lock); - goto done; - } } /* NOTE: Uses comp->lock and comp->messages_lock */ @@ -2140,7 +2085,7 @@ gst_omx_port_wait_enabled_unlocked (GstOMXPort * port, GstClockTime timeout) "Timeout waiting for port %u to be %s", port->index, (enabled ? "enabled" : "disabled")); err = OMX_ErrorTimeout; - goto error; + goto done; } else if (last_error != OMX_ErrorNone) { GST_ERROR_OBJECT (comp->parent, "Got error while waiting for port %u to be %s: %s (0x%08x)", @@ -2177,7 +2122,7 @@ gst_omx_port_wait_enabled_unlocked (GstOMXPort * port, GstClockTime timeout) "Failed to pass buffer %p (%p) to port %u: %s (0x%08x)", buf, buf->omx_buf->pBuffer, port->index, gst_omx_error_to_string (err), err); - goto error; + goto done; } GST_DEBUG_OBJECT (comp->parent, "Passed buffer %p (%p) to component", buf, buf->omx_buf->pBuffer); @@ -2195,14 +2140,6 @@ done: (enabled ? "enabled" : "disabled"), gst_omx_error_to_string (err), err); return err; - -error: - { - g_mutex_unlock (comp->lock); - gst_omx_component_set_last_error (comp, err); - g_mutex_lock (comp->lock); - goto done; - } } /* NOTE: Uses comp->lock and comp->messages_lock */ diff --git a/omx/gstomx.h b/omx/gstomx.h index 6fa7ee9..c21409c 100644 --- a/omx/gstomx.h +++ b/omx/gstomx.h @@ -279,7 +279,6 @@ void gst_omx_component_free (GstOMXComponent * comp); OMX_ERRORTYPE gst_omx_component_set_state (GstOMXComponent * comp, OMX_STATETYPE state); OMX_STATETYPE gst_omx_component_get_state (GstOMXComponent * comp, GstClockTime timeout); -void gst_omx_component_set_last_error (GstOMXComponent * comp, OMX_ERRORTYPE err); OMX_ERRORTYPE gst_omx_component_get_last_error (GstOMXComponent * comp); const gchar * gst_omx_component_get_last_error_string (GstOMXComponent * comp); @@ -295,7 +294,7 @@ OMX_ERRORTYPE gst_omx_component_setup_tunnel (GstOMXComponent * comp1, GstOM OMX_ERRORTYPE gst_omx_component_close_tunnel (GstOMXComponent * comp1, GstOMXPort * port1, GstOMXComponent * comp2, GstOMXPort * port2); -void gst_omx_port_get_port_definition (GstOMXPort * port, OMX_PARAM_PORTDEFINITIONTYPE * port_def); +OMX_ERRORTYPE gst_omx_port_get_port_definition (GstOMXPort * port, OMX_PARAM_PORTDEFINITIONTYPE * port_def); OMX_ERRORTYPE gst_omx_port_update_port_definition (GstOMXPort *port, OMX_PARAM_PORTDEFINITIONTYPE *port_definition); GstOMXAcquireBufferReturn gst_omx_port_acquire_buffer (GstOMXPort *port, GstOMXBuffer **buf); |