omxil_generic/omxilcomplib/src/omxilportmanager.cpp
changeset 5 fb6faddbb212
parent 0 0e4a32b9112d
equal deleted inserted replaced
2:6add9366d894 5:fb6faddbb212
   651 COmxILPortManager::SetConfig(OMX_INDEXTYPE aConfigIndex,
   651 COmxILPortManager::SetConfig(OMX_INDEXTYPE aConfigIndex,
   652 							 const TAny* apComponentConfigStructure)
   652 							 const TAny* apComponentConfigStructure)
   653 	{
   653 	{
   654 	DEBUG_PRINTF(_L8("COmxILPortManager::SetConfig"));
   654 	DEBUG_PRINTF(_L8("COmxILPortManager::SetConfig"));
   655 
   655 
   656 #ifdef _OMXIL_COMMON_IL516C_ON
       
   657 
       
   658 	if (OMX_IndexConfigPortBufferReturnRequest == aConfigIndex)
       
   659 		{
       
   660 		OMX_U32 portIndex;
       
   661 		if (OMX_ErrorNone != GetPortIndexFromOmxStruct(
       
   662 				apComponentConfigStructure,
       
   663 				portIndex))
       
   664 			{
       
   665 			return OMX_ErrorBadPortIndex;
       
   666 			}
       
   667 		DEBUG_PRINTF2(_L8("COmxILPortManager::SetConfig : PORT[%u] OMX_IndexConfigPortBufferReturnRequest"), portIndex);
       
   668 
       
   669 		// Check the index of the port..
       
   670 		if ((OMX_ALL != portIndex) &&
       
   671 			(CheckPortIndex(portIndex) != OMX_ErrorNone))
       
   672 			{
       
   673 			return OMX_ErrorBadPortIndex;
       
   674 			}
       
   675 
       
   676 		// This error will be ignored...
       
   677 		OMX_ERRORTYPE omxRetValue = OMX_ErrorNone;
       
   678 		if (portIndex != OMX_ALL)
       
   679 			{
       
   680 			omxRetValue = BufferEjectIndication(portIndex);
       
   681 			}
       
   682 		else
       
   683 			{
       
   684 			const TInt portCount = iAllPorts.Count();
       
   685 
       
   686 			for (TUint i = 0; i< portCount; ++i)
       
   687 				{
       
   688 				omxRetValue = BufferEjectIndication(iAllPorts[i]->Index());
       
   689 				}
       
   690 			}
       
   691 
       
   692 		return OMX_ErrorNone;
       
   693 
       
   694 		}
       
   695 #endif
       
   696 
       
   697 	TInt index = FindConfigIndex(aConfigIndex);
   656 	TInt index = FindConfigIndex(aConfigIndex);
   698 	if (KErrNotFound == index)
   657 	if (KErrNotFound == index)
   699 		{
   658 		{
   700 		return OMX_ErrorUnsupportedIndex;
   659 		return OMX_ErrorUnsupportedIndex;
   701 		}
   660 		}
   773 		}
   732 		}
   774 
   733 
   775 	// Grab the port here...
   734 	// Grab the port here...
   776 	COmxILPort* pPort = iAllPorts[aPortIndex];
   735 	COmxILPort* pPort = iAllPorts[aPortIndex];
   777 
   736 
   778 #ifdef _OMXIL_COMMON_IL516C_ON
       
   779 	if (!apBuffer)
       
   780 		{
       
   781 		// Basically, if OMX_UseBuffer is used, the port must not be populated
       
   782 		// at this point, otherwise it is an error...
       
   783 		if (pPort->IsPopulated())
       
   784 			{
       
   785 			return OMX_ErrorIncorrectStateOperation;
       
   786 			}
       
   787 		}
       
   788 	else
       
   789 		{
       
   790 		// ... AllocateBuffer... this is only allowed if the the IL Client has
       
   791 		// issued the command to idle already..
       
   792 #endif
       
   793 
       
   794 	if (OMX_TRUE == aPortIsDisabled &&
   737 	if (OMX_TRUE == aPortIsDisabled &&
   795 		pPort->IsEnabled() &&
   738 		pPort->IsEnabled() &&
   796 		!pPort->IsTransitioningToEnabled())
   739 		!pPort->IsTransitioningToEnabled())
   797 		{
   740 		{
   798 		// There is an indication from the FSM that the port must be disabled,
   741 		// There is an indication from the FSM that the port must be disabled,
   799 		// otherwise, the buffer allocation is not allowed in the current
   742 		// otherwise, the buffer allocation is not allowed in the current
   800 		// state. Note that a port may be transitioning to enabled and in that
   743 		// state. Note that a port may be transitioning to enabled and in that
   801 		// case the buffer population must be allowed...
   744 		// case the buffer population must be allowed...
   802 		return OMX_ErrorIncorrectStateOperation;
   745 		return OMX_ErrorIncorrectStateOperation;
   803 		}
   746 		}
   804 
       
   805 #ifdef _OMXIL_COMMON_IL516C_ON
       
   806 		}
       
   807 #endif
       
   808 
   747 
   809 	// Check that in case of tunnelling, this port is not buffer supplier...
   748 	// Check that in case of tunnelling, this port is not buffer supplier...
   810 	if (pPort->IsTunnelledAndBufferSupplier())
   749 	if (pPort->IsTunnelledAndBufferSupplier())
   811 		{
   750 		{
   812 		return OMX_ErrorBadPortIndex;
   751 		return OMX_ErrorBadPortIndex;
  1325 	if (pPort->Direction() != aDirection)
  1264 	if (pPort->Direction() != aDirection)
  1326 		{
  1265 		{
  1327 		return OMX_ErrorBadPortIndex;
  1266 		return OMX_ErrorBadPortIndex;
  1328 		}
  1267 		}
  1329 
  1268 
  1330 #ifdef _OMXIL_COMMON_IL516C_ON
       
  1331 	(void)aPortIsDisabled;
       
  1332 	// Only restriction here is that the port must be populated
       
  1333 	if (!pPort->IsPopulated())
       
  1334 		{
       
  1335 		return OMX_ErrorIncorrectStateOperation;
       
  1336 		}
       
  1337 #endif
       
  1338 
       
  1339 #ifndef _OMXIL_COMMON_IL516C_ON
       
  1340 	if (!pPort->IsEnabled() &&
  1269 	if (!pPort->IsEnabled() &&
  1341 		!pPort->IsTransitioningToDisabled() &&
  1270             !pPort->IsTransitioningToDisabled() &&
  1342 		!pPort->IsTransitioningToEnabled())
  1271             !pPort->IsTransitioningToEnabled())
  1343 		{
  1272             {
  1344 		return OMX_ErrorIncorrectStateOperation;
  1273             return OMX_ErrorIncorrectStateOperation;
  1345 		}
  1274             }
  1346 
  1275 
  1347 	// Check port enabled property...
  1276 	// Check port enabled property...
  1348 	if (OMX_TRUE == aPortIsDisabled &&
  1277 	if (OMX_TRUE == aPortIsDisabled &&
  1349 		pPort->IsEnabled())
  1278             pPort->IsEnabled())
  1350 		{
  1279             {
  1351 		// There is an indication from the FSM that the port must be disabled,
  1280             // There is an indication from the FSM that the port must be disabled,
  1352 		// otherwise, the buffer indication is not allowed in the current
  1281             // otherwise, the buffer indication is not allowed in the current
  1353 		// state.
  1282             // state.
  1354 		return OMX_ErrorIncorrectStateOperation;
  1283             return OMX_ErrorIncorrectStateOperation;
  1355 		}
  1284             }
  1356 
       
  1357 #endif
       
  1358 
  1285 
  1359 	OMX_ERRORTYPE omxRetValue = OMX_ErrorNone;
  1286 	OMX_ERRORTYPE omxRetValue = OMX_ErrorNone;
  1360 	// Check whether this port is a buffer supplier...
  1287 	// Check whether this port is a buffer supplier...
  1361 	if (pPort->IsTunnelledAndBufferSupplier() &&
  1288 	if (pPort->IsTunnelledAndBufferSupplier() &&
  1362 		pPort->IsTransitioningToDisabled())
  1289 		pPort->IsTransitioningToDisabled())
  1400 		// ... we are done.. no need to send the buffer to the
  1327 		// ... we are done.. no need to send the buffer to the
  1401 		// processing function...
  1328 		// processing function...
  1402 		return OMX_ErrorNone;
  1329 		return OMX_ErrorNone;
  1403 
  1330 
  1404 		} // if ((pPort->IsTunnelledAndBufferSupplier() && pPort->IsTransitioningToDisabled())
  1331 		} // if ((pPort->IsTunnelledAndBufferSupplier() && pPort->IsTransitioningToDisabled())
  1405 #ifdef _OMXIL_COMMON_IL516C_ON
       
  1406 	else if (pPort->IsTunnelled() && pPort->IsTransitioningToDisabled())
       
  1407 		{
       
  1408 		// We get here if the port is tunnelled, non-supplier and is currently
       
  1409 		// in the process of transitioning to disabled...  To avoid Race
       
  1410 		// condition #3, we need to check that we've received the request from
       
  1411 		// the supplier to return its buffers... however, we don't check it for
       
  1412 		// now, it is just easier to return the buffer now...
       
  1413 		DEBUG_PRINTF3(_L8("COmxILPortManager::BufferIndication : PORT [%u] BUFFER [%X] : "
       
  1414 						  "WARNING This port is being disabled, "
       
  1415 						  "the buffer id being returned to the tunnelled component"),
       
  1416 						  portIndex, apBufferHeader);
       
  1417 		omxRetValue =
       
  1418 			iCallbacks.BufferDoneNotification(apBufferHeader,
       
  1419 											  portIndex,
       
  1420 											  aDirection);
       
  1421 		// ... we are done..
       
  1422 		return OMX_ErrorNone;
       
  1423 		}
       
  1424 #endif
       
  1425 
       
  1426 
  1332 
  1427 	// Inform the port that one of its buffers is going to be sent to the
  1333 	// Inform the port that one of its buffers is going to be sent to the
  1428 	// processing function (exception applies to OMX_PortDomainOther ports) ... 
  1334 	// processing function (exception applies to OMX_PortDomainOther ports) ... 
  1429 	// The port will also mark this buffer if the port
  1335 	// The port will also mark this buffer if the port
  1430 	// has pending marks to be signalled... The buffer marks are finally
  1336 	// has pending marks to be signalled... The buffer marks are finally
  1690 				if (!RemoveBuffersFromPfOrCm(pPort))
  1596 				if (!RemoveBuffersFromPfOrCm(pPort))
  1691 					{
  1597 					{
  1692 					// This port will have to wait to get some of its buffers
  1598 					// This port will have to wait to get some of its buffers
  1693 					// returned by the tunnelled port...
  1599 					// returned by the tunnelled port...
  1694 					foundBufferSupplierThatNeedsToWait = ETrue;
  1600 					foundBufferSupplierThatNeedsToWait = ETrue;
  1695 #ifdef _OMXIL_COMMON_IL516C_ON
       
  1696 					// Request buffer ejection from the tunnelled component
       
  1697 					iCallbacks.EjectBuffersRequest(pPort->Index());
       
  1698 #endif
       
  1699 					}
  1601 					}
  1700 				continue;
  1602 				continue;
  1701 				}
  1603 				}
  1702 
       
  1703 #ifdef _OMXIL_COMMON_IL516C_ON
       
  1704 			if (!pPort->IsTunnelled())
       
  1705 				{
       
  1706 #endif
       
  1707 
  1604 
  1708 			if (OMX_ErrorNone !=
  1605 			if (OMX_ErrorNone !=
  1709 				(omxRetValue = iProcessingFunction.BufferFlushingIndication(
  1606 				(omxRetValue = iProcessingFunction.BufferFlushingIndication(
  1710 					pPort->Index(),
  1607 					pPort->Index(),
  1711 					pPort->Direction())))
  1608 					pPort->Direction())))
  1712 				{
  1609 				{
  1713 				return omxRetValue;
  1610 				return omxRetValue;
  1714 				}
  1611 				}
  1715 
       
  1716 #ifdef _OMXIL_COMMON_IL516C_ON
       
  1717 				}
       
  1718 #endif
       
  1719 
  1612 
  1720 			}
  1613 			}
  1721 		}
  1614 		}
  1722 
  1615 
  1723 	if (!foundBufferSupplierThatNeedsToWait)
  1616 	if (!foundBufferSupplierThatNeedsToWait)
  1917 				{
  1810 				{
  1918 				// Inform the port that it is being disabled
  1811 				// Inform the port that it is being disabled
  1919 				pPort->SetTransitionToDisabled();
  1812 				pPort->SetTransitionToDisabled();
  1920 				// This port will have to wait to get all its buffers
  1813 				// This port will have to wait to get all its buffers
  1921 				// returned by the tunnelled port...
  1814 				// returned by the tunnelled port...
  1922 #ifdef _OMXIL_COMMON_IL516C_ON
       
  1923 				//... but request the ejection of the buffers first...
       
  1924 				iCallbacks.EjectBuffersRequest(pPort->Index());
       
  1925 #endif
       
  1926 				}
  1815 				}
  1927 			else
  1816 			else
  1928 				{
  1817 				{
  1929 				// Buffer supplier with all buffers at home.. we can
  1818 				// Buffer supplier with all buffers at home.. we can
  1930 				// initiate here the depopulation of the tunnel...
  1819 				// initiate here the depopulation of the tunnel...
  1961 		else
  1850 		else
  1962 			{
  1851 			{
  1963 			if (pPort->Count() > 0)
  1852 			if (pPort->Count() > 0)
  1964 				{
  1853 				{
  1965 
  1854 
  1966 #ifdef _OMXIL_COMMON_IL516C_ON
       
  1967 			if (!pPort->IsTunnelled())
       
  1968 				{
       
  1969 #endif
       
  1970 
       
  1971 				if (OMX_ErrorNone !=
  1855 				if (OMX_ErrorNone !=
  1972 					(omxRetValue =
  1856 					(omxRetValue =
  1973 					 iProcessingFunction.BufferFlushingIndication(
  1857 					 iProcessingFunction.BufferFlushingIndication(
  1974 					portIndex,
  1858 					portIndex,
  1975 					pPort->Direction())))
  1859 					pPort->Direction())))
  1976 					{
  1860 					{
  1977 					return omxRetValue;
  1861 					return omxRetValue;
  1978 					}
  1862 					}
  1979 
       
  1980 #ifdef _OMXIL_COMMON_IL516C_ON
       
  1981 				}
       
  1982 #endif
       
  1983 
  1863 
  1984 				// Inform the port that it is being disabled
  1864 				// Inform the port that it is being disabled
  1985 				pPort->SetTransitionToDisabled();
  1865 				pPort->SetTransitionToDisabled();
  1986 				}
  1866 				}
  1987 			else
  1867 			else
  2036 	// buffer...
  1916 	// buffer...
  2037 	return iAllPorts[aPortIndex]->StoreBufferMark(pMark);
  1917 	return iAllPorts[aPortIndex]->StoreBufferMark(pMark);
  2038 
  1918 
  2039 	}
  1919 	}
  2040 
  1920 
  2041 #ifdef _OMXIL_COMMON_IL516C_ON
       
  2042 OMX_ERRORTYPE
       
  2043 COmxILPortManager::BufferEjectIndication(
       
  2044 	TUint32 aPortIndex)
       
  2045 	{
       
  2046     DEBUG_PRINTF2(_L8("COmxILPortManager::BufferEjectIndication: PORT[%u] "), aPortIndex);
       
  2047 
       
  2048 	// Check the index of the port..
       
  2049 	if (CheckPortIndex(aPortIndex) != OMX_ErrorNone)
       
  2050 		{
       
  2051 		return OMX_ErrorBadPortIndex;
       
  2052 		}
       
  2053 
       
  2054 	OMX_ERRORTYPE omxRetValue = OMX_ErrorNone;
       
  2055 	COmxILPort* pPort = iAllPorts[aPortIndex];
       
  2056 
       
  2057 	if (pPort->Count())
       
  2058 		{
       
  2059 		omxRetValue = iProcessingFunction.BufferFlushingIndication(
       
  2060 			pPort->Index(),
       
  2061 			pPort->Direction());
       
  2062 		}
       
  2063 
       
  2064 	return omxRetValue;
       
  2065 
       
  2066 	}
       
  2067 #endif
       
  2068 
       
  2069 OMX_ERRORTYPE
  1921 OMX_ERRORTYPE
  2070 COmxILPortManager::ComponentRoleIndication(TUint aComponentRoleIndex)
  1922 COmxILPortManager::ComponentRoleIndication(TUint aComponentRoleIndex)
  2071 	{
  1923 	{
  2072     DEBUG_PRINTF2(_L8("COmxILPortManager::ComponentRoleIndication : aComponentRoleIndex[%u]"), aComponentRoleIndex);
  1924     DEBUG_PRINTF2(_L8("COmxILPortManager::ComponentRoleIndication : aComponentRoleIndex[%u]"), aComponentRoleIndex);
  2073 
  1925