From 60861f3990a735bd0404e91576facae056fb8e80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 6 Mar 2013 17:05:51 +0100 Subject: [PATCH] omx: Do number of buffers configuration explicitely --- omx/gstomx.c | 24 ++++++++---------------- omx/gstomx.h | 2 +- omx/gstomxaudioenc.c | 8 ++++---- omx/gstomxvideodec.c | 6 +++--- omx/gstomxvideoenc.c | 8 ++++---- 5 files changed, 20 insertions(+), 28 deletions(-) diff --git a/omx/gstomx.c b/omx/gstomx.c index 7bd36ef..5547025 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -1565,22 +1565,14 @@ gst_omx_port_allocate_buffers_unlocked (GstOMXPort * port, */ gst_omx_port_update_port_definition (port, NULL); - g_return_val_if_fail (n == -1 || n >= port->port_def.nBufferCountMin, - OMX_ErrorBadParameter); - if (n == -1) - n = port->port_def.nBufferCountMin; + g_return_val_if_fail (n != -1 || (!buffers + && !images), OMX_ErrorBadParameter); - if (port->port_def.nBufferCountActual != n) { - port->port_def.nBufferCountActual = n; - err = gst_omx_port_update_port_definition (port, &port->port_def); - } + if (n == -1) + n = port->port_def.nBufferCountActual; - if (err != OMX_ErrorNone) { - 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 done; - } + g_return_val_if_fail (n == port->port_def.nBufferCountActual, + OMX_ErrorBadParameter); GST_DEBUG_OBJECT (comp->parent, "Allocating %d buffers of size %u for port %u", n, @@ -1645,14 +1637,14 @@ done: /* NOTE: Uses comp->lock and comp->messages_lock */ OMX_ERRORTYPE -gst_omx_port_allocate_buffers (GstOMXPort * port, guint n) +gst_omx_port_allocate_buffers (GstOMXPort * port) { OMX_ERRORTYPE err; g_return_val_if_fail (port != NULL, OMX_ErrorUndefined); g_mutex_lock (&port->comp->lock); - err = gst_omx_port_allocate_buffers_unlocked (port, NULL, NULL, n); + err = gst_omx_port_allocate_buffers_unlocked (port, NULL, NULL, -1); g_mutex_unlock (&port->comp->lock); return err; diff --git a/omx/gstomx.h b/omx/gstomx.h index 1a75969..03a38b3 100644 --- a/omx/gstomx.h +++ b/omx/gstomx.h @@ -304,7 +304,7 @@ OMX_ERRORTYPE gst_omx_port_release_buffer (GstOMXPort *port, GstOMXBuffer *b OMX_ERRORTYPE gst_omx_port_set_flushing (GstOMXPort *port, gboolean flush); gboolean gst_omx_port_is_flushing (GstOMXPort *port); -OMX_ERRORTYPE gst_omx_port_allocate_buffers (GstOMXPort *port, guint n); +OMX_ERRORTYPE gst_omx_port_allocate_buffers (GstOMXPort *port); OMX_ERRORTYPE gst_omx_port_use_buffers (GstOMXPort *port, const GList *buffers); OMX_ERRORTYPE gst_omx_port_use_eglimages (GstOMXPort *port, const GList *images); OMX_ERRORTYPE gst_omx_port_deallocate_buffers (GstOMXPort *port); diff --git a/omx/gstomxaudioenc.c b/omx/gstomxaudioenc.c index 547d0cd..0106fdb 100644 --- a/omx/gstomxaudioenc.c +++ b/omx/gstomxaudioenc.c @@ -354,7 +354,7 @@ gst_omx_audio_enc_loop (GstOMXAudioEnc * self) if (err != OMX_ErrorNone) goto reconfigure_error; - err = gst_omx_port_allocate_buffers (port, -1); + err = gst_omx_port_allocate_buffers (port); if (err != OMX_ErrorNone) goto reconfigure_error; @@ -733,7 +733,7 @@ gst_omx_audio_enc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info) if (needs_disable) { if (gst_omx_port_set_enabled (self->enc_in_port, TRUE) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_allocate_buffers (self->enc_in_port, -1) != OMX_ErrorNone) + if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone) return FALSE; if (gst_omx_port_wait_enabled (self->enc_in_port, 5 * GST_SECOND) != OMX_ErrorNone) @@ -745,7 +745,7 @@ gst_omx_audio_enc_set_format (GstAudioEncoder * encoder, GstAudioInfo * info) return FALSE; /* Need to allocate buffers to reach Idle state */ - if (gst_omx_port_allocate_buffers (self->enc_in_port, -1) != OMX_ErrorNone) + if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone) return FALSE; /* And disable output port */ @@ -900,7 +900,7 @@ gst_omx_audio_enc_handle_frame (GstAudioEncoder * encoder, GstBuffer * inbuf) goto reconfigure_error; } - err = gst_omx_port_allocate_buffers (port, -1); + err = gst_omx_port_allocate_buffers (port); if (err != OMX_ErrorNone) { GST_AUDIO_ENCODER_STREAM_LOCK (self); goto reconfigure_error; diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index 3119408..ceb592c 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -1201,7 +1201,7 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder, if (needs_disable) { if (gst_omx_port_set_enabled (self->dec_in_port, TRUE) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_allocate_buffers (self->dec_in_port, -1) != OMX_ErrorNone) + if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone) return FALSE; if (gst_omx_port_wait_enabled (self->dec_in_port, 5 * GST_SECOND) != OMX_ErrorNone) @@ -1213,7 +1213,7 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder, return FALSE; /* Need to allocate buffers to reach Idle state */ - if (gst_omx_port_allocate_buffers (self->dec_in_port, -1) != OMX_ErrorNone) + if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone) return FALSE; /* And disable output port */ @@ -1389,7 +1389,7 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, goto reconfigure_error; } - err = gst_omx_port_allocate_buffers (port, -1); + err = gst_omx_port_allocate_buffers (port); if (err != OMX_ErrorNone) { GST_VIDEO_DECODER_STREAM_LOCK (self); goto reconfigure_error; diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index c14f474..43d3963 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -807,7 +807,7 @@ gst_omx_video_enc_loop (GstOMXVideoEnc * self) if (err != OMX_ErrorNone) goto reconfigure_error; - err = gst_omx_port_allocate_buffers (port, -1); + err = gst_omx_port_allocate_buffers (port); if (err != OMX_ErrorNone) goto reconfigure_error; @@ -1206,7 +1206,7 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder, if (needs_disable) { if (gst_omx_port_set_enabled (self->enc_in_port, TRUE) != OMX_ErrorNone) return FALSE; - if (gst_omx_port_allocate_buffers (self->enc_in_port, -1) != OMX_ErrorNone) + if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone) return FALSE; if (gst_omx_port_wait_enabled (self->enc_in_port, 5 * GST_SECOND) != OMX_ErrorNone) @@ -1218,7 +1218,7 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder, return FALSE; /* Need to allocate buffers to reach Idle state */ - if (gst_omx_port_allocate_buffers (self->enc_in_port, -1) != OMX_ErrorNone) + if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone) return FALSE; /* And disable output port */ @@ -1542,7 +1542,7 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder, goto reconfigure_error; } - err = gst_omx_port_allocate_buffers (port, -1); + err = gst_omx_port_allocate_buffers (port); if (err != OMX_ErrorNone) { GST_VIDEO_ENCODER_STREAM_LOCK (self); goto reconfigure_error; -- 2.7.4