OSDN Git Service

RIO-7791: Fix for deadlock between player engine and OMX component threads caused...
authorPacketVideo CM <engbuild@pv.com>
Thu, 15 Apr 2010 20:34:33 +0000 (13:34 -0700)
committerPacketVideo CM <engbuild@pv.com>
Thu, 15 Apr 2010 20:34:33 +0000 (13:34 -0700)
Change-Id: I8f98f2486f39c6902ab2ff3fa642d033fb2e9a07

engines/2way/src/pv_2way_sdkinfo.h
engines/author/src/pv_author_sdkinfo.h
engines/player/src/pv_player_sdkinfo.h
nodes/pvomxaudiodecnode/src/pvmf_omx_audiodec_node.cpp
nodes/pvomxencnode/src/pvmf_omx_enc_node.cpp
nodes/pvomxvideodecnode/src/pvmf_omx_videodec_node.cpp

index faf11a4..7ff4724 100644 (file)
@@ -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
index bb9e002..2922ba1 100644 (file)
@@ -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
index 664c046..92ebd8f 100644 (file)
@@ -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
index 96ac93a..145cfa2 100644 (file)
@@ -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))
         {
index 5669f4c..bbf0a94 100644 (file)
@@ -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)
index fc5d214..6f7edb9 100644 (file)
@@ -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);