Commit c18a4bae authored by Martin Storsjö's avatar Martin Storsjö Committed by 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: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent e47ff3ff
...@@ -628,8 +628,15 @@ static OMX_ERRORTYPE DeinitialiseComponent(decoder_t *p_dec, ...@@ -628,8 +628,15 @@ static OMX_ERRORTYPE DeinitialiseComponent(decoder_t *p_dec,
omx_error = OMX_SendCommand( omx_handle, OMX_CommandStateSet, omx_error = OMX_SendCommand( omx_handle, OMX_CommandStateSet,
OMX_StateIdle, 0 ); OMX_StateIdle, 0 );
CHECK_ERROR(omx_error, "OMX_CommandStateSet Idle failed (%x)", omx_error ); CHECK_ERROR(omx_error, "OMX_CommandStateSet Idle failed (%x)", omx_error );
omx_error = WaitForSpecificOmxEvent(p_dec, OMX_EventCmdComplete, 0, 0, 0); while (1) {
CHECK_ERROR(omx_error, "Wait for Idle failed (%x)", omx_error ); 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); omx_error = OMX_GetState(omx_handle, &state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment