external/opencore
修訂 | 695196cdcf5285c6008c5f9b93200b6a3e8af75c (tree) |
---|---|
時間 | 2010-04-16 05:34:33 |
作者 | PacketVideo CM <engbuild@pv.c...> |
Commiter | PacketVideo CM |
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
@@ -21,7 +21,7 @@ | ||
21 | 21 | // This header file is automatically generated at build-time |
22 | 22 | // *** OFFICIAL RELEASE INFO -- Will not auto update |
23 | 23 | |
24 | -#define PV2WAY_ENGINE_SDKINFO_LABEL "1364347" | |
25 | -#define PV2WAY_ENGINE_SDKINFO_DATE 0x20100407 | |
24 | +#define PV2WAY_ENGINE_SDKINFO_LABEL "1366021" | |
25 | +#define PV2WAY_ENGINE_SDKINFO_DATE 0x20100408 | |
26 | 26 | |
27 | 27 | #endif //PV_2WAY_SDKINFO_H_INCLUDED |
@@ -21,7 +21,7 @@ | ||
21 | 21 | // This header file is automatically generated at build-time |
22 | 22 | // *** OFFICIAL RELEASE INFO -- Will not auto update |
23 | 23 | |
24 | -#define PVAUTHOR_ENGINE_SDKINFO_LABEL "1364347" | |
25 | -#define PVAUTHOR_ENGINE_SDKINFO_DATE 0x20100407 | |
24 | +#define PVAUTHOR_ENGINE_SDKINFO_LABEL "1366021" | |
25 | +#define PVAUTHOR_ENGINE_SDKINFO_DATE 0x20100408 | |
26 | 26 | |
27 | 27 | #endif //PV_AUTHOR_SDKINFO_H_INCLUDED |
@@ -21,7 +21,7 @@ | ||
21 | 21 | // This header file is automatically generated at build-time |
22 | 22 | // *** OFFICIAL RELEASE INFO -- Will not auto update |
23 | 23 | |
24 | -#define PVPLAYER_ENGINE_SDKINFO_LABEL "1364347" | |
25 | -#define PVPLAYER_ENGINE_SDKINFO_DATE 0x20100407 | |
24 | +#define PVPLAYER_ENGINE_SDKINFO_LABEL "1366021" | |
25 | +#define PVPLAYER_ENGINE_SDKINFO_DATE 0x20100408 | |
26 | 26 | |
27 | 27 | #endif //PV_PLAYER_SDKINFO_H_INCLUDED |
@@ -610,18 +610,6 @@ PVMFStatus PVMFOMXAudioDecNode::HandlePortReEnable() | ||
610 | 610 | return PVMFErrResource; |
611 | 611 | } |
612 | 612 | |
613 | - // send command for port re-enabling (for this to happen, we must first recreate the buffers) | |
614 | - Err = OMX_SendCommand(iOMXDecoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL); | |
615 | - if (Err != OMX_ErrorNone) | |
616 | - { | |
617 | - PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, | |
618 | - (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> problem sending Port Enable command at port %d", iPortIndexForDynamicReconfig)); | |
619 | - | |
620 | - SetState(EPVMFNodeError); | |
621 | - ReportErrorEvent(PVMFErrResource); | |
622 | - return PVMFErrResource; | |
623 | - } | |
624 | - | |
625 | 613 | |
626 | 614 | // get also input info (for frame duration if necessary) |
627 | 615 | OMX_PTR CodecProfilePtr; |
@@ -738,6 +726,8 @@ PVMFStatus PVMFOMXAudioDecNode::HandlePortReEnable() | ||
738 | 726 | if (iPortIndexForDynamicReconfig == iOutputPortIndex) |
739 | 727 | { |
740 | 728 | |
729 | + uint32 iBeforeConfigNumOutputBuffers = iNumOutputBuffers; | |
730 | + | |
741 | 731 | // GET the output buffer params and sizes |
742 | 732 | OMX_AUDIO_PARAM_PCMMODETYPE Audio_Pcm_Param; |
743 | 733 | Audio_Pcm_Param.nPortIndex = iOutputPortIndex; // we're looking for output port params |
@@ -986,6 +976,40 @@ PVMFStatus PVMFOMXAudioDecNode::HandlePortReEnable() | ||
986 | 976 | ReportInfoEvent(PVMFPvmiBufferAllocatorNotAcquired); |
987 | 977 | } |
988 | 978 | |
979 | + | |
980 | + if (iNumOutputBuffers > iBeforeConfigNumOutputBuffers) | |
981 | + { | |
982 | + //Reallocate FillBufferDone THREADSAFE CALLBACK AOs in case of port reconfiguration | |
983 | + if (iThreadSafeHandlerFillBufferDone) | |
984 | + { | |
985 | + OSCL_DELETE(iThreadSafeHandlerFillBufferDone); | |
986 | + iThreadSafeHandlerFillBufferDone = NULL; | |
987 | + } | |
988 | + // use the new queue depth of iNumOutputBuffers to prevent deadlock | |
989 | + iThreadSafeHandlerFillBufferDone = OSCL_NEW(FillBufferDoneThreadSafeCallbackAO, (this, iNumOutputBuffers, "FillBufferDoneAO", Priority() + 1)); | |
990 | + | |
991 | + if (NULL == iThreadSafeHandlerFillBufferDone) | |
992 | + { | |
993 | + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, | |
994 | + (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> Can't reallocate FillBufferDone threadsafe callback queue!")); | |
995 | + SetState(EPVMFNodeError); | |
996 | + ReportErrorEvent(PVMFErrNoMemory); | |
997 | + return false; | |
998 | + } | |
999 | + } | |
1000 | + | |
1001 | + // send command for port re-enabling (for this to happen, we must first recreate the buffers) | |
1002 | + Err = OMX_SendCommand(iOMXDecoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL); | |
1003 | + if (Err != OMX_ErrorNone) | |
1004 | + { | |
1005 | + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, | |
1006 | + (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> problem sending Port Enable command at port %d", iPortIndexForDynamicReconfig)); | |
1007 | + | |
1008 | + SetState(EPVMFNodeError); | |
1009 | + ReportErrorEvent(PVMFErrResource); | |
1010 | + return PVMFErrResource; | |
1011 | + } | |
1012 | + | |
989 | 1013 | /* Allocate output buffers */ |
990 | 1014 | if (!CreateOutMemPool(iNumOutputBuffers)) |
991 | 1015 | { |
@@ -1029,6 +1053,7 @@ PVMFStatus PVMFOMXAudioDecNode::HandlePortReEnable() | ||
1029 | 1053 | else |
1030 | 1054 | { |
1031 | 1055 | // this is input port |
1056 | + uint32 iBeforeConfigNumInputBuffers = iNumInputBuffers; | |
1032 | 1057 | |
1033 | 1058 | // read the alignment again - just in case |
1034 | 1059 | iInputBufferAlignment = iParamPort.nBufferAlignment; |
@@ -1045,6 +1070,41 @@ PVMFStatus PVMFOMXAudioDecNode::HandlePortReEnable() | ||
1045 | 1070 | PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, |
1046 | 1071 | (0, "PVMFOMXAudioDecNode::HandlePortReEnable() new buffers %d, size %d", iNumInputBuffers, iOMXComponentInputBufferSize)); |
1047 | 1072 | |
1073 | + if (iNumInputBuffers > iBeforeConfigNumInputBuffers) | |
1074 | + { | |
1075 | + //Reallocate EmptyBufferDone THREADSAFE CALLBACK AOs in case of port reconfiguration | |
1076 | + if (iThreadSafeHandlerEmptyBufferDone) | |
1077 | + { | |
1078 | + OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone); | |
1079 | + iThreadSafeHandlerEmptyBufferDone = NULL; | |
1080 | + } | |
1081 | + // use the new queue depth of iNumInputBuffers to prevent deadlock | |
1082 | + iThreadSafeHandlerEmptyBufferDone = OSCL_NEW(EmptyBufferDoneThreadSafeCallbackAO, (this, iNumInputBuffers, "EmptyBufferDoneAO", Priority() + 1)); | |
1083 | + | |
1084 | + if (NULL == iThreadSafeHandlerEmptyBufferDone) | |
1085 | + { | |
1086 | + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, | |
1087 | + (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> Can't reallocate EmptyBufferDone threadsafe callback queue!")); | |
1088 | + SetState(EPVMFNodeError); | |
1089 | + ReportErrorEvent(PVMFErrNoMemory); | |
1090 | + return false; | |
1091 | + } | |
1092 | + } | |
1093 | + | |
1094 | + | |
1095 | + // send command for port re-enabling (for this to happen, we must first recreate the buffers) | |
1096 | + Err = OMX_SendCommand(iOMXDecoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL); | |
1097 | + if (Err != OMX_ErrorNone) | |
1098 | + { | |
1099 | + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, | |
1100 | + (0, "PVMFOMXAudioDecNode::HandlePortReEnable() Port Reconfiguration -> problem sending Port Enable command at port %d", iPortIndexForDynamicReconfig)); | |
1101 | + | |
1102 | + SetState(EPVMFNodeError); | |
1103 | + ReportErrorEvent(PVMFErrResource); | |
1104 | + return PVMFErrResource; | |
1105 | + } | |
1106 | + | |
1107 | + | |
1048 | 1108 | /* Allocate input buffers */ |
1049 | 1109 | if (!CreateInputMemPool(iNumInputBuffers)) |
1050 | 1110 | { |
@@ -1637,6 +1637,8 @@ PVMFStatus PVMFOMXEncNode::HandleProcessingState() | ||
1637 | 1637 | // is this output port? |
1638 | 1638 | if (iPortIndexForDynamicReconfig == iOutputPortIndex) |
1639 | 1639 | { |
1640 | + uint32 iBeforeConfigNumOutputBuffers = iNumOutputBuffers; | |
1641 | + | |
1640 | 1642 | // check the new buffer size |
1641 | 1643 | iOMXComponentOutputBufferSize = iParamPort.nBufferSize; |
1642 | 1644 |
@@ -1673,6 +1675,27 @@ PVMFStatus PVMFOMXEncNode::HandleProcessingState() | ||
1673 | 1675 | return PVMFFailure; |
1674 | 1676 | } |
1675 | 1677 | |
1678 | + if (iNumOutputBuffers > iBeforeConfigNumOutputBuffers) | |
1679 | + { | |
1680 | + //Reallocate FillBufferDone THREADSAFE CALLBACK AOs in case of port reconfiguration | |
1681 | + if (iThreadSafeHandlerFillBufferDone) | |
1682 | + { | |
1683 | + OSCL_DELETE(iThreadSafeHandlerFillBufferDone); | |
1684 | + iThreadSafeHandlerFillBufferDone = NULL; | |
1685 | + } | |
1686 | + // use the new queue depth of iNumOutputBuffers to prevent deadlock | |
1687 | + iThreadSafeHandlerFillBufferDone = OSCL_NEW(FillBufferDoneThreadSafeCallbackAOEnc, (this, iNumOutputBuffers, "FillBufferDoneAO", Priority() + 1)); | |
1688 | + | |
1689 | + if (NULL == iThreadSafeHandlerFillBufferDone) | |
1690 | + { | |
1691 | + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, | |
1692 | + (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration ->Can't reallocate FillBufferDone threadsafe callback queue!", iNodeTypeId)); | |
1693 | + SetState(EPVMFNodeError); | |
1694 | + ReportErrorEvent(PVMFErrNoMemory); | |
1695 | + return false; | |
1696 | + } | |
1697 | + } | |
1698 | + | |
1676 | 1699 | // send command for port re-enabling (for this to happen, we must first recreate the buffers) |
1677 | 1700 | Err = OMX_SendCommand(iOMXEncoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL); |
1678 | 1701 | if (OMX_ErrorNone != Err) |
@@ -1723,6 +1746,8 @@ PVMFStatus PVMFOMXEncNode::HandleProcessingState() | ||
1723 | 1746 | { |
1724 | 1747 | |
1725 | 1748 | // this is input port |
1749 | + uint32 iBeforeConfigNumInputBuffers = iNumInputBuffers; | |
1750 | + | |
1726 | 1751 | // read the input port buffer alignment requirement |
1727 | 1752 | iInputBufferAlignment = iParamPort.nBufferAlignment; |
1728 | 1753 | iOMXComponentInputBufferSize = iParamPort.nBufferSize; |
@@ -1759,6 +1784,27 @@ PVMFStatus PVMFOMXEncNode::HandleProcessingState() | ||
1759 | 1784 | return PVMFFailure; |
1760 | 1785 | } |
1761 | 1786 | |
1787 | + if (iNumInputBuffers > iBeforeConfigNumInputBuffers) | |
1788 | + { | |
1789 | + //Reallocate EmptyBufferDone THREADSAFE CALLBACK AOs in case of port reconfiguration | |
1790 | + if (iThreadSafeHandlerEmptyBufferDone) | |
1791 | + { | |
1792 | + OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone); | |
1793 | + iThreadSafeHandlerEmptyBufferDone = NULL; | |
1794 | + } | |
1795 | + // use the new queue depth of iNumInputBuffers to prevent deadlock | |
1796 | + iThreadSafeHandlerEmptyBufferDone = OSCL_NEW(EmptyBufferDoneThreadSafeCallbackAOEnc, (this, iNumInputBuffers, "EmptyBufferDoneAO", Priority() + 1)); | |
1797 | + | |
1798 | + if (NULL == iThreadSafeHandlerEmptyBufferDone) | |
1799 | + { | |
1800 | + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, | |
1801 | + (0, "PVMFOMXEncNode-%s::HandleProcessingState() Port Reconfiguration -> Can't reallocate EmptyBufferDone threadsafe callback queue!", iNodeTypeId)); | |
1802 | + SetState(EPVMFNodeError); | |
1803 | + ReportErrorEvent(PVMFErrNoMemory); | |
1804 | + return false; | |
1805 | + } | |
1806 | + } | |
1807 | + | |
1762 | 1808 | // send command for port re-enabling (for this to happen, we must first recreate the buffers) |
1763 | 1809 | Err = OMX_SendCommand(iOMXEncoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL); |
1764 | 1810 | if (OMX_ErrorNone != Err) |
@@ -186,6 +186,7 @@ PVMFStatus PVMFOMXVideoDecNode::HandlePortReEnable() | ||
186 | 186 | // is this output port? |
187 | 187 | if (iPortIndexForDynamicReconfig == iOutputPortIndex) |
188 | 188 | { |
189 | + uint32 iBeforeConfigNumOutputBuffers = iNumOutputBuffers; | |
189 | 190 | |
190 | 191 | // read the alignment |
191 | 192 | iOutputBufferAlignment = iParamPort.nBufferAlignment; |
@@ -421,6 +422,28 @@ PVMFStatus PVMFOMXVideoDecNode::HandlePortReEnable() | ||
421 | 422 | |
422 | 423 | } |
423 | 424 | |
425 | + | |
426 | + if (iNumOutputBuffers > iBeforeConfigNumOutputBuffers) | |
427 | + { | |
428 | + //Reallocate FillBufferDone THREADSAFE CALLBACK AOs in case of port reconfiguration | |
429 | + if (iThreadSafeHandlerFillBufferDone) | |
430 | + { | |
431 | + OSCL_DELETE(iThreadSafeHandlerFillBufferDone); | |
432 | + iThreadSafeHandlerFillBufferDone = NULL; | |
433 | + } | |
434 | + // use the new queue depth of iNumOutputBuffers to prevent deadlock | |
435 | + iThreadSafeHandlerFillBufferDone = OSCL_NEW(FillBufferDoneThreadSafeCallbackAO, (this, iNumOutputBuffers, "FillBufferDoneAO", Priority() + 1)); | |
436 | + | |
437 | + if (NULL == iThreadSafeHandlerFillBufferDone) | |
438 | + { | |
439 | + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, | |
440 | + (0, "PVMFOMXVideoDecNode::HandlePortReEnable() Can't reallocate FillBufferDone threadsafe callback queue!")); | |
441 | + SetState(EPVMFNodeError); | |
442 | + ReportErrorEvent(PVMFErrNoMemory); | |
443 | + return false; | |
444 | + } | |
445 | + } | |
446 | + | |
424 | 447 | // it is now safe to send command for port reenable |
425 | 448 | // send command for port re-enabling (for this to happen, we must first recreate the buffers) |
426 | 449 | Err = OMX_SendCommand(iOMXDecoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL); |
@@ -474,6 +497,8 @@ PVMFStatus PVMFOMXVideoDecNode::HandlePortReEnable() | ||
474 | 497 | } |
475 | 498 | else |
476 | 499 | { |
500 | + uint32 iBeforeConfigNumInputBuffers = iNumInputBuffers; | |
501 | + | |
477 | 502 | // read the alignment |
478 | 503 | iInputBufferAlignment = iParamPort.nBufferAlignment; |
479 | 504 |
@@ -503,6 +528,28 @@ PVMFStatus PVMFOMXVideoDecNode::HandlePortReEnable() | ||
503 | 528 | ReportErrorEvent(PVMFErrNoMemory); |
504 | 529 | return false; |
505 | 530 | } |
531 | + | |
532 | + if (iNumInputBuffers > iBeforeConfigNumInputBuffers) | |
533 | + { | |
534 | + //Reallocate EmptyBufferDone THREADSAFE CALLBACK AOs in case of port reconfiguration | |
535 | + if (iThreadSafeHandlerEmptyBufferDone) | |
536 | + { | |
537 | + OSCL_DELETE(iThreadSafeHandlerEmptyBufferDone); | |
538 | + iThreadSafeHandlerEmptyBufferDone = NULL; | |
539 | + } | |
540 | + // use the new queue depth of iNumInputBuffers to prevent deadlock | |
541 | + iThreadSafeHandlerEmptyBufferDone = OSCL_NEW(EmptyBufferDoneThreadSafeCallbackAO, (this, iNumInputBuffers, "EmptyBufferDoneAO", Priority() + 1)); | |
542 | + | |
543 | + if (NULL == iThreadSafeHandlerEmptyBufferDone) | |
544 | + { | |
545 | + PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_ERR, | |
546 | + (0, "PVMFOMXVideoDecNode::HandlePortReEnable() Can't reallocate EmptyBufferDone threadsafe callback queue!")); | |
547 | + SetState(EPVMFNodeError); | |
548 | + ReportErrorEvent(PVMFErrNoMemory); | |
549 | + return false; | |
550 | + } | |
551 | + } | |
552 | + | |
506 | 553 | // it is now safe to send command for port reenable |
507 | 554 | // send command for port re-enabling (for this to happen, we must first recreate the buffers) |
508 | 555 | Err = OMX_SendCommand(iOMXDecoder, OMX_CommandPortEnable, iPortIndexForDynamicReconfig, NULL); |