mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
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
This commit is contained in:
parent
c89b54fe78
commit
34bc02e397
7 changed files with 34 additions and 20 deletions
17
omx/gstomx.c
17
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",
|
||||
|
|
11
omx/gstomx.h
11
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);
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue