Use required not exposed in checkSourceSinkVsInterfacesCompatibility.
Change-Id: Ib71826b989ddef2e87dd60bec0306ca2a4021fe3
SLresult checkSourceSinkVsInterfacesCompatibility(const DataLocatorFormat *pSrcDataLocatorFormat,
const DataLocatorFormat *pSinkDataLocatorFormat,
- const ClassTable *clazz, unsigned exposedMask) {
+ const ClassTable *clazz, unsigned requiredMask) {
int index;
switch (pSrcDataLocatorFormat->mLocator.mLocatorType) {
case SL_DATALOCATOR_URI:
#endif
break;
default:
- // can't request SLBufferQueueItf or its alias SLAndroidSimpleBufferQueueItf
+ // can't require SLBufferQueueItf or its alias SLAndroidSimpleBufferQueueItf
// if the data sink is not a buffer queue
index = clazz->mMPH_to_index[MPH_BUFFERQUEUE];
#ifdef ANDROID
assert(index == clazz->mMPH_to_index[MPH_ANDROIDSIMPLEBUFFERQUEUE]);
#endif
if (0 <= index) {
- if (exposedMask & (1 << index)) {
- SL_LOGE("can't request SL_IID_BUFFERQUEUE "
+ if (requiredMask & (1 << index)) {
+ SL_LOGE("can't require SL_IID_BUFFERQUEUE "
#ifdef ANDROID
"or SL_IID_ANDROIDSIMPLEBUFFERQUEUE "
#endif
#ifdef ANDROID
case SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE:
#endif
- // can't request SLSeekItf if data source is a buffer queue
+ // can't require SLSeekItf if data source is a buffer queue
index = clazz->mMPH_to_index[MPH_SEEK];
if (0 <= index) {
- if (exposedMask & (1 << index)) {
- SL_LOGE("can't request SL_IID_SEEK with a buffer queue data source");
+ if (requiredMask & (1 << index)) {
+ SL_LOGE("can't require SL_IID_SEEK with a buffer queue data source");
return SL_RESULT_FEATURE_UNSUPPORTED;
}
}
- // can't request SLMuteSoloItf if data source is a mono buffer queue
+ // can't require SLMuteSoloItf if data source is a mono buffer queue
index = clazz->mMPH_to_index[MPH_MUTESOLO];
if (0 <= index) {
- if ((exposedMask & (1 << index)) &&
+ if ((requiredMask & (1 << index)) &&
(SL_DATAFORMAT_PCM == pSrcDataLocatorFormat->mFormat.mFormatType) &&
(1 == pSrcDataLocatorFormat->mFormat.mPCM.numChannels)) {
- SL_LOGE("can't request SL_IID_MUTESOLO with a mono buffer queue data source");
+ SL_LOGE("can't require SL_IID_MUTESOLO with a mono buffer queue data source");
return SL_RESULT_FEATURE_UNSUPPORTED;
}
}
case XA_DATALOCATOR_NATIVEDISPLAY:
// any special checks here???
default:
- // can't request SLBufferQueueItf or its alias SLAndroidSimpleBufferQueueItf
+ // can't require SLBufferQueueItf or its alias SLAndroidSimpleBufferQueueItf
// if the data source is not a buffer queue
index = clazz->mMPH_to_index[MPH_BUFFERQUEUE];
#ifdef ANDROID
assert(index == clazz->mMPH_to_index[MPH_ANDROIDSIMPLEBUFFERQUEUE]);
#endif
if (0 <= index) {
- if (exposedMask & (1 << index)) {
- SL_LOGE("can't request SL_IID_BUFFERQUEUE "
+ if (requiredMask & (1 << index)) {
+ SL_LOGE("can't require SL_IID_BUFFERQUEUE "
#ifdef ANDROID
"or SL_IID_ANDROIDSIMPLEBUFFERQUEUE "
#endif
extern SLresult checkSourceSinkVsInterfacesCompatibility(
const DataLocatorFormat *pSrcDataLocatorFormat,
const DataLocatorFormat *pSinkDataLocatorFormat,
- const ClassTable *clazz, unsigned exposedMask);
+ const ClassTable *clazz, unsigned requiredMask);
extern void freeDataLocatorFormat(DataLocatorFormat *dlf);
unsigned exposedMask;
assert(NULL != pCEngine_class);
result = checkInterfaces(pCEngine_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask);
+ pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
if (SL_RESULT_SUCCESS != result) {
break;
}
result = SL_RESULT_FEATURE_UNSUPPORTED;
} else {
result = checkInterfaces(pCLEDDevice_class, numInterfaces, pInterfaceIds,
- pInterfaceRequired, &exposedMask);
+ pInterfaceRequired, &exposedMask, NULL);
}
if (SL_RESULT_SUCCESS == result) {
CLEDDevice *thiz = (CLEDDevice *) construct(pCLEDDevice_class, exposedMask, self);
result = SL_RESULT_FEATURE_UNSUPPORTED;
} else {
result = checkInterfaces(pCVibraDevice_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask);
+ pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
}
if (SL_RESULT_SUCCESS == result) {
CVibraDevice *thiz = (CVibraDevice *) construct(pCVibraDevice_class, exposedMask, self);
result = SL_RESULT_PARAMETER_INVALID;
} else {
*pPlayer = NULL;
- unsigned exposedMask;
+ unsigned exposedMask, requiredMask;
const ClassTable *pCAudioPlayer_class = objectIDtoClass(SL_OBJECTID_AUDIOPLAYER);
assert(NULL != pCAudioPlayer_class);
result = checkInterfaces(pCAudioPlayer_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask);
+ pInterfaceIds, pInterfaceRequired, &exposedMask, &requiredMask);
if (SL_RESULT_SUCCESS == result) {
// Construct our new AudioPlayer instance
// Check that the requested interfaces are compatible with data source and sink
result = checkSourceSinkVsInterfacesCompatibility(&thiz->mDataSource,
- &thiz->mDataSink, pCAudioPlayer_class, exposedMask);
+ &thiz->mDataSink, pCAudioPlayer_class, requiredMask);
if (SL_RESULT_SUCCESS != result) {
break;
}
result = SL_RESULT_FEATURE_UNSUPPORTED;
} else {
result = checkInterfaces(pCAudioRecorder_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask);
+ pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
}
if (SL_RESULT_SUCCESS == result) {
result = SL_RESULT_FEATURE_UNSUPPORTED;
} else {
result = checkInterfaces(pCMidiPlayer_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask);
+ pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
}
if (SL_RESULT_SUCCESS == result) {
CMidiPlayer *thiz = (CMidiPlayer *) construct(pCMidiPlayer_class, exposedMask, self);
result = SL_RESULT_FEATURE_UNSUPPORTED;
} else {
result = checkInterfaces(pCListener_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask);
+ pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
}
if (SL_RESULT_SUCCESS == result) {
CListener *thiz = (CListener *) construct(pCListener_class, exposedMask, self);
result = SL_RESULT_FEATURE_UNSUPPORTED;
} else {
result = checkInterfaces(pC3DGroup_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask);
+ pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
}
if (SL_RESULT_SUCCESS == result) {
C3DGroup *thiz = (C3DGroup *) construct(pC3DGroup_class, exposedMask, self);
const ClassTable *pCOutputMix_class = objectIDtoClass(SL_OBJECTID_OUTPUTMIX);
assert(NULL != pCOutputMix_class);
result = checkInterfaces(pCOutputMix_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask);
+ pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
if (SL_RESULT_SUCCESS == result) {
COutputMix *thiz = (COutputMix *) construct(pCOutputMix_class, exposedMask, self);
if (NULL == thiz) {
result = SL_RESULT_FEATURE_UNSUPPORTED;
} else {
result = checkInterfaces(pCMetadataExtractor_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask);
+ pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
}
if (SL_RESULT_SUCCESS == result) {
CMetadataExtractor *thiz = (CMetadataExtractor *)
const ClassTable *pCMediaPlayer_class = objectIDtoClass(XA_OBJECTID_MEDIAPLAYER);
assert(NULL != pCMediaPlayer_class);
result = checkInterfaces(pCMediaPlayer_class, numInterfaces,
- (const SLInterfaceID *) pInterfaceIds, pInterfaceRequired, &exposedMask);
+ (const SLInterfaceID *) pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
if (XA_RESULT_SUCCESS == result) {
// Construct our new MediaPlayer instance
/** \brief Check the interface IDs passed into a Create operation */
SLresult checkInterfaces(const ClassTable *clazz, SLuint32 numInterfaces,
- const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired, unsigned *pExposedMask)
+ const SLInterfaceID *pInterfaceIds, const SLboolean *pInterfaceRequired,
+ unsigned *pExposedMask, unsigned *pRequiredMask)
{
assert(NULL != clazz && NULL != pExposedMask);
// Initially no interfaces are exposed
unsigned exposedMask = 0;
+ unsigned requiredMask = 0;
const struct iid_vtable *interfaces = clazz->mInterfaces;
SLuint32 interfaceCount = clazz->mInterfaceCount;
SLuint32 i;
if (NULL == iid) {
return SL_RESULT_PARAMETER_INVALID;
}
+ SLboolean isRequired = pInterfaceRequired[i];
int MPH, index;
if ((0 > (MPH = IID_to_MPH(iid))) ||
// there must be an initialization hook present
(0 > (index = clazz->mMPH_to_index[MPH])) ||
(INTERFACE_UNAVAILABLE == interfaces[index].mInterface)) {
// Here if interface was not found, or is not available for this object type
- if (pInterfaceRequired[i]) {
+ if (isRequired) {
// Application said it required the interface, so give up
SL_LOGE("class %s interface %u required but unavailable MPH=%d",
clazz->mName, i, MPH);
clazz->mName, i, MPH);
continue;
}
+ if (isRequired) {
+ requiredMask |= (1 << index);
+ }
// The requested interface was both found and available, so expose it
exposedMask |= (1 << index);
// Note that we ignore duplicate requests, including equal and aliased IDs
}
}
*pExposedMask = exposedMask;
+ if (NULL != pRequiredMask) {
+ *pRequiredMask = requiredMask;
+ }
return SL_RESULT_SUCCESS;
}
extern /*static*/ const struct MPH_init MPH_init_table[MPH_MAX];
extern SLresult checkInterfaces(const ClassTable *clazz,
SLuint32 numInterfaces, const SLInterfaceID *pInterfaceIds,
- const SLboolean *pInterfaceRequired, unsigned *pExposedMask);
+ const SLboolean *pInterfaceRequired, unsigned *pExposedMask, unsigned *pRequiredMask);
extern IObject *construct(const ClassTable *clazz,
unsigned exposedMask, SLEngineItf engine);
extern const ClassTable *objectIDtoClass(SLuint32 objectID);