diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2018-08-13 15:10:37 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2018-08-30 10:59:30 +0200 |
commit | 34bc02e397d8db72c06d86f7a8734c0d34d78276 (patch) | |
tree | 99e0ff396abf4cfc81b57ef6ac4f199e713942d9 /omx | |
parent | c89b54fe7867568f85ccc3b8660bbbd839659fcd (diff) | |
download | gst-omx-34bc02e397d8db72c06d86f7a8734c0d34d78276.tar.gz |
omx: allow gst_omx_port_acquire_buffer() to not wait for buffers
Will be needed to implement GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT.
https://bugzilla.gnome.org/show_bug.cgi?id=796918
Diffstat (limited to 'omx')
-rw-r--r-- | omx/gstomx.c | 17 | ||||
-rw-r--r-- | omx/gstomx.h | 11 | ||||
-rw-r--r-- | omx/gstomxaudiodec.c | 6 | ||||
-rw-r--r-- | omx/gstomxaudioenc.c | 6 | ||||
-rw-r--r-- | omx/gstomxaudiosink.c | 2 | ||||
-rw-r--r-- | omx/gstomxvideodec.c | 6 | ||||
-rw-r--r-- | omx/gstomxvideoenc.c | 6 |
7 files changed, 34 insertions, 20 deletions
diff --git a/omx/gstomx.c b/omx/gstomx.c index 6096806..8f99f82 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -1372,7 +1372,8 @@ gst_omx_port_update_port_definition (GstOMXPort * port, /* 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; @@ -1504,11 +1505,17 @@ retry: 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", diff --git a/omx/gstomx.h b/omx/gstomx.h index cab62bd..c43e2d7 100644 --- a/omx/gstomx.h +++ b/omx/gstomx.h @@ -225,7 +225,9 @@ typedef enum { /* 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 { @@ -269,6 +271,11 @@ typedef enum { 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; @@ -441,7 +448,7 @@ OMX_ERRORTYPE gst_omx_close_tunnel (GstOMXPort * port1, GstOMXPort * port2); 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); diff --git a/omx/gstomxaudiodec.c b/omx/gstomxaudiodec.c index 1fb0bd5..8275b72 100644 --- a/omx/gstomxaudiodec.c +++ b/omx/gstomxaudiodec.c @@ -303,7 +303,7 @@ gst_omx_audio_dec_loop (GstOMXAudioDec * self) 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) { @@ -1085,7 +1085,7 @@ gst_omx_audio_dec_handle_frame (GstAudioDecoder * decoder, GstBuffer * inbuf) * _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); @@ -1353,7 +1353,7 @@ gst_omx_audio_dec_drain (GstOMXAudioDec * 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", diff --git a/omx/gstomxaudioenc.c b/omx/gstomxaudioenc.c index 036b911..c5c1d6f 100644 --- a/omx/gstomxaudioenc.c +++ b/omx/gstomxaudioenc.c @@ -285,7 +285,7 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self) 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) { @@ -960,7 +960,7 @@ gst_omx_audio_enc_handle_frame (GstAudioEncoder * encoder, GstBuffer * inbuf) * _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); @@ -1145,7 +1145,7 @@ gst_omx_audio_enc_drain (GstOMXAudioEnc * 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", diff --git a/omx/gstomxaudiosink.c b/omx/gstomxaudiosink.c index 0f1c23e..d4e684f 100644 --- a/omx/gstomxaudiosink.c +++ b/omx/gstomxaudiosink.c @@ -760,7 +760,7 @@ gst_omx_audio_sink_acquire_buffer (GstOMXAudioSink * self) 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) { diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index cdf6300..1a943b3 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -1608,7 +1608,7 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self) 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) { @@ -2816,7 +2816,7 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, * _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); @@ -3149,7 +3149,7 @@ gst_omx_video_dec_finish (GstVideoDecoder * decoder) /* 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", diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index a8a0212..6da94a7 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -1425,7 +1425,7 @@ gst_omx_video_enc_loop (GstOMXVideoEnc * self) 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) { @@ -2673,7 +2673,7 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder, * _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); @@ -2933,7 +2933,7 @@ gst_omx_video_enc_drain (GstOMXVideoEnc * 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", |