Use hw-based codec if a sw-based codec is not available but a hw-based codec is, when sw-based codec decoders are requested.
Thus, the request for sw-based codec becomes "preferred" request now, instead of "forced" ones.
diff --git a/codecs_v2/omx/omx_mastercore/src/pv_omxmastercore.cpp b/codecs_v2/omx/omx_mastercore/src/pv_omxmastercore.cpp
index b6360d2..20662ed 100644
--- a/codecs_v2/omx/omx_mastercore/src/pv_omxmastercore.cpp
+++ b/codecs_v2/omx/omx_mastercore/src/pv_omxmastercore.cpp
@@ -563,21 +563,32 @@
return OMX_ErrorInsufficientResources;
}
+ OMX_S32 hwCodecFoundWhenSoftwareCodecIsRequested = -1;
for (ii = 0; ii < (data->iTotalNumOMXComponents); ii++)
{
// go through the list of supported components and find the component based on its name (identifier)
if (!oscl_strcmp((OMX_STRING)pOMXMasterRegistry[ii].CompName, cComponentName))
{
- // when we are not requesting a HW accelelrated codec, we must find a software
- // codec.
+ // when we are not requesting a HW accelelrated codec
+ // we prefer to find a software-based codec.
if (!bHWAccelerated) {
- if (!pOMXMasterRegistry[ii].bHWAccelerated) break;
+ if (!pOMXMasterRegistry[ii].bHWAccelerated)
+ {
+ break;
+ }
+ else if (hwCodecFoundWhenSoftwareCodecIsRequested == -1)
+ {
+ // Store the first hardware-based codec found
+ // In case we could not find any software-based codec, we will
+ // use this hareware-based codec
+ hwCodecFoundWhenSoftwareCodecIsRequested = ii;
+ }
} else {
break;
}
}
}
- if (ii == (data->iTotalNumOMXComponents))
+ if (ii == (data->iTotalNumOMXComponents) && hwCodecFoundWhenSoftwareCodecIsRequested == -1)
{
// could not find a component with the given name
OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMXMASTERCORE, error);
@@ -589,6 +600,10 @@
}
return OMX_ErrorComponentNotFound;
}
+ else if (hwCodecFoundWhenSoftwareCodecIsRequested != -1)
+ {
+ ii = hwCodecFoundWhenSoftwareCodecIsRequested;
+ }
// call the appropriate GetHandle for the component