[vlc-commits] omxil: Wait for the right event when deinitializing

Martin Storsjö git at videolan.org
Wed Jan 30 15:37:57 CET 2013


vlc | branch: master | Martin Storsjö <martin at martin.st> | Tue Jan 29 17:55:09 2013 +0200| [c18a4bae88f98539c49c7e16b40d278a5db2727b] | committer: Jean-Baptiste Kempf

omxil: Wait for the right event when deinitializing

Previously, we checked that the event queue had an OMX_EventCmdComplete
item, but we didn't make sure that it was for the previously issued
OMX_CommandStateSet. In many cases, it was from a OMX_CommandFlush,
which made the code proceed with other deinitialization. If the decoder
hadn't actually transitioned to idle state yet, the buffers weren't
actually ever freed (in the state == OMX_StateIdle block), which lead
to crashes when the handle was freed at the end.

This fixes crashes when finishing playback of wmv3 videos on Galaxy S3.

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

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

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

diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index 31038eb..a69b41f 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -628,8 +628,15 @@ static OMX_ERRORTYPE DeinitialiseComponent(decoder_t *p_dec,
         omx_error = OMX_SendCommand( omx_handle, OMX_CommandStateSet,
                                      OMX_StateIdle, 0 );
         CHECK_ERROR(omx_error, "OMX_CommandStateSet Idle failed (%x)", omx_error );
-        omx_error = WaitForSpecificOmxEvent(p_dec, OMX_EventCmdComplete, 0, 0, 0);
-        CHECK_ERROR(omx_error, "Wait for Idle failed (%x)", omx_error );
+        while (1) {
+            OMX_U32 cmd, state;
+            omx_error = WaitForSpecificOmxEvent(p_dec, OMX_EventCmdComplete, &cmd, &state, 0);
+            CHECK_ERROR(omx_error, "Wait for Idle failed (%x)", omx_error );
+            // The event queue can contain other OMX_EventCmdComplete items,
+            // such as for OMX_CommandFlush
+            if (cmd == OMX_CommandStateSet && state == OMX_StateIdle)
+                break;
+        }
     }
 
     omx_error = OMX_GetState(omx_handle, &state);



More information about the vlc-commits mailing list