OpenMAX Bellagio 0.9.3
|
#include <string.h>
#include "omx_reference_resource_manager.h"
#include "base/omx_base_component.h"
#include "queue.h"
Go to the source code of this file.
Functions | |
OMX_ERRORTYPE | RM_Init () |
OMX_ERRORTYPE | RM_RegisterComponent (char *name, int max_components) |
OMX_ERRORTYPE | RM_Deinit () |
OMX_ERRORTYPE | addElemToList (ComponentListType **list, OMX_COMPONENTTYPE *openmaxStandComp, int index, OMX_BOOL bIsWaiting) |
OMX_ERRORTYPE | removeElemFromList (ComponentListType **list, OMX_COMPONENTTYPE *openmaxStandComp) |
int | numElemInList (ComponentListType *list) |
OMX_ERRORTYPE | clearList (ComponentListType **list) |
void | RM_printList (ComponentListType *list, int viewFlag) |
int | searchLowerPriority (ComponentListType *list, int current_priority, ComponentListType **oldest_component_preemptable) |
OMX_ERRORTYPE | preemptComponent (OMX_COMPONENTTYPE *openmaxStandComp) |
OMX_ERRORTYPE | RM_getResource (OMX_COMPONENTTYPE *openmaxStandComp) |
OMX_ERRORTYPE | RM_releaseResource (OMX_COMPONENTTYPE *openmaxStandComp) |
OMX_ERRORTYPE | RM_waitForResource (OMX_COMPONENTTYPE *openmaxStandComp) |
OMX_ERRORTYPE | RM_removeFromWaitForResource (OMX_COMPONENTTYPE *openmaxStandComp) |
Variables | |
int | globalIndex |
NameIndexType * | listOfcomponentRegistered |
ComponentListType ** | globalComponentList |
ComponentListType ** | globalWaitingComponentList |
OMX_ERRORTYPE addElemToList | ( | ComponentListType ** | list, |
OMX_COMPONENTTYPE * | openmaxStandComp, | ||
int | index, | ||
OMX_BOOL | bIsWaiting | ||
) |
This function adds a new element to a given list. If it does not yet exists, this function also allocates the list.
Definition at line 114 of file omx_reference_resource_manager.c.
References DEB_LEV_ERR, DEB_LEV_FUNCTION_NAME, DEBUG, globalComponentList, globalWaitingComponentList, ComponentListType::next, omx_base_component_PrivateType::nGroupPriority, ComponentListType::nGroupPriority, OMX_ErrorInsufficientResources, OMX_ErrorNone, ComponentListType::openmaxStandComp, OMX_COMPONENTTYPE::pComponentPrivate, and ComponentListType::timestamp.
Referenced by RM_getResource(), and RM_waitForResource().
OMX_ERRORTYPE clearList | ( | ComponentListType ** | list | ) |
This function deallocate any remaining element in a list and dispose it
Definition at line 228 of file omx_reference_resource_manager.c.
References DEB_LEV_FUNCTION_NAME, DEBUG, ComponentListType::next, and OMX_ErrorNone.
Referenced by RM_Deinit().
int numElemInList | ( | ComponentListType * | list | ) |
This function returns the number of elements present in the list. If the list does not exists, this function returns 0 elements without further warnings
Definition at line 207 of file omx_reference_resource_manager.c.
References DEB_LEV_FUNCTION_NAME, DEB_LEV_SIMPLE_SEQ, DEBUG, and ComponentListType::next.
Referenced by RM_getResource(), and RM_releaseResource().
OMX_ERRORTYPE preemptComponent | ( | OMX_COMPONENTTYPE * | openmaxStandComp | ) |
This function tries to preempt the given component, that has been detected as the candidate by the default policy defined in the OpenMAX spec.
Definition at line 317 of file omx_reference_resource_manager.c.
References omx_base_component_PrivateType::callbackData, omx_base_component_PrivateType::callbacks, DEB_LEV_ERR, DEB_LEV_FUNCTION_NAME, DEBUG, err, OMX_CALLBACKTYPE::EventHandler, OMX_CommandStateSet, OMX_ErrorNone, OMX_ErrorResourcesLost, OMX_ErrorUndefined, OMX_EventError, OMX_SendCommand, OMX_StateExecuting, OMX_StateIdle, OMX_StateLoaded, OMX_StatePause, OMX_COMPONENTTYPE::pComponentPrivate, and omx_base_component_PrivateType::state.
Referenced by RM_getResource().
OMX_ERRORTYPE removeElemFromList | ( | ComponentListType ** | list, |
OMX_COMPONENTTYPE * | openmaxStandComp | ||
) |
This function removes the given element from the list, if present. If the list is empty, this function cleans up everything.
Definition at line 162 of file omx_reference_resource_manager.c.
References DEB_LEV_ERR, DEB_LEV_FUNCTION_NAME, DEBUG, ComponentListType::next, OMX_ErrorComponentNotFound, OMX_ErrorNone, OMX_ErrorUndefined, OMX_FALSE, OMX_TRUE, and ComponentListType::openmaxStandComp.
Referenced by RM_getResource(), RM_releaseResource(), and RM_removeFromWaitForResource().
OMX_ERRORTYPE RM_Deinit | ( | ) |
This function de-initializes the resource manager. In the current implementation its responsibility is to clean up any queue that can be left pending at the end of usage. With a correct use of the resource manager it won't happen, but it is safer to clean up everything this these lists are global and alive for all the life of IL client, beyond the usual OMX_Init - Deinit scope.
Definition at line 98 of file omx_reference_resource_manager.c.
References clearList(), DEB_LEV_FUNCTION_NAME, DEBUG, globalComponentList, globalWaitingComponentList, and OMX_ErrorNone.
Referenced by BOSA_ST_DeInitComponentLoader(), and BOSA_STE_DeInitComponentLoader().
OMX_ERRORTYPE RM_getResource | ( | OMX_COMPONENTTYPE * | openmaxStandComp | ) |
This function is executed by a component when it changes state from Loaded to Idle. If it return ErrorNone the resource is granted and it can transit to Idle. In case the resource is already busy, the resource manager preempt another component with a lower priority and a oldest time flag if it exists. Differently it returns OMX_ErrorInsufficientResources
Definition at line 349 of file omx_reference_resource_manager.c.
References addElemToList(), DEB_LEV_ERR, DEB_LEV_FUNCTION_NAME, DEB_LEV_SIMPLE_SEQ, DEBUG, err, globalComponentList, NameIndexType::index, listOfcomponentRegistered, omx_base_component_PrivateType::name, omx_base_component_PrivateType::nGroupPriority, numElemInList(), OMX_ErrorInsufficientResources, OMX_ErrorNone, OMX_FALSE, ComponentListType::openmaxStandComp, OMX_COMPONENTTYPE::pComponentPrivate, preemptComponent(), removeElemFromList(), and searchLowerPriority().
Referenced by omx_base_component_DoStateSet().
OMX_ERRORTYPE RM_Init | ( | ) |
This function initializes the Resource manager. In the current implementation it does not perform any operation
Definition at line 47 of file omx_reference_resource_manager.c.
References NameIndexType::component_name, DEB_LEV_FUNCTION_NAME, DEBUG, globalComponentList, globalIndex, globalWaitingComponentList, NameIndexType::index, listOfcomponentRegistered, MAX_COMPONENTS_TYPES_HANDLED, and OMX_ErrorNone.
Referenced by BOSA_ST_InitComponentLoader(), and BOSA_STE_InitComponentLoader().
void RM_printList | ( | ComponentListType * | list, |
int | viewFlag | ||
) |
This debug function is capable of printing the full list actually stored
Definition at line 251 of file omx_reference_resource_manager.c.
References omx_base_component_PrivateType::name, ComponentListType::next, ComponentListType::openmaxStandComp, OMX_COMPONENTTYPE::pComponentPrivate, RM_SHOW_ADDRESS, and RM_SHOW_NAME.
OMX_ERRORTYPE RM_RegisterComponent | ( | char * | name, |
int | max_components | ||
) |
This function is called during initialization by any component interested in be handled by the internal resource manager
Definition at line 67 of file omx_reference_resource_manager.c.
References NameIndexType::component_name, DEB_LEV_FUNCTION_NAME, DEBUG, globalIndex, NameIndexType::index, listOfcomponentRegistered, NameIndexType::max_components, OMX_ErrorInsufficientResources, OMX_ErrorNone, and OMX_MAX_STRINGNAME_SIZE.
Referenced by omx_audio_mixer_component_Constructor(), omx_clocksrc_component_Constructor(), omx_video_scheduler_component_Constructor(), and omx_volume_component_Constructor().
OMX_ERRORTYPE RM_releaseResource | ( | OMX_COMPONENTTYPE * | openmaxStandComp | ) |
This function is called by a component when it transit from Idle to Loaded and can release its used resource handled by the resource manager
Definition at line 404 of file omx_reference_resource_manager.c.
References DEB_LEV_ERR, DEB_LEV_FUNCTION_NAME, DEBUG, err, globalComponentList, globalWaitingComponentList, NameIndexType::index, listOfcomponentRegistered, omx_base_component_PrivateType::name, numElemInList(), OMX_CommandStateSet, OMX_ErrorNone, OMX_ErrorUndefined, OMX_SendCommand, OMX_StateIdle, ComponentListType::openmaxStandComp, OMX_COMPONENTTYPE::pComponentPrivate, and removeElemFromList().
Referenced by omx_base_component_DoStateSet().
OMX_ERRORTYPE RM_removeFromWaitForResource | ( | OMX_COMPONENTTYPE * | openmaxStandComp | ) |
This function removes a component from the waiting queue if the IL client decides that the component should not wait any more for the resource
Definition at line 490 of file omx_reference_resource_manager.c.
References DEB_LEV_ERR, DEB_LEV_FUNCTION_NAME, DEBUG, globalComponentList, listOfcomponentRegistered, omx_base_component_PrivateType::name, OMX_ErrorNone, OMX_COMPONENTTYPE::pComponentPrivate, and removeElemFromList().
Referenced by omx_base_component_DoStateSet().
OMX_ERRORTYPE RM_waitForResource | ( | OMX_COMPONENTTYPE * | openmaxStandComp | ) |
This function adds the given component to the waiting queue for the given resource. When a resource becomes available through the RM_releaseResource function the first element in the queue is taken off the list and it receives the resource just released.
Definition at line 456 of file omx_reference_resource_manager.c.
References addElemToList(), DEB_LEV_ERR, DEB_LEV_FUNCTION_NAME, DEBUG, globalWaitingComponentList, NameIndexType::index, listOfcomponentRegistered, omx_base_component_PrivateType::name, OMX_ErrorNone, OMX_TRUE, and OMX_COMPONENTTYPE::pComponentPrivate.
Referenced by omx_base_component_DoStateSet().
int searchLowerPriority | ( | ComponentListType * | list, |
int | current_priority, | ||
ComponentListType ** | oldest_component_preemptable | ||
) |
This function returns the number of components that have a lower priority than the value specified, and the lowest among all possibles. If the number returned is 0, no component is preemptable. if it is 1 or more, the oldest_component_preemptable will contain the reference to the preemptable component with the oldest time stamp.
Definition at line 282 of file omx_reference_resource_manager.c.
References DEB_LEV_ERR, DEB_LEV_FUNCTION_NAME, DEBUG, ComponentListType::next, ComponentListType::nGroupPriority, OMX_ErrorUndefined, and ComponentListType::timestamp.
Referenced by RM_getResource().
ComponentListType** globalComponentList |
Definition at line 35 of file omx_reference_resource_manager.c.
Referenced by addElemToList(), RM_Deinit(), RM_getResource(), RM_Init(), RM_releaseResource(), and RM_removeFromWaitForResource().
int globalIndex |
src/omx_reference_resource_manager.c
This simple resource manager emulates the behavior of a real RM. It applies the rules defined in the OpenMAX spec. It can be replaced in the future by a real system.
Copyright (C) 2007-2009 STMicroelectronics Copyright (C) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Definition at line 33 of file omx_reference_resource_manager.c.
Referenced by RM_Init(), and RM_RegisterComponent().
ComponentListType** globalWaitingComponentList |
Definition at line 36 of file omx_reference_resource_manager.c.
Referenced by addElemToList(), RM_Deinit(), RM_Init(), RM_releaseResource(), and RM_waitForResource().
NameIndexType* listOfcomponentRegistered |
Definition at line 34 of file omx_reference_resource_manager.c.
Referenced by RM_getResource(), RM_Init(), RM_RegisterComponent(), RM_releaseResource(), RM_removeFromWaitForResource(), and RM_waitForResource().