[vlc-devel] [PATCH 05/21] Update the number of buffers when reconfiguring
Martin Storsjö
martin at martin.st
Mon Sep 5 11:47:36 CEST 2011
On OpenMAX devices supported earlier, the number of buffers has
stayed the same after reconfiguring, but on the Nexus One, the
number changes.
---
This is a generic bug fix for the omxil module and can
be applied to the main tree immediately.
Added error handling for the realloc call.
Changed realloc into free+malloc, since the old content of the
array doesn't need to be preserved, and since this IMO is
cleaner than proper leak-free handling of realloc failures.
modules/codec/omxil/omxil.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 71b1716..a9472a2 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -992,6 +992,16 @@ static OMX_ERRORTYPE PortReconfigure(decoder_t *p_dec, OmxPort *p_port)
CHECK_ERROR(omx_error, "ONX_CommandPortEnable on %i failed (%x)",
(int)p_port->i_port_index, omx_error );
+ if (p_port->definition.nBufferCountActual > p_port->i_buffers) {
+ free(p_port->pp_buffers);
+ p_port->pp_buffers = malloc(p_port->definition.nBufferCountActual * sizeof(OMX_BUFFERHEADERTYPE*));
+ if(!p_port->pp_buffers)
+ {
+ omx_error = OMX_ErrorInsufficientResources;
+ CHECK_ERROR(omx_error, "memory allocation failed");
+ }
+ }
+ p_port->i_buffers = p_port->definition.nBufferCountActual;
for(i = 0; i < p_port->i_buffers; i++)
{
if(0 && p_port->b_direct)
--
1.7.2.5
More information about the vlc-devel
mailing list