[vlc-commits] omxil: Push a dummy buffer on the input buffer fifo to avoid deadlocks

Martin Storsjö git at videolan.org
Wed Sep 21 12:36:07 CEST 2011


vlc | branch: master | Martin Storsjö <martin at martin.st> | Wed Sep 21 11:19:07 2011 +0300| [555ba2d1256879b551b60cce579bf4bdbf137061] | committer: Jean-Baptiste Kempf

omxil: Push a dummy buffer on the input buffer fifo to avoid deadlocks

By pushing a sentinel/dummy buffer on the input buffer fifo
when the output needs reconfiguring, we avoid deadlocks on
HTC Sensation, where the input buffers aren't returned to
the caller until the decoder has been reconfigured.

Since all input buffers can be used up before the reconfigure event
is received, this earlier led to a deadlock where the decoder
waited for the caller to reconfigure it (as a response to the
reconfigure event), while the caller waited for an input buffer
to be freed to put the next input packet into.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/codec/omxil/omxil.c |    8 ++++++++
 modules/codec/omxil/omxil.h |    2 ++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 75bc609..f7f0182 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -1111,6 +1111,10 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
 
     /* Send the input buffer to the component */
     OMX_FIFO_GET(&p_sys->in.fifo, p_header);
+
+    if (p_header && p_header->nFlags & OMX_BUFFERFLAG_EOS)
+        goto reconfig;
+
     if(p_header)
     {
         p_header->nFilledLen = p_block->i_buffer;
@@ -1147,6 +1151,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
         *pp_block = NULL; /* Avoid being fed the same packet again */
     }
 
+reconfig:
     /* Handle the PortSettingsChanged events */
     for(i = 0; i < p_sys->ports; i++)
     {
@@ -1453,6 +1458,9 @@ static OMX_ERRORTYPE OmxEventHandler( OMX_HANDLETYPE omx_handle,
         for(i = 0; i < p_sys->ports; i++)
             if(p_sys->p_ports[i].definition.eDir == OMX_DirOutput)
                 p_sys->p_ports[i].b_reconfigure = true;
+        memset(&p_sys->sentinel_buffer, 0, sizeof(p_sys->sentinel_buffer));
+        p_sys->sentinel_buffer.nFlags = OMX_BUFFERFLAG_EOS;
+        OMX_FIFO_PUT(&p_sys->in.fifo, &p_sys->sentinel_buffer);
         break;
 
     default:
diff --git a/modules/codec/omxil/omxil.h b/modules/codec/omxil/omxil.h
index e4aad8d..eefdeb4 100644
--- a/modules/codec/omxil/omxil.h
+++ b/modules/codec/omxil/omxil.h
@@ -111,4 +111,6 @@ struct decoder_sys_t
     date_t end_date;
 
     int i_nal_size_length; /* Length of the NAL size field for H264 */
+
+    OMX_BUFFERHEADERTYPE sentinel_buffer;
 };



More information about the vlc-commits mailing list