omx: factor out should_wait_until_flushed()

No semantic change. Makes the code easier to understand and I'm about to
change the waiting condition.

https://bugzilla.gnome.org/show_bug.cgi?id=789475
This commit is contained in:
Guillaume Desmottes 2018-08-22 15:52:23 +02:00 committed by Nicolas Dufresne
parent 626a481e01
commit 3d55051da3

View file

@ -1569,6 +1569,19 @@ done:
return err; return err;
} }
static gboolean
should_wait_until_flushed (GstOMXPort * port)
{
if (port->flushed)
return FALSE;
if (port->buffers
&& port->buffers->len == g_queue_get_length (&port->pending_buffers))
return FALSE;
return TRUE;
}
/* NOTE: Uses comp->lock and comp->messages_lock */ /* NOTE: Uses comp->lock and comp->messages_lock */
OMX_ERRORTYPE OMX_ERRORTYPE
gst_omx_port_set_flushing (GstOMXPort * port, GstClockTime timeout, gst_omx_port_set_flushing (GstOMXPort * port, GstClockTime timeout,
@ -1633,9 +1646,7 @@ gst_omx_port_set_flushing (GstOMXPort * port, GstClockTime timeout,
} }
if (timeout == 0) { if (timeout == 0) {
if (!port->flushed || (port->buffers if (should_wait_until_flushed (port))
&& port->buffers->len >
g_queue_get_length (&port->pending_buffers)))
err = OMX_ErrorTimeout; err = OMX_ErrorTimeout;
goto done; goto done;
} }
@ -1646,10 +1657,7 @@ gst_omx_port_set_flushing (GstOMXPort * port, GstClockTime timeout,
signalled = TRUE; signalled = TRUE;
last_error = OMX_ErrorNone; last_error = OMX_ErrorNone;
gst_omx_component_handle_messages (comp); gst_omx_component_handle_messages (comp);
while (!port->flushed && while (should_wait_until_flushed (port)) {
(port->buffers
&& port->buffers->len >
g_queue_get_length (&port->pending_buffers))) {
signalled = gst_omx_component_wait_message (comp, timeout); signalled = gst_omx_component_wait_message (comp, timeout);
if (signalled) if (signalled)
gst_omx_component_handle_messages (comp); gst_omx_component_handle_messages (comp);