From: PacketVideo CM Date: Thu, 15 Apr 2010 20:34:33 +0000 (-0700) Subject: RIO-7791: Fix for deadlock between player engine and OMX component threads caused... X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=695196cdcf5285c6008c5f9b93200b6a3e8af75c;p=android-x86%2Fexternal-opencore.git RIO-7791: Fix for deadlock between player engine and OMX component threads caused by a mismatched queue depth and number of new output AVC buffers during port reconfiguration Change-Id: I8f98f2486f39c6902ab2ff3fa642d033fb2e9a07 --- diff --git a/engines/2way/src/pv_2way_sdkinfo.h b/engines/2way/src/pv_2way_sdkinfo.h index faf11a40..7ff47249 100644 --- a/engines/2way/src/pv_2way_sdkinfo.h +++ b/engines/2way/src/pv_2way_sdkinfo.h @@ -21,7 +21,7 @@ // This header file is automatically generated at build-time // *** OFFICIAL RELEASE INFO -- Will not auto update -#define PV2WAY_ENGINE_SDKINFO_LABEL "1364347" -#define PV2WAY_ENGINE_SDKINFO_DATE 0x20100407 +#define PV2WAY_ENGINE_SDKINFO_LABEL "1366021" +#define PV2WAY_ENGINE_SDKINFO_DATE 0x20100408 #endif //PV_2WAY_SDKINFO_H_INCLUDED diff --git a/engines/author/src/pv_author_sdkinfo.h b/engines/author/src/pv_author_sdkinfo.h index bb9e0025..2922ba17 100644 --- a/engines/author/src/pv_author_sdkinfo.h +++ b/engines/author/src/pv_author_sdkinfo.h @@ -21,7 +21,7 @@ // This header file is automatically generated at build-time // *** OFFICIAL RELEASE INFO -- Will not auto update -#define PVAUTHOR_ENGINE_SDKINFO_LABEL "1364347" -#define PVAUTHOR_ENGINE_SDKINFO_DATE 0x20100407 +#define PVAUTHOR_ENGINE_SDKINFO_LABEL "1366021" +#define PVAUTHOR_ENGINE_SDKINFO_DATE 0x20100408 #endif //PV_AUTHOR_SDKINFO_H_INCLUDED diff --git a/engines/player/src/pv_player_sdkinfo.h b/engines/player/src/pv_player_sdkinfo.h index 664c0466..92ebd8f2 100644 --- a/engines/player/src/pv_player_sdkinfo.h +++ b/engines/player/src/pv_player_sdkinfo.h @@ -21,7 +21,7 @@ // This header file is automatically generated at build-time // *** OFFICIAL RELEASE INFO -- Will not auto update -#define PVPLAYER_ENGINE_SDKINFO_LABEL "1364347" -#define PVPLAYER_ENGINE_SDKINFO_DATE 0x20100407 +#define PVPLAYER_ENGINE_SDKINFO_LABEL "1366021" +#define PVPLAYER_ENGINE_SDKINFO_DATE 0x20100408 #endif //PV_PLAYER_SDKINFO_H_INCLUDED diff --git a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.cpp b/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.cpp index 96ac93a3..145cfa23 100644 --- a/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.cpp +++ b/nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.cpp @@ -610,18 +610,6 @@ PVMFStatus PVMFOMXAudioDecNode::HandlePortReEnable() return PVMFErrResource; } - // send command for port re-enabling (for this to happen, we must first recreate the buffers) - Err = OMX_SendCommand(iOMXDecoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL); - if (Err != OMX_ErrorNone) - { - PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, - (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> problem sending Port Enable command at port %d", iPortIndexForDynamicReconfig)); - - SetState(EPVMFNodeError); - ReportErrorEvent(PVMFErrResource); - return PVMFErrResource; - } - // get also input info (for frame duration if necessary) OMX_PTR CodecProfilePtr; @@ -738,6 +726,8 @@ PVMFStatus PVMFOMXAudioDecNode::HandlePortReEnable() if (iPortIndexForDynamicReconfig == iOutputPortIndex) { + uint32 iBeforeConfigNumOutputBuffers = iNumOutputBuffers; + // GET the output buffer params and sizes OMX_AUDIO_PARAM_PCMMODETYPE Audio_Pcm_Param; Audio_Pcm_Param.nPortIndex = iOutputPortIndex; // we're looking for output port params @@ -986,6 +976,40 @@ PVMFStatus PVMFOMXAudioDecNode::HandlePortReEnable() ReportInfoEvent(PVMFPvmiBufferAllocatorNotAcquired); } + + if (iNumOutputBuffers > iBeforeConfigNumOutputBuffers) + { + //Reallocate FillBufferDone THREADSAFE CALLBACK AOs in case of port reconfiguration + if (iThreadSafeHandlerFillBufferDone) + { + OSCL_DELETE(iThreadSafeHandlerFillBufferDone); + iThreadSafeHandlerFillBufferDone = NULL; + } + // use the new queue depth of iNumOutputBuffers to prevent deadlock + iThreadSafeHandlerFillBufferDone = OSCL_NEW(FillBufferDoneThreadSafeCallbackAO, (this, iNumOutputBuffers, "FillBufferDoneAO", Priority() + 1)); + + if (NULL == iThreadSafeHandlerFillBufferDone) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, + (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> Can't reallocate FillBufferDone threadsafe callback queue!")); + SetState(EPVMFNodeError); + ReportErrorEvent(PVMFErrNoMemory); + return false; + } + } + + // send command for port re-enabling (for this to happen, we must first recreate the buffers) + Err = OMX_SendCommand(iOMXDecoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL); + if (Err != OMX_ErrorNone) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, + (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> problem sending Port Enable command at port %d", iPortIndexForDynamicReconfig)); + + SetState(EPVMFNodeError); + ReportErrorEvent(PVMFErrResource); + return PVMFErrResource; + } + /* Allocate output buffers */ if (!CreateOutMemPool(iNumOutputBuffers)) { @@ -1029,6 +1053,7 @@ PVMFStatus PVMFOMXAudioDecNode::HandlePortReEnable() else { // this is input port + uint32 iBeforeConfigNumInputBuffers = iNumInputBuffers; // read the alignment again - just in case iInputBufferAlignment = iParamPort.nBufferAlignment; @@ -1045,6 +1070,41 @@ PVMFStatus PVMFOMXAudioDecNode::HandlePortReEnable() PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVMFOMXAudioDecNode::HandlePortReEnable() new buffers %d, size %d", iNumInputBuffers, iOMXComponentInputBufferSize)); + if (iNumInputBuffers > iBeforeConfigNumInputBuffers) + { + //Reallocate EmptyBufferDone THREADSAFE CALLBACK AOs in case of port reconfiguration + if (iThreadSafeHandlerEmptyBufferDone) + { + OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone); + iThreadSafeHandlerEmptyBufferDone = NULL; + } + // use the new queue depth of iNumInputBuffers to prevent deadlock + iThreadSafeHandlerEmptyBufferDone = OSCL_NEW(EmptyBufferDoneThreadSafeCallbackAO, (this, iNumInputBuffers, "EmptyBufferDoneAO", Priority() + 1)); + + if (NULL == iThreadSafeHandlerEmptyBufferDone) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, + (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> Can't reallocate EmptyBufferDone threadsafe callback queue!")); + SetState(EPVMFNodeError); + ReportErrorEvent(PVMFErrNoMemory); + return false; + } + } + + + // send command for port re-enabling (for this to happen, we must first recreate the buffers) + Err = OMX_SendCommand(iOMXDecoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL); + if (Err != OMX_ErrorNone) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, + (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> problem sending Port Enable command at port %d", iPortIndexForDynamicReconfig)); + + SetState(EPVMFNodeError); + ReportErrorEvent(PVMFErrResource); + return PVMFErrResource; + } + + /* Allocate input buffers */ if (!CreateInputMemPool(iNumInputBuffers)) { diff --git a/nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp b/nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp index 5669f4cf..bbf0a944 100644 --- a/nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp +++ b/nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp @@ -1637,6 +1637,8 @@ PVMFStatus PVMFOMXEncNode::HandleProcessingState() // is this output port? if (iPortIndexForDynamicReconfig == iOutputPortIndex) { + uint32 iBeforeConfigNumOutputBuffers = iNumOutputBuffers; + // check the new buffer size iOMXComponentOutputBufferSize = iParamPort.nBufferSize; @@ -1673,6 +1675,27 @@ PVMFStatus PVMFOMXEncNode::HandleProcessingState() return PVMFFailure; } + if (iNumOutputBuffers > iBeforeConfigNumOutputBuffers) + { + //Reallocate FillBufferDone THREADSAFE CALLBACK AOs in case of port reconfiguration + if (iThreadSafeHandlerFillBufferDone) + { + OSCL_DELETE(iThreadSafeHandlerFillBufferDone); + iThreadSafeHandlerFillBufferDone = NULL; + } + // use the new queue depth of iNumOutputBuffers to prevent deadlock + iThreadSafeHandlerFillBufferDone = OSCL_NEW(FillBufferDoneThreadSafeCallbackAOEnc, (this, iNumOutputBuffers, "FillBufferDoneAO", Priority() + 1)); + + if (NULL == iThreadSafeHandlerFillBufferDone) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, + (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration ->Can't reallocate FillBufferDone threadsafe callback queue!", iNodeTypeId)); + SetState(EPVMFNodeError); + ReportErrorEvent(PVMFErrNoMemory); + return false; + } + } + // send command for port re-enabling (for this to happen, we must first recreate the buffers) Err = OMX_SendCommand(iOMXEncoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL); if (OMX_ErrorNone != Err) @@ -1723,6 +1746,8 @@ PVMFStatus PVMFOMXEncNode::HandleProcessingState() { // this is input port + uint32 iBeforeConfigNumInputBuffers = iNumInputBuffers; + // read the input port buffer alignment requirement iInputBufferAlignment = iParamPort.nBufferAlignment; iOMXComponentInputBufferSize = iParamPort.nBufferSize; @@ -1759,6 +1784,27 @@ PVMFStatus PVMFOMXEncNode::HandleProcessingState() return PVMFFailure; } + if (iNumInputBuffers > iBeforeConfigNumInputBuffers) + { + //Reallocate EmptyBufferDone THREADSAFE CALLBACK AOs in case of port reconfiguration + if (iThreadSafeHandlerEmptyBufferDone) + { + OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone); + iThreadSafeHandlerEmptyBufferDone = NULL; + } + // use the new queue depth of iNumInputBuffers to prevent deadlock + iThreadSafeHandlerEmptyBufferDone = OSCL_NEW(EmptyBufferDoneThreadSafeCallbackAOEnc, (this, iNumInputBuffers, "EmptyBufferDoneAO", Priority() + 1)); + + if (NULL == iThreadSafeHandlerEmptyBufferDone) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, + (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration -> Can't reallocate EmptyBufferDone threadsafe callback queue!", iNodeTypeId)); + SetState(EPVMFNodeError); + ReportErrorEvent(PVMFErrNoMemory); + return false; + } + } + // send command for port re-enabling (for this to happen, we must first recreate the buffers) Err = OMX_SendCommand(iOMXEncoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL); if (OMX_ErrorNone != Err) diff --git a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_node.cpp b/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_node.cpp index fc5d2141..6f7edb9d 100644 --- a/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_node.cpp +++ b/nodes/pvomxvideodecnode/src/pvmf_omx_videodec_node.cpp @@ -186,6 +186,7 @@ PVMFStatus PVMFOMXVideoDecNode::HandlePortReEnable() // is this output port? if (iPortIndexForDynamicReconfig == iOutputPortIndex) { + uint32 iBeforeConfigNumOutputBuffers = iNumOutputBuffers; // read the alignment iOutputBufferAlignment = iParamPort.nBufferAlignment; @@ -421,6 +422,28 @@ PVMFStatus PVMFOMXVideoDecNode::HandlePortReEnable() } + + if (iNumOutputBuffers > iBeforeConfigNumOutputBuffers) + { + //Reallocate FillBufferDone THREADSAFE CALLBACK AOs in case of port reconfiguration + if (iThreadSafeHandlerFillBufferDone) + { + OSCL_DELETE(iThreadSafeHandlerFillBufferDone); + iThreadSafeHandlerFillBufferDone = NULL; + } + // use the new queue depth of iNumOutputBuffers to prevent deadlock + iThreadSafeHandlerFillBufferDone = OSCL_NEW(FillBufferDoneThreadSafeCallbackAO, (this, iNumOutputBuffers, "FillBufferDoneAO", Priority() + 1)); + + if (NULL == iThreadSafeHandlerFillBufferDone) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, + (0, "PVMFOMXVideoDecNode::HandlePortReEnable() Can't reallocate FillBufferDone threadsafe callback queue!")); + SetState(EPVMFNodeError); + ReportErrorEvent(PVMFErrNoMemory); + return false; + } + } + // it is now safe to send command for port reenable // send command for port re-enabling (for this to happen, we must first recreate the buffers) Err = OMX_SendCommand(iOMXDecoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL); @@ -474,6 +497,8 @@ PVMFStatus PVMFOMXVideoDecNode::HandlePortReEnable() } else { + uint32 iBeforeConfigNumInputBuffers = iNumInputBuffers; + // read the alignment iInputBufferAlignment = iParamPort.nBufferAlignment; @@ -503,6 +528,28 @@ PVMFStatus PVMFOMXVideoDecNode::HandlePortReEnable() ReportErrorEvent(PVMFErrNoMemory); return false; } + + if (iNumInputBuffers > iBeforeConfigNumInputBuffers) + { + //Reallocate EmptyBufferDone THREADSAFE CALLBACK AOs in case of port reconfiguration + if (iThreadSafeHandlerEmptyBufferDone) + { + OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone); + iThreadSafeHandlerEmptyBufferDone = NULL; + } + // use the new queue depth of iNumInputBuffers to prevent deadlock + iThreadSafeHandlerEmptyBufferDone = OSCL_NEW(EmptyBufferDoneThreadSafeCallbackAO, (this, iNumInputBuffers, "EmptyBufferDoneAO", Priority() + 1)); + + if (NULL == iThreadSafeHandlerEmptyBufferDone) + { + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, + (0, "PVMFOMXVideoDecNode::HandlePortReEnable() Can't reallocate EmptyBufferDone threadsafe callback queue!")); + SetState(EPVMFNodeError); + ReportErrorEvent(PVMFErrNoMemory); + return false; + } + } + // it is now safe to send command for port reenable // send command for port re-enabling (for this to happen, we must first recreate the buffers) Err = OMX_SendCommand(iOMXDecoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL);