OSDN Git Service

Bug 5369977 check required interface compatibility
authorGlenn Kasten <gkasten@google.com>
Wed, 21 Sep 2011 16:03:14 +0000 (09:03 -0700)
committerGlenn Kasten <gkasten@google.com>
Mon, 26 Sep 2011 00:23:34 +0000 (17:23 -0700)
Use required not exposed in checkSourceSinkVsInterfacesCompatibility.

Change-Id: Ib71826b989ddef2e87dd60bec0306ca2a4021fe3

wilhelm/src/data.c
wilhelm/src/data.h
wilhelm/src/entry.c
wilhelm/src/itf/IEngine.c
wilhelm/src/sles.c
wilhelm/src/sles_allinclusive.h

index b24001c..12f4257 100644 (file)
@@ -598,7 +598,7 @@ static SLresult checkDataFormat(const char *name, void *pFormat, DataFormat *pDa
 
 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:
@@ -614,15 +614,15 @@ SLresult checkSourceSinkVsInterfacesCompatibility(const DataLocatorFormat *pSrcD
 #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
@@ -638,21 +638,21 @@ SLresult checkSourceSinkVsInterfacesCompatibility(const DataLocatorFormat *pSrcD
 #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;
             }
         }
@@ -679,15 +679,15 @@ SLresult checkSourceSinkVsInterfacesCompatibility(const DataLocatorFormat *pSrcD
     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
index 4e9eea2..a5f7faf 100644 (file)
@@ -93,7 +93,7 @@ extern SLresult checkDataSink(const char *name, const SLDataSink *pDataSink,
 extern SLresult checkSourceSinkVsInterfacesCompatibility(
         const DataLocatorFormat *pSrcDataLocatorFormat,
         const DataLocatorFormat *pSinkDataLocatorFormat,
-        const ClassTable *clazz, unsigned exposedMask);
+        const ClassTable *clazz, unsigned requiredMask);
 extern void freeDataLocatorFormat(DataLocatorFormat *dlf);
 
 
index b09f0e9..8ee0430 100644 (file)
@@ -81,7 +81,7 @@ LI_API SLresult liCreateEngine(SLObjectItf *pEngine, SLuint32 numOptions,
         unsigned exposedMask;
         assert(NULL != pCEngine_class);
         result = checkInterfaces(pCEngine_class, numInterfaces,
-            pInterfaceIds, pInterfaceRequired, &exposedMask);
+            pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
         if (SL_RESULT_SUCCESS != result) {
             break;
         }
index 8eb11a3..687727e 100644 (file)
@@ -127,7 +127,7 @@ static SLresult IEngine_CreateLEDDevice(SLEngineItf self, SLObjectItf *pDevice,
             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);
@@ -165,7 +165,7 @@ static SLresult IEngine_CreateVibraDevice(SLEngineItf self, SLObjectItf *pDevice
             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);
@@ -197,11 +197,11 @@ static SLresult IEngine_CreateAudioPlayer(SLEngineItf self, SLObjectItf *pPlayer
        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
@@ -299,7 +299,7 @@ static SLresult IEngine_CreateAudioPlayer(SLEngineItf self, SLObjectItf *pPlayer
 
                     // 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;
                     }
@@ -439,7 +439,7 @@ static SLresult IEngine_CreateAudioRecorder(SLEngineItf self, SLObjectItf *pReco
             result = SL_RESULT_FEATURE_UNSUPPORTED;
         } else {
             result = checkInterfaces(pCAudioRecorder_class, numInterfaces,
-                    pInterfaceIds, pInterfaceRequired, &exposedMask);
+                    pInterfaceIds, pInterfaceRequired, &exposedMask, NULL);
         }
 
         if (SL_RESULT_SUCCESS == result) {
@@ -577,7 +577,7 @@ static SLresult IEngine_CreateMidiPlayer(SLEngineItf self, SLObjectItf *pPlayer,
             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);
@@ -623,7 +623,7 @@ static SLresult IEngine_CreateListener(SLEngineItf self, SLObjectItf *pListener,
             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);
@@ -660,7 +660,7 @@ static SLresult IEngine_Create3DGroup(SLEngineItf self, SLObjectItf *pGroup, SLu
             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);
@@ -695,7 +695,7 @@ static SLresult IEngine_CreateOutputMix(SLEngineItf self, SLObjectItf *pMix, SLu
         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) {
@@ -749,7 +749,7 @@ static SLresult IEngine_CreateMetadataExtractor(SLEngineItf self, SLObjectItf *p
             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 *)
@@ -1082,7 +1082,7 @@ static XAresult IEngine_CreateMediaPlayer(XAEngineItf self, XAObjectItf *pPlayer
         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
index 342ab68..270d01a 100644 (file)
@@ -148,11 +148,13 @@ SLresult err_to_result(int err)
 /** \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;
@@ -187,6 +189,7 @@ SLresult checkInterfaces(const ClassTable *clazz, SLuint32 numInterfaces,
             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
@@ -194,7 +197,7 @@ SLresult checkInterfaces(const ClassTable *clazz, SLuint32 numInterfaces,
                     (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);
@@ -205,6 +208,9 @@ SLresult checkInterfaces(const ClassTable *clazz, SLuint32 numInterfaces,
                         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
@@ -214,6 +220,9 @@ SLresult checkInterfaces(const ClassTable *clazz, SLuint32 numInterfaces,
         }
     }
     *pExposedMask = exposedMask;
+    if (NULL != pRequiredMask) {
+        *pRequiredMask = requiredMask;
+    }
     return SL_RESULT_SUCCESS;
 }
 
index a4d9278..513f774 100644 (file)
@@ -295,7 +295,7 @@ extern /*static*/ int IID_to_MPH(const SLInterfaceID iid);
 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);