[vlc-commits] omxil: Make sure i_channels is nonzero before dividing by it

Martin Storsjö git at videolan.org
Sat Feb 2 14:59:45 CET 2013


vlc | branch: master | Martin Storsjö <martin at martin.st> | Fri Feb  1 12:53:22 2013 +0200| [fab34784a588febf0f74afb45a69c374085c5f2c] | committer: Martin Storsjö

omxil: Make sure i_channels is nonzero before dividing by it

At startup of the decoder, i_channels might be set to 0 if the decoder
hasn't processed the sent CODECCONFIG data yet. (In these cases, the
returned buffers are 0 bytes long so we don't miss anything either.)
A port reconfigure event is sent in these cases, so i_channels gets
initialized to the right value before we handle any later buffers with
actual content.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fab34784a588febf0f74afb45a69c374085c5f2c
---

 modules/codec/omxil/omxil.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index c15197a..b0d423b 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -1513,12 +1513,13 @@ block_t *DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
     /* Take care of decoded frames first */
     while(!p_buffer)
     {
-        unsigned int i_samples;
+        unsigned int i_samples = 0;
 
         OMX_FIFO_PEEK(&p_sys->out.fifo, p_header);
         if(!p_header) break; /* No frame available */
 
-        i_samples = p_header->nFilledLen / p_sys->out.p_fmt->audio.i_channels / 2;
+        if (p_sys->out.p_fmt->audio.i_channels)
+            i_samples = p_header->nFilledLen / p_sys->out.p_fmt->audio.i_channels / 2;
         if(i_samples)
         {
             p_buffer = decoder_NewAudioBuffer( p_dec, i_samples );



More information about the vlc-commits mailing list