Will be needed to implement GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT.
https://bugzilla.gnome.org/show_bug.cgi?id=796918
/* NOTE: Uses comp->lock and comp->messages_lock */
GstOMXAcquireBufferReturn
-gst_omx_port_acquire_buffer (GstOMXPort * port, GstOMXBuffer ** buf)
+gst_omx_port_acquire_buffer (GstOMXPort * port, GstOMXBuffer ** buf,
+ GstOMXWait wait)
{
GstOMXAcquireBufferReturn ret = GST_OMX_ACQUIRE_BUFFER_ERROR;
GstOMXComponent *comp;
if (g_queue_is_empty (&port->pending_buffers)) {
GST_DEBUG_OBJECT (comp->parent, "Queue of %s port %u is empty",
comp->name, port->index);
- gst_omx_component_wait_message (comp,
- timeout == -2 ? GST_CLOCK_TIME_NONE : timeout);
- /* And now check everything again and maybe get a buffer */
- goto retry;
+ if (wait == GST_OMX_WAIT) {
+ gst_omx_component_wait_message (comp,
+ timeout == -2 ? GST_CLOCK_TIME_NONE : timeout);
+
+ /* And now check everything again and maybe get a buffer */
+ goto retry;
+ } else {
+ ret = GST_OMX_ACQUIRE_BUFFER_NO_AVAILABLE;
+ goto done;
+ }
}
GST_DEBUG_OBJECT (comp->parent, "%s port %u has pending buffers",
/* The port is EOS */
GST_OMX_ACQUIRE_BUFFER_EOS,
/* A fatal error happened */
- GST_OMX_ACQUIRE_BUFFER_ERROR
+ GST_OMX_ACQUIRE_BUFFER_ERROR,
+ /* No buffer is currently available (used when calling gst_omx_port_acquire_buffer() in not waiting mode) */
+ GST_OMX_ACQUIRE_BUFFER_NO_AVAILABLE,
} GstOMXAcquireBufferReturn;
struct _GstOMXCore {
GST_OMX_BUFFER_ALLOCATION_USE_BUFFER_DYNAMIC, /* Only supported by OMX 1.2.0 */
} GstOMXBufferAllocation;
+typedef enum {
+ GST_OMX_WAIT,
+ GST_OMX_DONT_WAIT,
+} GstOMXWait;
+
struct _GstOMXMessage {
GstOMXMessageType type;
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);
+GstOMXAcquireBufferReturn gst_omx_port_acquire_buffer (GstOMXPort *port, GstOMXBuffer **buf, GstOMXWait wait);
OMX_ERRORTYPE gst_omx_port_release_buffer (GstOMXPort *port, GstOMXBuffer *buf);
OMX_ERRORTYPE gst_omx_port_set_flushing (GstOMXPort *port, GstClockTime timeout, gboolean flush);
OMX_ERRORTYPE err;
gint spf;
- acq_return = gst_omx_port_acquire_buffer (port, &buf);
+ acq_return = gst_omx_port_acquire_buffer (port, &buf, GST_OMX_WAIT);
if (acq_return == GST_OMX_ACQUIRE_BUFFER_ERROR) {
goto component_error;
} else if (acq_return == GST_OMX_ACQUIRE_BUFFER_FLUSHING) {
* _loop() can't call _finish_frame() and we might block forever
* because no input buffers are released */
GST_AUDIO_DECODER_STREAM_UNLOCK (self);
- acq_ret = gst_omx_port_acquire_buffer (port, &buf);
+ acq_ret = gst_omx_port_acquire_buffer (port, &buf, GST_OMX_WAIT);
if (acq_ret == GST_OMX_ACQUIRE_BUFFER_ERROR) {
GST_AUDIO_DECODER_STREAM_LOCK (self);
/* Send an EOS buffer to the component and let the base
* class drop the EOS event. We will send it later when
* the EOS buffer arrives on the output port. */
- acq_ret = gst_omx_port_acquire_buffer (self->dec_in_port, &buf);
+ acq_ret = gst_omx_port_acquire_buffer (self->dec_in_port, &buf, GST_OMX_WAIT);
if (acq_ret != GST_OMX_ACQUIRE_BUFFER_OK) {
GST_AUDIO_DECODER_STREAM_LOCK (self);
GST_ERROR_OBJECT (self, "Failed to acquire buffer for draining: %d",
klass = GST_OMX_AUDIO_ENC_GET_CLASS (self);
- acq_return = gst_omx_port_acquire_buffer (port, &buf);
+ acq_return = gst_omx_port_acquire_buffer (port, &buf, GST_OMX_WAIT);
if (acq_return == GST_OMX_ACQUIRE_BUFFER_ERROR) {
goto component_error;
} else if (acq_return == GST_OMX_ACQUIRE_BUFFER_FLUSHING) {
* _loop() can't call _finish_frame() and we might block forever
* because no input buffers are released */
GST_AUDIO_ENCODER_STREAM_UNLOCK (self);
- acq_ret = gst_omx_port_acquire_buffer (port, &buf);
+ acq_ret = gst_omx_port_acquire_buffer (port, &buf, GST_OMX_WAIT);
if (acq_ret == GST_OMX_ACQUIRE_BUFFER_ERROR) {
GST_AUDIO_ENCODER_STREAM_LOCK (self);
/* Send an EOS buffer to the component and let the base
* class drop the EOS event. We will send it later when
* the EOS buffer arrives on the output port. */
- acq_ret = gst_omx_port_acquire_buffer (self->enc_in_port, &buf);
+ acq_ret = gst_omx_port_acquire_buffer (self->enc_in_port, &buf, GST_OMX_WAIT);
if (acq_ret != GST_OMX_ACQUIRE_BUFFER_OK) {
GST_AUDIO_ENCODER_STREAM_LOCK (self);
GST_ERROR_OBJECT (self, "Failed to acquire buffer for draining: %d",
GstOMXBuffer *buf = NULL;
while (!buf) {
- acq_ret = gst_omx_port_acquire_buffer (port, &buf);
+ acq_ret = gst_omx_port_acquire_buffer (port, &buf, GST_OMX_WAIT);
if (acq_ret == GST_OMX_ACQUIRE_BUFFER_ERROR) {
goto component_error;
} else if (acq_ret == GST_OMX_ACQUIRE_BUFFER_FLUSHING) {
port = self->dec_out_port;
#endif
- acq_return = gst_omx_port_acquire_buffer (port, &buf);
+ acq_return = gst_omx_port_acquire_buffer (port, &buf, GST_OMX_WAIT);
if (acq_return == GST_OMX_ACQUIRE_BUFFER_ERROR) {
goto component_error;
} else if (acq_return == GST_OMX_ACQUIRE_BUFFER_FLUSHING) {
* _loop() can't call _finish_frame() and we might block forever
* because no input buffers are released */
GST_VIDEO_DECODER_STREAM_UNLOCK (self);
- acq_ret = gst_omx_port_acquire_buffer (port, &buf);
+ acq_ret = gst_omx_port_acquire_buffer (port, &buf, GST_OMX_WAIT);
if (acq_ret == GST_OMX_ACQUIRE_BUFFER_ERROR) {
GST_VIDEO_DECODER_STREAM_LOCK (self);
/* Send an EOS buffer to the component and let the base
* class drop the EOS event. We will send it later when
* the EOS buffer arrives on the output port. */
- acq_ret = gst_omx_port_acquire_buffer (self->dec_in_port, &buf);
+ acq_ret = gst_omx_port_acquire_buffer (self->dec_in_port, &buf, GST_OMX_WAIT);
if (acq_ret != GST_OMX_ACQUIRE_BUFFER_OK) {
GST_VIDEO_DECODER_STREAM_LOCK (self);
GST_ERROR_OBJECT (self, "Failed to acquire buffer for draining: %d",
klass = GST_OMX_VIDEO_ENC_GET_CLASS (self);
- acq_return = gst_omx_port_acquire_buffer (port, &buf);
+ acq_return = gst_omx_port_acquire_buffer (port, &buf, GST_OMX_WAIT);
if (acq_return == GST_OMX_ACQUIRE_BUFFER_ERROR) {
goto component_error;
} else if (acq_return == GST_OMX_ACQUIRE_BUFFER_FLUSHING) {
* _loop() can't call _finish_frame() and we might block forever
* because no input buffers are released */
GST_VIDEO_ENCODER_STREAM_UNLOCK (self);
- acq_ret = gst_omx_port_acquire_buffer (port, &buf);
+ acq_ret = gst_omx_port_acquire_buffer (port, &buf, GST_OMX_WAIT);
if (acq_ret == GST_OMX_ACQUIRE_BUFFER_ERROR) {
GST_VIDEO_ENCODER_STREAM_LOCK (self);
/* Send an EOS buffer to the component and let the base
* class drop the EOS event. We will send it later when
* the EOS buffer arrives on the output port. */
- acq_ret = gst_omx_port_acquire_buffer (self->enc_in_port, &buf);
+ acq_ret = gst_omx_port_acquire_buffer (self->enc_in_port, &buf, GST_OMX_WAIT);
if (acq_ret != GST_OMX_ACQUIRE_BUFFER_OK) {
GST_VIDEO_ENCODER_STREAM_LOCK (self);
GST_ERROR_OBJECT (self, "Failed to acquire buffer for draining: %d",