OSDN Git Service

Bug fix and general code cleanup.
authorGlenn Kasten <gkasten@google.com>
Fri, 9 Jul 2010 18:50:34 +0000 (11:50 -0700)
committerGlenn Kasten <gkasten@google.com>
Tue, 13 Jul 2010 00:08:36 +0000 (17:08 -0700)
Trace debug now uses Android logging by LOGV/LOGE.
Added SL Utility Toolkit for OpenSL ES, similar to OpenAL UT.
Add a -DUSE_TRACE instead of -DNDEBUG and add it commented out to Android.mk.
LOGE for error returns, LOGV for all entry and exit.
Rename debug.c to trace.c.
slutPrintIID prints the symbolic name if known.
Fix bug in slQueryNumSupportedEngineInterfaces and
  slQuerySupportedEngineInterfaces which were not
  skipping over unavailable interfaces.
Use USE_CONFORMANCE to return SL_RESULT_FEATURE_UNSUPPORTED when not supported
  and make some interfaces unavailable depending on USE_CONFORMANCE.
Move most FIXME to separate bug/to-do list.
Fix possible intermediate overflow in duration computation for sndfile.
Line length 100.
Address code review comments, disable LOG.

28 files changed:
opensles/libopensles/Android.mk
opensles/libopensles/CAudioPlayer.c
opensles/libopensles/CEngine.c
opensles/libopensles/I3DCommit.c
opensles/libopensles/I3DGrouping.c
opensles/libopensles/I3DLocation.c
opensles/libopensles/I3DMacroscopic.c
opensles/libopensles/IAudioEncoder.c
opensles/libopensles/IAudioIODeviceCapabilities.c
opensles/libopensles/IBufferQueue.c
opensles/libopensles/IDeviceVolume.c
opensles/libopensles/IDynamicSource.c
opensles/libopensles/IEngine.c
opensles/libopensles/IMIDIMuteSolo.c
opensles/libopensles/IMIDITempo.c
opensles/libopensles/IMetadataExtraction.c
opensles/libopensles/IMetadataTraversal.c
opensles/libopensles/IObject.c
opensles/libopensles/IOutputMixExt.c
opensles/libopensles/OpenSLUT.c [new file with mode: 0644]
opensles/libopensles/OpenSLUT.h [new file with mode: 0644]
opensles/libopensles/SndFile.c
opensles/libopensles/classes.c
opensles/libopensles/devices.c
opensles/libopensles/locks.c
opensles/libopensles/sles.c
opensles/libopensles/sles_allinclusive.h
opensles/libopensles/trace.c [moved from opensles/libopensles/debug.c with 56% similarity]

index 5208578..6fc2549 100644 (file)
@@ -2,6 +2,18 @@ LOCAL_PATH:= $(call my-dir)
 
 include $(CLEAR_VARS)
 
+LOCAL_SRC_FILES := \
+        OpenSLUT.c
+
+LOCAL_C_INCLUDES:=                                                  \
+       system/media/opensles/include
+
+LOCAL_MODULE := libOpenSLUT
+
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+
 LOCAL_CFLAGS += -Wno-override-init -Wno-missing-field-initializers
 
 LOCAL_SRC_FILES:=                     \
@@ -14,12 +26,13 @@ include $(BUILD_STATIC_LIBRARY)
 include $(CLEAR_VARS)
 
 LOCAL_CFLAGS += -DUSE_CONFORMANCE
+# -DUSE_TRACE
 
 LOCAL_SRC_FILES:=                     \
         OpenSLES_IID.c                \
         classes.c                     \
         devices.c                     \
-        debug.c                       \
+        trace.c                       \
         interfaces.c                  \
         locks.c                       \
         sles.c                        \
@@ -85,7 +98,8 @@ LOCAL_C_INCLUDES:=                                                  \
 LOCAL_CFLAGS += -x c++ -Wno-multichar -Wno-invalid-offsetof
 
 LOCAL_STATIC_LIBRARIES += \
-        libopensles_helper
+        libopensles_helper        \
+        libOpenSLUT
 
 LOCAL_SHARED_LIBRARIES :=         \
         libstagefright            \
index e13a6bd..428ed2a 100644 (file)
@@ -29,7 +29,6 @@ SLresult CAudioPlayer_Realize(void *self, SLboolean async)
     this->mNumChannels = 0;
 
 #ifdef ANDROID
-    // FIXME move this to android specific files
     result = sles_to_android_audioPlayerRealize(this, async);
 #endif
 
@@ -49,23 +48,13 @@ SLresult CAudioPlayer_Realize(void *self, SLboolean async)
             int ok;
             ok = pthread_mutex_init(&this->mSndFile.mMutex, (const pthread_mutexattr_t *) NULL);
             assert(0 == ok);
-            // FIXME how do we know this interface is exposed?
             SLBufferQueueItf bufferQueue = &this->mBufferQueue.mItf;
-            // FIXME should use a private internal API, and disallow
-            // application to have access to our buffer queue
-            // FIXME if we had an internal API, could call this directly
-            // FIXME can't call this directly as we get a double lock
-            // result = (*bufferQueue)->RegisterCallback(bufferQueue,
-            //    SndFile_Callback, &this->mSndFile);
-            // FIXME so let's inline the code, but this is maintenance risk
-            // we know we are called by Object_Realize, which holds a lock,
-            // but if interface lock != object lock, need to rewrite this
             IBufferQueue *thisBQ = (IBufferQueue *) bufferQueue;
             thisBQ->mCallback = SndFile_Callback;
             thisBQ->mContext = this;
-            // FIXME Intermediate overflow possible on duration computation
             this->mPrefetchStatus.mStatus = SL_PREFETCHSTATUS_SUFFICIENTDATA;
-            this->mPlay.mDuration = (SLmillisecond) ((sfinfo.frames * 1000) / sfinfo.samplerate);
+            this->mPlay.mDuration = (SLmillisecond)
+                (((long long) sfinfo.frames * 1000LL) / sfinfo.samplerate);
             this->mNumChannels = sfinfo.channels;
         }
     }
@@ -78,7 +67,6 @@ void CAudioPlayer_Destroy(void *self)
     CAudioPlayer *this = (CAudioPlayer *) self;
     freeDataLocatorFormat(&this->mDataSource);
     freeDataLocatorFormat(&this->mDataSink);
-    // FIXME stop the player in a way that app can't restart it
     // Free the buffer queue, if it was larger than typical
     if (NULL != this->mBufferQueue.mArray &&
         this->mBufferQueue.mArray != this->mBufferQueue.mTypical) {
index f176f86..2e9524c 100644 (file)
@@ -27,7 +27,6 @@ SLresult CEngine_Realize(void *self, SLboolean async)
     SLresult result = err_to_result(err);
     if (SL_RESULT_SUCCESS != result)
         return result;
-    // FIXME Use platform-specific engine configuration options here.
     result = ThreadPool_init(&this->mEngine.mThreadPool, 0, 0);
     if (SL_RESULT_SUCCESS != result) {
         this->mEngine.mShutdown = SL_BOOLEAN_TRUE;
index 9b53ef8..889878c 100644 (file)
@@ -27,7 +27,6 @@ static SLresult I3DCommit_Commit(SL3DCommitItf self)
     IObject *thisObject = InterfaceToIObject(this);
     object_lock_exclusive(thisObject);
     if (this->mDeferred) {
-        // FIXME This should be a no-op without blocking if no 3D operations enqueued
         SLuint32 myGeneration = this->mGeneration;
         do {
             ++this->mWaiting;
index 0a0a2f9..cf616ca 100644 (file)
@@ -88,5 +88,5 @@ void I3DGrouping_init(void *self)
     I3DGrouping *this = (I3DGrouping *) self;
     this->mItf = &I3DGrouping_Itf;
     this->mGroup = NULL;
-    // FIXME initialize the set here
+    // initialize the set here
 }
index 3ec360b..635913d 100644 (file)
@@ -170,7 +170,7 @@ static SLresult I3DLocation_SetOrientationVectors(SL3DLocationItf self,
     } else {
         SLVec3D front = *pFront;
         SLVec3D above = *pAbove;
-        // FIXME Check for vectors close to zero or close to parallel
+        // NTH Check for vectors close to zero or close to parallel
         I3DLocation *this = (I3DLocation *) self;
         interface_lock_exclusive(this);
         this->mOrientationVectors.mFront = front;
@@ -218,7 +218,7 @@ static SLresult I3DLocation_Rotate(SL3DLocationItf self, SLmillidegree theta, co
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
         SLVec3D axis = *pAxis;
-        // FIXME Check that axis is not (close to) zero vector, length does not matter
+        // NTH Check that axis is not (close to) zero vector, length does not matter
         I3DLocation *this = (I3DLocation *) self;
         interface_lock_exclusive(this);
         while (this->mRotatePending)
@@ -247,7 +247,6 @@ static SLresult I3DLocation_GetOrientationVectors(SL3DLocationItf self,
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
         I3DLocation *this = (I3DLocation *) self;
-        // FIXME Should wait for a pending rotate to complete, or orientation angles to be converted
         interface_lock_shared(this);
         SLVec3D front = this->mOrientationVectors.mFront;
         SLVec3D up = this->mOrientationVectors.mUp;
index 4850679..3330dbe 100644 (file)
@@ -103,11 +103,11 @@ static SLresult I3DMacroscopic_SetOrientationVectors(SL3DMacroscopicItf self,
         I3DMacroscopic *this = (I3DMacroscopic *) self;
         SLVec3D front = *pFront;
         SLVec3D above = *pAbove;
-        // FIXME Check for vectors close to zero or close to parallel
+        // NTH Check for vectors close to zero or close to parallel
         interface_lock_exclusive(this);
         this->mOrientationVectors.mFront = front;
         this->mOrientationVectors.mAbove = above;
-        this->mOrientationVectors.mUp = above; // FIXME
+        this->mOrientationVectors.mUp = above; // wrong
         this->mOrientationActive = ANGLES_UNKNOWN_VECTORS_SET;
         this->mRotatePending = SL_BOOLEAN_FALSE;
         interface_unlock_exclusive(this);
@@ -127,22 +127,14 @@ static SLresult I3DMacroscopic_Rotate(SL3DMacroscopicItf self,
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
         SLVec3D axis = *pAxis;
-        // FIXME Check that axis is not (close to) zero vector, length does not matter
+        // NTH Check that axis is not (close to) zero vector, length does not matter
         I3DMacroscopic *this = (I3DMacroscopic *) self;
-        // FIXME Do the rotate here:
-        // interface_lock_shared(this);
-        // read old values and generation
-        // interface_unlock_shared(this);
-        // compute new position
         interface_lock_exclusive(this);
         while (this->mRotatePending)
             interface_cond_wait(this);
         this->mTheta = theta;
         this->mAxis = axis;
         this->mRotatePending = SL_BOOLEAN_TRUE;
-        // compare generation with saved value
-        // if equal, store new position and increment generation
-        // if unequal, discard new position
         interface_unlock_exclusive(this);
         result = SL_RESULT_SUCCESS;
     }
index 1164a18..c7b167a 100644 (file)
@@ -29,7 +29,6 @@ static SLresult IAudioEncoder_SetEncoderSettings(SLAudioEncoderItf self,
     } else {
         IAudioEncoder *this = (IAudioEncoder *) self;
         SLAudioEncoderSettings settings = *pSettings;
-        // FIXME Validate the settings
         interface_lock_exclusive(this);
         this->mSettings = settings;
         interface_unlock_exclusive(this);
index 90a59e4..23a68ac 100644 (file)
@@ -18,6 +18,8 @@
 
 /* AudioIODeviceCapabilities implementation */
 
+// NTH make it platform-configurable
+
 
 static SLresult IAudioIODeviceCapabilities_GetAvailableAudioInputs(
     SLAudioIODeviceCapabilitiesItf self, SLint32 *pNumInputs, SLuint32 *pInputDeviceIDs)
@@ -29,7 +31,6 @@ static SLresult IAudioIODeviceCapabilities_GetAvailableAudioInputs(
     } else {
         result = SL_RESULT_SUCCESS;
         if (NULL != pInputDeviceIDs) {
-            // FIXME should be OEM-configurable
             if (1 > *pNumInputs) {
                 result = SL_RESULT_BUFFER_INSUFFICIENT;
             } else {
@@ -53,7 +54,6 @@ static SLresult IAudioIODeviceCapabilities_QueryAudioInputCapabilities(
     } else {
         result = SL_RESULT_SUCCESS;
         switch (deviceID) {
-        // FIXME should be OEM-configurable
         case SL_DEFAULTDEVICEID_AUDIOINPUT:
             *pDescriptor = *AudioInput_id_descriptors[0].descriptor;
             break;
@@ -94,14 +94,13 @@ static SLresult IAudioIODeviceCapabilities_GetAvailableAudioOutputs(
     } else {
         result = SL_RESULT_SUCCESS;
         if (NULL != pOutputDeviceIDs) {
-            // FIXME should be OEM-configurable
             if (2 > *pNumOutputs) {
                 result = SL_RESULT_BUFFER_INSUFFICIENT;
-                // FIXME if 1 slot available, still fill that
+                // if 1 slot available, should still fill that
             } else {
                 pOutputDeviceIDs[0] = DEVICE_ID_HEADSET;
                 pOutputDeviceIDs[1] = DEVICE_ID_HANDSFREE;
-                // FIXME SL_DEFAULTDEVICEID_AUDIOOUTPUT?
+                // SL_DEFAULTDEVICEID_AUDIOOUTPUT?
             }
         }
         *pNumOutputs = 2;
@@ -121,14 +120,13 @@ static SLresult IAudioIODeviceCapabilities_QueryAudioOutputCapabilities(
     } else {
         result = SL_RESULT_SUCCESS;
         switch (deviceID) {
-        // FIXME should be OEM-configurable
         case DEVICE_ID_HEADSET:
             *pDescriptor = *AudioOutput_id_descriptors[1].descriptor;
             break;
         case DEVICE_ID_HANDSFREE:
             *pDescriptor = *AudioOutput_id_descriptors[2].descriptor;
             break;
-        // FIXME SL_DEFAULTDEVICEID_AUDIOOUTPUT?
+        // SL_DEFAULTDEVICEID_AUDIOOUTPUT?
         default:
             result = SL_RESULT_IO_ERROR;
             break;
@@ -182,7 +180,7 @@ static SLresult IAudioIODeviceCapabilities_GetAssociatedAudioInputs(
     if (NULL == pNumAudioInputs) {
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
-        // FIXME Incomplete
+        // Incomplete
         *pNumAudioInputs = 0;
         result = SL_RESULT_SUCCESS;
     }
@@ -200,7 +198,7 @@ static SLresult IAudioIODeviceCapabilities_GetAssociatedAudioOutputs(
     if (NULL == pNumAudioOutputs) {
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
-        // FIXME Incomplete
+        // Incomplete
         *pNumAudioOutputs = 0;
         result = SL_RESULT_SUCCESS;
     }
@@ -223,7 +221,6 @@ static SLresult IAudioIODeviceCapabilities_GetDefaultAudioDevices(
         case SL_DEFAULTDEVICEID_AUDIOOUTPUT:
             result = SL_RESULT_SUCCESS;
             if (NULL != pAudioDeviceIDs) {
-                // FIXME should be OEM-configurable
                 switch (defaultDeviceID) {
                 case SL_DEFAULTDEVICEID_AUDIOINPUT:
                     if (1 > *pNumAudioDevices) {
@@ -239,7 +236,7 @@ static SLresult IAudioIODeviceCapabilities_GetDefaultAudioDevices(
                     } else {
                         pAudioDeviceIDs[0] = DEVICE_ID_HEADSET;
                         pAudioDeviceIDs[1] = DEVICE_ID_HANDSFREE;
-                        // FIXME should be capable of returning first item if 1 slot
+                        // should be capable of returning first item if 1 slot
                     }
                     *pNumAudioDevices = 2;
                     break;
@@ -273,7 +270,7 @@ static SLresult IAudioIODeviceCapabilities_QuerySampleFormatsSupported(
         case SL_DEFAULTDEVICEID_AUDIOINPUT:
         case SL_DEFAULTDEVICEID_AUDIOOUTPUT:
             result = SL_RESULT_SUCCESS;
-            // FIXME incomplete
+            // incomplete
             switch (samplingRate) {
             case SL_SAMPLINGRATE_44_1:
                 break;
@@ -284,7 +281,7 @@ static SLresult IAudioIODeviceCapabilities_QuerySampleFormatsSupported(
             if (NULL != pSampleFormats) {
                 if (1 > *pNumOfSampleFormats)
                     result = SL_RESULT_BUFFER_INSUFFICIENT;
-                // FIXME incomplete
+                // incomplete
                 pSampleFormats[0] = SL_PCMSAMPLEFORMAT_FIXED_16;
             }
             *pNumOfSampleFormats = 1;
index fc4e2ac..8e0b63c 100644 (file)
@@ -40,7 +40,6 @@ static SLresult IBufferQueue_Enqueue(SLBufferQueueItf self, const void *pBuffer,
             ++this->mState.count;
             result = SL_RESULT_SUCCESS;
         }
-        //fprintf(stderr, "Enqueue: nbBuffers in queue = %lu\n", this->mState.count);
         interface_unlock_exclusive(this);
     }
 
index cebe807..82650c0 100644 (file)
@@ -27,7 +27,6 @@ static SLresult IDeviceVolume_GetVolumeScale(SLDeviceVolumeItf self, SLuint32 de
     switch (deviceID) {
     case SL_DEFAULTDEVICEID_AUDIOINPUT:
     case SL_DEFAULTDEVICEID_AUDIOOUTPUT:
-    // FIXME move these to device-specific or platform-specific file
     case DEVICE_ID_HEADSET:
     case DEVICE_ID_HANDSFREE:
         if (NULL != pMinValue)
@@ -52,7 +51,7 @@ static SLresult IDeviceVolume_SetVolume(SLDeviceVolumeItf self, SLuint32 deviceI
     SL_ENTER_INTERFACE
 
     switch (deviceID) {
-    // FIXME These are treated same as generic audio output for now
+    // These are treated same as generic audio output for now
     case DEVICE_ID_HEADSET:
     case DEVICE_ID_HANDSFREE:
         deviceID = SL_DEFAULTDEVICEID_AUDIOOUTPUT;
@@ -84,7 +83,7 @@ static SLresult IDeviceVolume_GetVolume(SLDeviceVolumeItf self, SLuint32 deviceI
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
         switch (deviceID) {
-        // FIXME These are treated same as generic audio output for now
+        // These are treated same as generic audio output for now
         case DEVICE_ID_HEADSET:
         case DEVICE_ID_HANDSFREE:
             deviceID = SL_DEFAULTDEVICEID_AUDIOOUTPUT;
@@ -120,7 +119,7 @@ void IDeviceVolume_init(void *self)
 {
     IDeviceVolume *this = (IDeviceVolume *) self;
     this->mItf = &IDeviceVolume_Itf;
-    // FIXME hard-coded array size for default in/out
+    // hard-coded array size for default in/out
     this->mVolume[0] = 10;
     this->mVolume[1] = 10;
 }
index 5e03658..e126601 100644 (file)
@@ -27,7 +27,7 @@ static SLresult IDynamicSource_SetSource(SLDynamicSourceItf self, SLDataSource *
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
         IDynamicSource *this = (IDynamicSource *) self;
-        // FIXME Full implementation of dynamic sources will need a lot more work.
+        // Full implementation of dynamic sources will need a lot more work.
         // It requires validating the new source by itself, validating it with respect
         // to a data sink if appropriate, terminating the current source, and connecting
         // the new source. Note that all this must appear to app to be atomic, yet can actually
@@ -41,7 +41,7 @@ static SLresult IDynamicSource_SetSource(SLDynamicSourceItf self, SLDataSource *
         // need to lock the object, as a change to source can impact most of object
         IObject *thisObject = InterfaceToIObject(this);
         object_lock_exclusive(thisObject);
-        // FIXME a bit of a simplification to say the least!
+        // a bit of a simplification to say the least!
         this->mDataSource = pDataSource;
         object_unlock_exclusive(thisObject);
         result = SL_RESULT_FEATURE_UNSUPPORTED;
index 16e95d3..04410cf 100644 (file)
@@ -24,6 +24,7 @@ static SLresult IEngine_CreateLEDDevice(SLEngineItf self, SLObjectItf *pDevice,
 {
     SL_ENTER_INTERFACE
 
+#ifdef USE_CONFORMANCE
     if (NULL == pDevice || SL_DEFAULTDEVICEID_LED != deviceID) {
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
@@ -42,6 +43,9 @@ static SLresult IEngine_CreateLEDDevice(SLEngineItf self, SLObjectItf *pDevice,
             }
         }
     }
+#else
+    result = SL_RESULT_FEATURE_UNSUPPORTED;
+#endif
 
     SL_LEAVE_INTERFACE
 }
@@ -52,6 +56,7 @@ static SLresult IEngine_CreateVibraDevice(SLEngineItf self, SLObjectItf *pDevice
 {
     SL_ENTER_INTERFACE
 
+#ifdef USE_CONFORMANCE
     if (NULL == pDevice || SL_DEFAULTDEVICEID_VIBRA != deviceID) {
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
@@ -70,6 +75,9 @@ static SLresult IEngine_CreateVibraDevice(SLEngineItf self, SLObjectItf *pDevice
             }
         }
     }
+#else
+    result = SL_RESULT_FEATURE_UNSUPPORTED;
+#endif
 
     SL_LEAVE_INTERFACE
 }
@@ -133,8 +141,7 @@ static SLresult IEngine_CreateAudioPlayer(SLEngineItf self, SLObjectItf *pPlayer
                         break;
 #else
                     {
-                    // FIXME This is b/c we init buffer queues in SndFile below, which is not always
-                    // present
+                    // because we init buffer queues in SndFile below, which is not always present
                     SLuint32 locatorType = *(SLuint32 *) pAudioSrc->pLocator;
                     if (locatorType == SL_DATALOCATOR_BUFFERQUEUE)
                         this->mBufferQueue.mNumBuffers = ((SLDataLocator_BufferQueue *)
@@ -209,6 +216,7 @@ static SLresult IEngine_CreateAudioRecorder(SLEngineItf self, SLObjectItf *pReco
 {
     SL_ENTER_INTERFACE
 
+#ifdef USE_CONFORMANCE
     if (NULL == pRecorder) {
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
@@ -236,7 +244,7 @@ static SLresult IEngine_CreateAudioRecorder(SLEngineItf self, SLObjectItf *pReco
                     if (SL_RESULT_SUCCESS != result)
                         break;
 
-                    // FIXME This section is not yet fully implemented
+                    // This section is not yet fully implemented
 
                     // return the new audio recorder object
                     *pRecorder = &this->mObject.mItf;
@@ -250,6 +258,9 @@ static SLresult IEngine_CreateAudioRecorder(SLEngineItf self, SLObjectItf *pReco
         }
 
     }
+#else
+    result = SL_RESULT_FEATURE_UNSUPPORTED;
+#endif
 
     SL_LEAVE_INTERFACE
 }
@@ -262,6 +273,7 @@ static SLresult IEngine_CreateMidiPlayer(SLEngineItf self, SLObjectItf *pPlayer,
 {
     SL_ENTER_INTERFACE
 
+#ifdef USE_CONFORMANCE
     if (NULL == pPlayer || NULL == pMIDISrc || NULL == pAudioOutput) {
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
@@ -280,6 +292,9 @@ static SLresult IEngine_CreateMidiPlayer(SLEngineItf self, SLObjectItf *pPlayer,
             }
         }
     }
+#else
+    result = SL_RESULT_FEATURE_UNSUPPORTED;
+#endif
 
     SL_LEAVE_INTERFACE
 }
@@ -290,6 +305,7 @@ static SLresult IEngine_CreateListener(SLEngineItf self, SLObjectItf *pListener,
 {
     SL_ENTER_INTERFACE
 
+#ifdef USE_CONFORMANCE
     if (NULL == pListener) {
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
@@ -308,6 +324,9 @@ static SLresult IEngine_CreateListener(SLEngineItf self, SLObjectItf *pListener,
             }
         }
     }
+#else
+    result = SL_RESULT_FEATURE_UNSUPPORTED;
+#endif
 
     SL_LEAVE_INTERFACE
 }
@@ -318,6 +337,7 @@ static SLresult IEngine_Create3DGroup(SLEngineItf self, SLObjectItf *pGroup, SLu
 {
     SL_ENTER_INTERFACE
 
+#ifdef USE_CONFORMANCE
     if (NULL == pGroup) {
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
@@ -337,6 +357,9 @@ static SLresult IEngine_Create3DGroup(SLEngineItf self, SLObjectItf *pGroup, SLu
             }
         }
     }
+#else
+    result = SL_RESULT_FEATURE_UNSUPPORTED;
+#endif
 
     SL_LEAVE_INTERFACE
 }
@@ -375,6 +398,7 @@ static SLresult IEngine_CreateMetadataExtractor(SLEngineItf self, SLObjectItf *p
 {
     SL_ENTER_INTERFACE
 
+#ifdef USE_CONFORMANCE
     if (NULL == pMetadataExtractor) {
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
@@ -395,6 +419,9 @@ static SLresult IEngine_CreateMetadataExtractor(SLEngineItf self, SLObjectItf *p
             }
         }
     }
+#else
+    result = SL_RESULT_FEATURE_UNSUPPORTED;
+#endif
 
     SL_LEAVE_INTERFACE
 }
@@ -429,7 +456,6 @@ static SLresult IEngine_QueryNumSupportedInterfaces(SLEngineItf self,
         if (NULL == class__) {
             result = SL_RESULT_FEATURE_UNSUPPORTED;
         } else {
-            // FIXME Cache this value
             SLuint32 count = 0;
             SLuint32 i;
             for (i = 0; i < class__->mInterfaceCount; ++i)
@@ -458,10 +484,8 @@ static SLresult IEngine_QuerySupportedInterfaces(SLEngineItf self,
             result = SL_RESULT_FEATURE_UNSUPPORTED;
         } else {
             result = SL_RESULT_PARAMETER_INVALID; // will be reset later
-            // FIXME O(n)
             SLuint32 i;
             for (i = 0; i < class__->mInterfaceCount; ++i) {
-                // FIXME check whether published also (might be internal implicit)
                 if (INTERFACE_UNAVAILABLE == class__->mInterfaces[i].mInterface)
                     continue;
                 if (index == 0) {
index 4abf41a..f1524f6 100644 (file)
@@ -229,5 +229,5 @@ void IMIDIMuteSolo_init(void *self)
     this->mTrackMuteMask = 0;
     this->mTrackSoloMask = 0;
     // const
-    this->mTrackCount = 32; // FIXME
+    this->mTrackCount = 32; // wrong
 }
index 99d85ce..daa9133 100644 (file)
@@ -60,7 +60,7 @@ static SLresult IMIDITempo_SetMicrosecondsPerQuarterNote(SLMIDITempoItf self, SL
 {
     SL_ENTER_INTERFACE
 
-    // FIXME spec says zero, is that correct?
+    // spec says zero, is that correct?
     if (!(1 <= uspqn && uspqn <= 16777215)) {
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
@@ -105,6 +105,6 @@ void IMIDITempo_init(void *self)
 {
     IMIDITempo *this = (IMIDITempo *) self;
     this->mItf = &IMIDITempo_Itf;
-    this->mTicksPerQuarterNote = 32; // FIXME
-    this->mMicrosecondsPerQuarterNote = 100; // FIXME
+    this->mTicksPerQuarterNote = 32; // wrong
+    this->mMicrosecondsPerQuarterNote = 100; // wrong
 }
index e4eeb66..2af0d9e 100644 (file)
@@ -128,7 +128,7 @@ static SLresult IMetadataExtraction_AddKeyFilter(SLMetadataExtractionItf self,
         this->mKeySize = keySize;
         this->mKey = pKey;
         this->mKeyEncoding = keyEncoding;
-        this->mValueLangCountry = pValueLangCountry; // FIXME local copy?
+        this->mValueLangCountry = pValueLangCountry; // should make a local copy
         this->mValueEncoding = valueEncoding;
         this->mFilterMask = filterMask;
         interface_unlock_exclusive(this);
index a7a9667..0793eeb 100644 (file)
@@ -88,7 +88,6 @@ static SLresult IMetadataTraversal_GetChildInfo(SLMetadataTraversalItf self, SLu
     SL_ENTER_INTERFACE
 
     //IMetadataTraversal *this = (IMetadataTraversal *) self;
-    // FIXME not implemented
     result = SL_RESULT_FEATURE_UNSUPPORTED;
 
     SL_LEAVE_INTERFACE
@@ -104,7 +103,6 @@ static SLresult IMetadataTraversal_SetActiveNode(SLMetadataTraversalItf self, SL
     }
     IMetadataTraversal *this = (IMetadataTraversal *) self;
     this->mIndex = index;
-    // FIXME not implemented
     result = SL_RESULT_PARAMETER_INVALID;
 
     SL_LEAVE_INTERFACE
index b073f44..e82a098 100644 (file)
@@ -373,7 +373,6 @@ static SLresult IObject_RegisterCallback(SLObjectItf self,
 
 static void Abort_internal(IObject *this, SLboolean shutdown)
 {
-    // FIXME Aborting asynchronous operations during phase 2 is not yet implemented
     const ClassTable *class__ = this->mClass;
     object_lock_exclusive(this);
     // Abort asynchronous operations on the object
@@ -388,7 +387,6 @@ static void Abort_internal(IObject *this, SLboolean shutdown)
         break;
     }
     // Abort asynchronous operations on interfaces
-    // FIXME O(n), could be O(1) using a generation count
     SLuint8 *interfaceStateP = this->mInterfaceStates;
     unsigned index;
     for (index = 0; index < class__->mInterfaceCount; ++index, ++interfaceStateP) {
@@ -403,12 +401,6 @@ static void Abort_internal(IObject *this, SLboolean shutdown)
             break;
         }
     }
-#if 0
-    // FIXME Not fully implemented, the intention is to advise other threads to exit from sync ops
-    // FIXME Also need to wait for async ops to recognize the shutdown
-    if (shutdown)
-        this->mShutdown = SL_BOOLEAN_TRUE;
-#endif
     object_unlock_exclusive(this);
 }
 
@@ -428,10 +420,6 @@ static void IObject_Destroy(SLObjectItf self)
 {
     SL_ENTER_INTERFACE_VOID
 
-    // FIXME Check for dependencies, e.g. destroying an output mix with attached players,
-    //       destroying an engine with extant objects, etc.
-    // FIXME The abort should be atomic w.r.t. destroy, so another async can't be started in window
-    // FIXME Destroy may need to be made asynchronous to permit safe cleanup of resources
     IObject *this = (IObject *) self;
     Abort_internal(this, SL_BOOLEAN_TRUE);
     const ClassTable *class__ = this->mClass;
@@ -504,7 +492,6 @@ static void IObject_Destroy(SLObjectItf self)
     free(this);
     // one or more interfaces was actively changing at time of Destroy
     assert(incorrect == 0);
-    // FIXME assert might be the wrong thing to do; instead block until active ops complete?
 
     SL_LEAVE_INTERFACE_VOID
 }
@@ -514,12 +501,16 @@ static SLresult IObject_SetPriority(SLObjectItf self, SLint32 priority, SLboolea
 {
     SL_ENTER_INTERFACE
 
+#ifdef USE_CONFORMANCE
     IObject *this = (IObject *) self;
     object_lock_exclusive(this);
     this->mPriority = priority;
     this->mPreemptable = SL_BOOLEAN_FALSE != preemptable; // normalize
     object_unlock_exclusive(this);
     result = SL_RESULT_SUCCESS;
+#else
+    result = SL_RESULT_FEATURE_UNSUPPORTED;
+#endif
 
     SL_LEAVE_INTERFACE
 }
@@ -529,6 +520,7 @@ static SLresult IObject_GetPriority(SLObjectItf self, SLint32 *pPriority, SLbool
 {
     SL_ENTER_INTERFACE
 
+#ifdef USE_CONFORMANCE
     if (NULL == pPriority || NULL == pPreemptable) {
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
@@ -541,6 +533,9 @@ static SLresult IObject_GetPriority(SLObjectItf self, SLint32 *pPriority, SLbool
         *pPreemptable = preemptable;
         result = SL_RESULT_SUCCESS;
     }
+#else
+    result = SL_RESULT_FEATURE_UNSUPPORTED;
+#endif
 
     SL_LEAVE_INTERFACE
 }
@@ -551,6 +546,7 @@ static SLresult IObject_SetLossOfControlInterfaces(SLObjectItf self,
 {
     SL_ENTER_INTERFACE
 
+#ifdef USE_CONFORMANCE
     result = SL_RESULT_SUCCESS;
     if (0 < numInterfaces) {
         SLuint32 i;
@@ -560,7 +556,7 @@ static SLresult IObject_SetLossOfControlInterfaces(SLObjectItf self,
             IObject *this = (IObject *) self;
             const ClassTable *class__ = this->mClass;
             unsigned lossOfControlMask = 0;
-            // FIXME The cast is due to a typo in the spec
+            // The cast is due to a typo in the spec, bug 6482
             for (i = 0; i < (SLuint32) numInterfaces; ++i) {
                 SLInterfaceID iid = pInterfaceIDs[i];
                 if (NULL == iid) {
@@ -568,7 +564,7 @@ static SLresult IObject_SetLossOfControlInterfaces(SLObjectItf self,
                     goto out;
                 }
                 int MPH, index;
-                // FIXME no error if invalid MPH or index?
+                // We ignore without error any invalid MPH or index, but spec is unclear
                 if ((0 <= (MPH = IID_to_MPH(iid))) && (0 <= (index = class__->mMPH_to_index[MPH])))
                     lossOfControlMask |= (1 << index);
             }
@@ -581,6 +577,9 @@ static SLresult IObject_SetLossOfControlInterfaces(SLObjectItf self,
         }
     }
 out:
+#else
+    result = SL_RESULT_FEATURE_UNSUPPORTED;
+#endif
 
     SL_LEAVE_INTERFACE
 }
@@ -614,8 +613,10 @@ void IObject_init(void *self)
     this->mAttributesMask = 0;
     this->mCallback = NULL;
     this->mContext = NULL;
+#ifdef USE_CONFORMANCE
     this->mPriority = SL_PRIORITY_NORMAL;
     this->mPreemptable = SL_BOOLEAN_FALSE;
+#endif
     int ok;
     ok = pthread_mutex_init(&this->mMutex, (const pthread_mutexattr_t *) NULL);
     assert(0 == ok);
index 98a405a..05ce8a7 100644 (file)
@@ -137,7 +137,7 @@ static void IOutputMixExt_FillBuffer(SLOutputMixExtItf self, void *pBuffer, SLui
                 }
                 // no lock, but safe b/c noone else updates this field
                 track->mFrameCounter += actual >> 2;    // sizeof(short) * STEREO_CHANNELS
-                // FIXME Calling the callback too often, should depend on requested update period
+                // NTH Calling the callback too often, should depend on requested update period
                 if (audioPlayer->mPlay.mCallback)
                     (*audioPlayer->mPlay.mCallback)(&audioPlayer->mPlay.mItf,
                         audioPlayer->mPlay.mContext, SL_PLAYEVENT_HEADMOVING);
@@ -156,7 +156,7 @@ got_one:
                     interface_unlock_shared(bufferQueue);
                     continue;
                 }
-                // FIXME should be able to configure when to
+                // NTH should be able to configure when to
                 // kick off the callback e.g. high/low water-marks etc.
                 // need data but none available, attempt a desperate callback
                 slBufferQueueCallback callback = bufferQueue->mCallback;
@@ -172,7 +172,7 @@ got_one:
                     // unlucky, queue still empty, the callback failed
                 }
                 // here on underflow due to no callback, or failed callback
-                // FIXME underflow, send silence (or previous buffer?)
+                // NTH underflow, send silence (or previous buffer?)
                 // we did a callback to try to kick start again but failed
                 // should log this
             }
diff --git a/opensles/libopensles/OpenSLUT.c b/opensles/libopensles/OpenSLUT.c
new file mode 100644 (file)
index 0000000..cf104c3
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* OpenSL ES Utility Toolkit */
+
+#include "OpenSLES.h"
+#include "OpenSLUT.h"
+#include <stdio.h>
+#include <string.h>
+
+const char * const slutResultStrings[SLUT_RESULT_MAX] = {
+    "SUCCESS",
+    "PRECONDITIONS_VIOLATED",
+    "PARAMETER_INVALID",
+    "MEMORY_FAILURE",
+    "RESOURCE_ERROR",
+    "RESOURCE_LOST",
+    "IO_ERROR",
+    "BUFFER_INSUFFICIENT",
+    "CONTENT_CORRUPTED",
+    "CONTENT_UNSUPPORTED",
+    "CONTENT_NOT_FOUND",
+    "PERMISSION_DENIED",
+    "FEATURE_UNSUPPORTED",
+    "INTERNAL_ERROR",
+    "UNKNOWN_ERROR",
+    "OPERATION_ABORTED",
+    "CONTROL_LOST"
+};
+
+typedef struct
+{
+    const SLInterfaceID *iid;
+    const char *name;
+} Pair;
+
+// ## is token concatenation e.g. a##b becomes ab
+// # is stringize operator to convert a symbol to a string constant e.g. #a becomes "a"
+
+#define _(x) { &SL_IID_##x, #x }
+
+Pair pairs[] = {
+    _(3DCOMMIT),
+    _(3DDOPPLER),
+    _(3DGROUPING),
+    _(3DLOCATION),
+    _(3DMACROSCOPIC),
+    _(3DSOURCE),
+    _(AUDIODECODERCAPABILITIES),
+    _(AUDIOENCODER),
+    _(AUDIOENCODERCAPABILITIES),
+    _(AUDIOIODEVICECAPABILITIES),
+    _(BASSBOOST),
+    _(BUFFERQUEUE),
+    _(DEVICEVOLUME),
+    _(DYNAMICINTERFACEMANAGEMENT),
+    _(DYNAMICSOURCE),
+    _(EFFECTSEND),
+    _(ENGINE),
+    _(ENGINECAPABILITIES),
+    _(ENVIRONMENTALREVERB),
+    _(EQUALIZER),
+    _(LED),
+    _(METADATAEXTRACTION),
+    _(METADATATRAVERSAL),
+    _(MIDIMESSAGE),
+    _(MIDIMUTESOLO),
+    _(MIDITEMPO),
+    _(MIDITIME),
+    _(MUTESOLO),
+    _(NULL),
+    _(OBJECT),
+    _(OUTPUTMIX),
+    _(PITCH),
+    _(PLAY),
+    _(PLAYBACKRATE),
+    _(PREFETCHSTATUS),
+    _(PRESETREVERB),
+    _(RATEPITCH),
+    _(RECORD),
+    _(SEEK),
+    _(THREADSYNC),
+    _(VIBRA),
+    _(VIRTUALIZER),
+    _(VISUALIZATION),
+    _(VOLUME)
+};
+
+void slutPrintIID(SLInterfaceID iid)
+{
+    Pair *p;
+    const Pair *end = &pairs[sizeof(pairs)/sizeof(pairs[0])];
+    for (p = pairs; p != end; ++p) {
+        if (!memcmp(*p->iid, iid, sizeof(struct SLInterfaceID_))) {
+            printf("SL_IID_%s = ", p->name);
+            break;
+        }
+    }
+    printf(
+        "{ 0x%08X, 0x%04X, 0x%04X, 0x%04X, { 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X } }\n",
+        (unsigned) iid->time_low, iid->time_mid, iid->time_hi_and_version, iid->clock_seq,
+        iid->node[0], iid->node[1], iid->node[2], iid->node[3], iid->node[4], iid->node[5]);
+}
diff --git a/opensles/libopensles/OpenSLUT.h b/opensles/libopensles/OpenSLUT.h
new file mode 100644 (file)
index 0000000..a32d23a
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* OpenSL ES Utility Toolkit */
+
+#define SLUT_RESULT_MAX (SL_RESULT_CONTROL_LOST + 1)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern const char * const slutResultStrings[SLUT_RESULT_MAX];
+
+#ifdef __cplusplus
+}
+#endif
index a962a18..09d8e2e 100644 (file)
@@ -63,7 +63,7 @@ void SndFile_Callback(SLBufferQueueItf caller, void *pContext)
         assert(SL_RESULT_SUCCESS == result);
     } else {
         object_lock_exclusive(&thisAP->mObject);
-        // FIXME Uh not yet - we just ran out of new data to enqueue,
+        // Should not pause yet - we just ran out of new data to enqueue,
         // but there may still be (partially) full buffers in the queue.
         thisAP->mPlay.mState = SL_PLAYSTATE_PAUSED;
         thisAP->mPlay.mPosition = thisAP->mPlay.mDuration;
@@ -155,7 +155,7 @@ void audioPlayerTransportUpdate(CAudioPlayer *audioPlayer)
 
     if ((SL_TIME_UNKNOWN != pos) && (NULL != audioPlayer->mSndFile.mSNDFILE)) {
         pthread_mutex_lock(&audioPlayer->mSndFile.mMutex);
-        // FIXME use pos not 0
+        // use pos not 0
         (void) sf_seek(audioPlayer->mSndFile.mSNDFILE, (sf_count_t) 0, SEEK_SET);
         audioPlayer->mSndFile.mEOF = SL_BOOLEAN_FALSE;
         pthread_mutex_unlock(&audioPlayer->mSndFile.mMutex);
index 32c4954..0ceb8e3 100644 (file)
 // 3DGroup class
 
 static const struct iid_vtable _3DGroup_interfaces[INTERFACES_3DGroup] = {
-    {MPH_OBJECT, INTERFACE_IMPLICIT,
-        offsetof(C3DGroup, mObject)},
+    {MPH_OBJECT, INTERFACE_IMPLICIT, offsetof(C3DGroup, mObject)},
     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
         offsetof(C3DGroup, mDynamicInterfaceManagement)},
-    {MPH_3DLOCATION, INTERFACE_IMPLICIT,
-        offsetof(C3DGroup, m3DLocation)},
-    {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME,
-        offsetof(C3DGroup, m3DDoppler)},
-    {MPH_3DSOURCE, INTERFACE_GAME,
-        offsetof(C3DGroup, m3DSource)},
-    {MPH_3DMACROSCOPIC, INTERFACE_OPTIONAL,
-        offsetof(C3DGroup, m3DMacroscopic)},
+    {MPH_3DLOCATION, INTERFACE_IMPLICIT, offsetof(C3DGroup, m3DLocation)},
+    {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME, offsetof(C3DGroup, m3DDoppler)},
+    {MPH_3DSOURCE, INTERFACE_GAME, offsetof(C3DGroup, m3DSource)},
+    {MPH_3DMACROSCOPIC, INTERFACE_OPTIONAL, offsetof(C3DGroup, m3DMacroscopic)},
 };
 
 static const ClassTable C3DGroup_class = {
@@ -50,62 +45,40 @@ static const ClassTable C3DGroup_class = {
 // AudioPlayer class
 
 static const struct iid_vtable AudioPlayer_interfaces[INTERFACES_AudioPlayer] = {
-    {MPH_OBJECT, INTERFACE_IMPLICIT,
-        offsetof(CAudioPlayer, mObject)},
+    {MPH_OBJECT, INTERFACE_IMPLICIT, offsetof(CAudioPlayer, mObject)},
     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
         offsetof(CAudioPlayer, mDynamicInterfaceManagement)},
-    {MPH_PLAY, INTERFACE_IMPLICIT,
-        offsetof(CAudioPlayer, mPlay)},
-    {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME,
-        offsetof(CAudioPlayer, m3DDoppler)},
-    {MPH_3DGROUPING, INTERFACE_GAME,
-        offsetof(CAudioPlayer, m3DGrouping)},
-    {MPH_3DLOCATION, INTERFACE_GAME,
-        offsetof(CAudioPlayer, m3DLocation)},
-    {MPH_3DSOURCE, INTERFACE_GAME,
-        offsetof(CAudioPlayer, m3DSource)},
-    // FIXME Currently we create an internal buffer queue for playing files
-    {MPH_BUFFERQUEUE, /* INTERFACE_GAME */ INTERFACE_IMPLICIT,
-        offsetof(CAudioPlayer, mBufferQueue)},
-    {MPH_EFFECTSEND, INTERFACE_MUSIC_GAME,
-        offsetof(CAudioPlayer, mEffectSend)},
-    {MPH_MUTESOLO, INTERFACE_GAME,
-        offsetof(CAudioPlayer, mMuteSolo)},
-    {MPH_METADATAEXTRACTION, INTERFACE_MUSIC_GAME,
-        offsetof(CAudioPlayer, mMetadataExtraction)},
-    {MPH_METADATATRAVERSAL, INTERFACE_MUSIC_GAME,
-        offsetof(CAudioPlayer, mMetadataTraversal)},
-    {MPH_PREFETCHSTATUS, INTERFACE_EXPLICIT,
-        offsetof(CAudioPlayer, mPrefetchStatus)},
-    {MPH_RATEPITCH, INTERFACE_DYNAMIC_GAME,
-        offsetof(CAudioPlayer, mRatePitch)},
-    {MPH_SEEK, INTERFACE_EXPLICIT,
-        offsetof(CAudioPlayer, mSeek)},
-    {MPH_VOLUME, INTERFACE_TBD,
-        offsetof(CAudioPlayer, mVolume)},
-    {MPH_3DMACROSCOPIC, INTERFACE_OPTIONAL,
-        offsetof(CAudioPlayer, m3DMacroscopic)},
-    {MPH_BASSBOOST, INTERFACE_OPTIONAL,
-        offsetof(CAudioPlayer, mBassBoost)},
-    {MPH_DYNAMICSOURCE, INTERFACE_OPTIONAL,
-        offsetof(CAudioPlayer, mDynamicSource)},
-    {MPH_ENVIRONMENTALREVERB, INTERFACE_OPTIONAL,
-        offsetof(CAudioPlayer, mEnvironmentalReverb)},
-    {MPH_EQUALIZER, INTERFACE_OPTIONAL,
-        offsetof(CAudioPlayer, mEqualizer)},
-    {MPH_PITCH, INTERFACE_OPTIONAL,
-        offsetof(CAudioPlayer, mPitch)},
-    {MPH_PRESETREVERB, INTERFACE_OPTIONAL,
-        offsetof(CAudioPlayer, mPresetReverb)},
-    {MPH_PLAYBACKRATE, INTERFACE_OPTIONAL,
-        offsetof(CAudioPlayer, mPlaybackRate)},
-    {MPH_VIRTUALIZER, INTERFACE_OPTIONAL,
-        offsetof(CAudioPlayer, mVirtualizer)},
-    {MPH_VISUALIZATION, INTERFACE_OPTIONAL,
-        offsetof(CAudioPlayer, mVisualization)},
+    {MPH_PLAY, INTERFACE_IMPLICIT, offsetof(CAudioPlayer, mPlay)},
+    {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME, offsetof(CAudioPlayer, m3DDoppler)},
+    {MPH_3DGROUPING, INTERFACE_GAME, offsetof(CAudioPlayer, m3DGrouping)},
+    {MPH_3DLOCATION, INTERFACE_GAME, offsetof(CAudioPlayer, m3DLocation)},
+    {MPH_3DSOURCE, INTERFACE_GAME, offsetof(CAudioPlayer, m3DSource)},
+#ifdef USE_SNDFILE
+    // Currently we create an internal buffer queue for playing encoded files
+    {MPH_BUFFERQUEUE, INTERFACE_IMPLICIT, offsetof(CAudioPlayer, mBufferQueue)},
+#else
+    {MPH_BUFFERQUEUE, INTERFACE_GAME, offsetof(CAudioPlayer, mBufferQueue)},
+#endif
+    {MPH_EFFECTSEND, INTERFACE_MUSIC_GAME, offsetof(CAudioPlayer, mEffectSend)},
+    {MPH_MUTESOLO, INTERFACE_GAME, offsetof(CAudioPlayer, mMuteSolo)},
+    {MPH_METADATAEXTRACTION, INTERFACE_MUSIC_GAME, offsetof(CAudioPlayer, mMetadataExtraction)},
+    {MPH_METADATATRAVERSAL, INTERFACE_MUSIC_GAME, offsetof(CAudioPlayer, mMetadataTraversal)},
+    {MPH_PREFETCHSTATUS, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mPrefetchStatus)},
+    {MPH_RATEPITCH, INTERFACE_DYNAMIC_GAME, offsetof(CAudioPlayer, mRatePitch)},
+    {MPH_SEEK, INTERFACE_EXPLICIT, offsetof(CAudioPlayer, mSeek)},
+    {MPH_VOLUME, INTERFACE_TBD, offsetof(CAudioPlayer, mVolume)},
+    {MPH_3DMACROSCOPIC, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, m3DMacroscopic)},
+    {MPH_BASSBOOST, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, mBassBoost)},
+    {MPH_DYNAMICSOURCE, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, mDynamicSource)},
+    {MPH_ENVIRONMENTALREVERB, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, mEnvironmentalReverb)},
+    {MPH_EQUALIZER, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, mEqualizer)},
+    {MPH_PITCH, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, mPitch)},
+    {MPH_PRESETREVERB, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, mPresetReverb)},
+    {MPH_PLAYBACKRATE, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, mPlaybackRate)},
+    {MPH_VIRTUALIZER, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, mVirtualizer)},
+    {MPH_VISUALIZATION, INTERFACE_OPTIONAL, offsetof(CAudioPlayer, mVisualization)},
 #ifdef ANDROID
-    {MPH_ANDROIDSTREAMTYPE, INTERFACE_IMPLICIT,
-        offsetof(CAudioPlayer, mAndroidStreamType)},
+    {MPH_ANDROIDSTREAMTYPE, INTERFACE_IMPLICIT, offsetof(CAudioPlayer, mAndroidStreamType)},
 #endif
 };
 
@@ -124,24 +97,16 @@ static const ClassTable CAudioPlayer_class = {
 // AudioRecorder class
 
 static const struct iid_vtable AudioRecorder_interfaces[INTERFACES_AudioRecorder] = {
-    {MPH_OBJECT, INTERFACE_IMPLICIT,
-        offsetof(CAudioRecorder, mObject)},
+    {MPH_OBJECT, INTERFACE_IMPLICIT, offsetof(CAudioRecorder, mObject)},
     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
         offsetof(CAudioRecorder, mDynamicInterfaceManagement)},
-    {MPH_RECORD, INTERFACE_IMPLICIT,
-        offsetof(CAudioRecorder, mRecord)},
-    {MPH_AUDIOENCODER, INTERFACE_TBD,
-        offsetof(CAudioRecorder, mAudioEncoder)},
-    {MPH_BASSBOOST, INTERFACE_OPTIONAL,
-        offsetof(CAudioRecorder, mBassBoost)},
-    {MPH_DYNAMICSOURCE, INTERFACE_OPTIONAL,
-        offsetof(CAudioRecorder, mDynamicSource)},
-    {MPH_EQUALIZER, INTERFACE_OPTIONAL,
-        offsetof(CAudioRecorder, mEqualizer)},
-    {MPH_VISUALIZATION, INTERFACE_OPTIONAL,
-        offsetof(CAudioRecorder, mVisualization)},
-    {MPH_VOLUME, INTERFACE_OPTIONAL,
-        offsetof(CAudioRecorder, mVolume)}
+    {MPH_RECORD, INTERFACE_IMPLICIT, offsetof(CAudioRecorder, mRecord)},
+    {MPH_AUDIOENCODER, INTERFACE_TBD, offsetof(CAudioRecorder, mAudioEncoder)},
+    {MPH_BASSBOOST, INTERFACE_OPTIONAL, offsetof(CAudioRecorder, mBassBoost)},
+    {MPH_DYNAMICSOURCE, INTERFACE_OPTIONAL, offsetof(CAudioRecorder, mDynamicSource)},
+    {MPH_EQUALIZER, INTERFACE_OPTIONAL, offsetof(CAudioRecorder, mEqualizer)},
+    {MPH_VISUALIZATION, INTERFACE_OPTIONAL, offsetof(CAudioRecorder, mVisualization)},
+    {MPH_VOLUME, INTERFACE_OPTIONAL, offsetof(CAudioRecorder, mVolume)}
 };
 
 static const ClassTable CAudioRecorder_class = {
@@ -159,26 +124,20 @@ static const ClassTable CAudioRecorder_class = {
 // Engine class
 
 static const struct iid_vtable Engine_interfaces[INTERFACES_Engine] = {
-    {MPH_OBJECT, INTERFACE_IMPLICIT,
-        offsetof(CEngine, mObject)},
-    {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
+    {MPH_OBJECT, INTERFACE_IMPLICIT, offsetof(CEngine, mObject)},
+    {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT_CT,
         offsetof(CEngine, mDynamicInterfaceManagement)},
-    {MPH_ENGINE, INTERFACE_IMPLICIT,
-        offsetof(CEngine, mEngine)},
-    {MPH_ENGINECAPABILITIES, INTERFACE_IMPLICIT,
-        offsetof(CEngine, mEngineCapabilities)},
-    {MPH_THREADSYNC, INTERFACE_IMPLICIT,
-        offsetof(CEngine, mThreadSync)},
-    {MPH_AUDIOIODEVICECAPABILITIES, INTERFACE_IMPLICIT,
+    {MPH_ENGINE, INTERFACE_IMPLICIT, offsetof(CEngine, mEngine)},
+    {MPH_ENGINECAPABILITIES, INTERFACE_IMPLICIT_CT, offsetof(CEngine, mEngineCapabilities)},
+    {MPH_THREADSYNC, INTERFACE_IMPLICIT_CT, offsetof(CEngine, mThreadSync)},
+    {MPH_AUDIOIODEVICECAPABILITIES, INTERFACE_IMPLICIT_CT,
         offsetof(CEngine, mAudioIODeviceCapabilities)},
-    {MPH_AUDIODECODERCAPABILITIES, INTERFACE_EXPLICIT,
+    {MPH_AUDIODECODERCAPABILITIES, INTERFACE_EXPLICIT_CT,
         offsetof(CEngine, mAudioDecoderCapabilities)},
-    {MPH_AUDIOENCODERCAPABILITIES, INTERFACE_EXPLICIT,
+    {MPH_AUDIOENCODERCAPABILITIES, INTERFACE_EXPLICIT_CT,
         offsetof(CEngine, mAudioEncoderCapabilities)},
-    {MPH_3DCOMMIT, INTERFACE_EXPLICIT_GAME,
-        offsetof(CEngine, m3DCommit)},
-    {MPH_DEVICEVOLUME, INTERFACE_OPTIONAL,
-        offsetof(CEngine, mDeviceVolume)}
+    {MPH_3DCOMMIT, INTERFACE_EXPLICIT_GAME_CT, offsetof(CEngine, m3DCommit)},
+    {MPH_DEVICEVOLUME, INTERFACE_OPTIONAL_CT, offsetof(CEngine, mDeviceVolume)}
 };
 
 static const ClassTable CEngine_class = {
@@ -196,12 +155,10 @@ static const ClassTable CEngine_class = {
 // LEDDevice class
 
 static const struct iid_vtable LEDDevice_interfaces[INTERFACES_LEDDevice] = {
-    {MPH_OBJECT, INTERFACE_IMPLICIT,
-        offsetof(CLEDDevice, mObject)},
+    {MPH_OBJECT, INTERFACE_IMPLICIT, offsetof(CLEDDevice, mObject)},
     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
         offsetof(CLEDDevice, mDynamicInterfaceManagement)},
-    {MPH_LED, INTERFACE_IMPLICIT,
-        offsetof(CLEDDevice, mLEDArray)}
+    {MPH_LED, INTERFACE_IMPLICIT, offsetof(CLEDDevice, mLEDArray)}
 };
 
 static const ClassTable CLEDDevice_class = {
@@ -219,14 +176,11 @@ static const ClassTable CLEDDevice_class = {
 // Listener class
 
 static const struct iid_vtable Listener_interfaces[INTERFACES_Listener] = {
-    {MPH_OBJECT, INTERFACE_IMPLICIT,
-        offsetof(CListener, mObject)},
+    {MPH_OBJECT, INTERFACE_IMPLICIT, offsetof(CListener, mObject)},
     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
         offsetof(CListener, mDynamicInterfaceManagement)},
-    {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME,
-        offsetof(C3DGroup, m3DDoppler)},
-    {MPH_3DLOCATION, INTERFACE_EXPLICIT_GAME,
-        offsetof(C3DGroup, m3DLocation)}
+    {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME, offsetof(C3DGroup, m3DDoppler)},
+    {MPH_3DLOCATION, INTERFACE_EXPLICIT_GAME, offsetof(C3DGroup, m3DLocation)}
 };
 
 static const ClassTable CListener_class = {
@@ -244,16 +198,12 @@ static const ClassTable CListener_class = {
 // MetadataExtractor class
 
 static const struct iid_vtable MetadataExtractor_interfaces[INTERFACES_MetadataExtractor] = {
-    {MPH_OBJECT, INTERFACE_IMPLICIT,
-        offsetof(CMetadataExtractor, mObject)},
+    {MPH_OBJECT, INTERFACE_IMPLICIT, offsetof(CMetadataExtractor, mObject)},
     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
         offsetof(CMetadataExtractor, mDynamicInterfaceManagement)},
-    {MPH_DYNAMICSOURCE, INTERFACE_IMPLICIT,
-        offsetof(CMetadataExtractor, mDynamicSource)},
-    {MPH_METADATAEXTRACTION, INTERFACE_IMPLICIT,
-        offsetof(CMetadataExtractor, mMetadataExtraction)},
-    {MPH_METADATATRAVERSAL, INTERFACE_IMPLICIT,
-        offsetof(CMetadataExtractor, mMetadataTraversal)}
+    {MPH_DYNAMICSOURCE, INTERFACE_IMPLICIT, offsetof(CMetadataExtractor, mDynamicSource)},
+    {MPH_METADATAEXTRACTION, INTERFACE_IMPLICIT, offsetof(CMetadataExtractor, mMetadataExtraction)},
+    {MPH_METADATATRAVERSAL, INTERFACE_IMPLICIT, offsetof(CMetadataExtractor, mMetadataTraversal)}
 };
 
 static const ClassTable CMetadataExtractor_class = {
@@ -271,67 +221,38 @@ static const ClassTable CMetadataExtractor_class = {
 // MidiPlayer class
 
 static const struct iid_vtable MidiPlayer_interfaces[INTERFACES_MidiPlayer] = {
-    {MPH_OBJECT, INTERFACE_IMPLICIT,
-        offsetof(CMidiPlayer, mObject)},
+    {MPH_OBJECT, INTERFACE_IMPLICIT, offsetof(CMidiPlayer, mObject)},
     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
         offsetof(CMidiPlayer, mDynamicInterfaceManagement)},
-    {MPH_PLAY, INTERFACE_IMPLICIT,
-        offsetof(CMidiPlayer, mPlay)},
-    {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME,
-        offsetof(C3DGroup, m3DDoppler)},
-    {MPH_3DGROUPING, INTERFACE_GAME,
-        offsetof(CMidiPlayer, m3DGrouping)},
-    {MPH_3DLOCATION, INTERFACE_GAME,
-        offsetof(CMidiPlayer, m3DLocation)},
-    {MPH_3DSOURCE, INTERFACE_GAME,
-        offsetof(CMidiPlayer, m3DSource)},
-    {MPH_BUFFERQUEUE, INTERFACE_GAME,
-        offsetof(CMidiPlayer, mBufferQueue)},
-    {MPH_EFFECTSEND, INTERFACE_GAME,
-        offsetof(CMidiPlayer, mEffectSend)},
-    {MPH_MUTESOLO, INTERFACE_GAME,
-        offsetof(CMidiPlayer, mMuteSolo)},
-    {MPH_METADATAEXTRACTION, INTERFACE_GAME,
-        offsetof(CMidiPlayer, mMetadataExtraction)},
-    {MPH_METADATATRAVERSAL, INTERFACE_GAME,
-        offsetof(CMidiPlayer, mMetadataTraversal)},
-    {MPH_MIDIMESSAGE, INTERFACE_PHONE_GAME,
-        offsetof(CMidiPlayer, mMIDIMessage)},
-    {MPH_MIDITIME, INTERFACE_PHONE_GAME,
-        offsetof(CMidiPlayer, mMIDITime)},
-    {MPH_MIDITEMPO, INTERFACE_PHONE_GAME,
-        offsetof(CMidiPlayer, mMIDITempo)},
-    {MPH_MIDIMUTESOLO, INTERFACE_GAME,
-        offsetof(CMidiPlayer, mMIDIMuteSolo)},
-    {MPH_PREFETCHSTATUS, INTERFACE_PHONE_GAME,
-        offsetof(CMidiPlayer, mPrefetchStatus)},
-    {MPH_SEEK, INTERFACE_PHONE_GAME,
-        offsetof(CMidiPlayer, mSeek)},
-    {MPH_VOLUME, INTERFACE_PHONE_GAME,
-        offsetof(CMidiPlayer, mVolume)},
-    {MPH_3DMACROSCOPIC, INTERFACE_OPTIONAL,
-        offsetof(CMidiPlayer, m3DMacroscopic)},
-    {MPH_BASSBOOST, INTERFACE_OPTIONAL,
-        offsetof(CMidiPlayer, mBassBoost)},
-    {MPH_DYNAMICSOURCE, INTERFACE_OPTIONAL,
-        offsetof(CMidiPlayer, mDynamicSource)},
-    {MPH_ENVIRONMENTALREVERB, INTERFACE_OPTIONAL,
-        offsetof(CMidiPlayer, mEnvironmentalReverb)},
-    {MPH_EQUALIZER, INTERFACE_OPTIONAL,
-        offsetof(CMidiPlayer, mEqualizer)},
-    {MPH_PITCH, INTERFACE_OPTIONAL,
-        offsetof(CMidiPlayer, mPitch)},
-    {MPH_PRESETREVERB, INTERFACE_OPTIONAL,
-        offsetof(CMidiPlayer, mPresetReverb)},
-    {MPH_PLAYBACKRATE, INTERFACE_OPTIONAL,
-        offsetof(CMidiPlayer, mPlaybackRate)},
-    {MPH_VIRTUALIZER, INTERFACE_OPTIONAL,
-        offsetof(CMidiPlayer, mVirtualizer)},
-    {MPH_VISUALIZATION, INTERFACE_OPTIONAL,
-        offsetof(CMidiPlayer, mVisualization)},
+    {MPH_PLAY, INTERFACE_IMPLICIT, offsetof(CMidiPlayer, mPlay)},
+    {MPH_3DDOPPLER, INTERFACE_DYNAMIC_GAME, offsetof(C3DGroup, m3DDoppler)},
+    {MPH_3DGROUPING, INTERFACE_GAME, offsetof(CMidiPlayer, m3DGrouping)},
+    {MPH_3DLOCATION, INTERFACE_GAME, offsetof(CMidiPlayer, m3DLocation)},
+    {MPH_3DSOURCE, INTERFACE_GAME, offsetof(CMidiPlayer, m3DSource)},
+    {MPH_BUFFERQUEUE, INTERFACE_GAME, offsetof(CMidiPlayer, mBufferQueue)},
+    {MPH_EFFECTSEND, INTERFACE_GAME, offsetof(CMidiPlayer, mEffectSend)},
+    {MPH_MUTESOLO, INTERFACE_GAME, offsetof(CMidiPlayer, mMuteSolo)},
+    {MPH_METADATAEXTRACTION, INTERFACE_GAME, offsetof(CMidiPlayer, mMetadataExtraction)},
+    {MPH_METADATATRAVERSAL, INTERFACE_GAME, offsetof(CMidiPlayer, mMetadataTraversal)},
+    {MPH_MIDIMESSAGE, INTERFACE_PHONE_GAME, offsetof(CMidiPlayer, mMIDIMessage)},
+    {MPH_MIDITIME, INTERFACE_PHONE_GAME, offsetof(CMidiPlayer, mMIDITime)},
+    {MPH_MIDITEMPO, INTERFACE_PHONE_GAME, offsetof(CMidiPlayer, mMIDITempo)},
+    {MPH_MIDIMUTESOLO, INTERFACE_GAME, offsetof(CMidiPlayer, mMIDIMuteSolo)},
+    {MPH_PREFETCHSTATUS, INTERFACE_PHONE_GAME, offsetof(CMidiPlayer, mPrefetchStatus)},
+    {MPH_SEEK, INTERFACE_PHONE_GAME, offsetof(CMidiPlayer, mSeek)},
+    {MPH_VOLUME, INTERFACE_PHONE_GAME, offsetof(CMidiPlayer, mVolume)},
+    {MPH_3DMACROSCOPIC, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, m3DMacroscopic)},
+    {MPH_BASSBOOST, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, mBassBoost)},
+    {MPH_DYNAMICSOURCE, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, mDynamicSource)},
+    {MPH_ENVIRONMENTALREVERB, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, mEnvironmentalReverb)},
+    {MPH_EQUALIZER, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, mEqualizer)},
+    {MPH_PITCH, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, mPitch)},
+    {MPH_PRESETREVERB, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, mPresetReverb)},
+    {MPH_PLAYBACKRATE, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, mPlaybackRate)},
+    {MPH_VIRTUALIZER, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, mVirtualizer)},
+    {MPH_VISUALIZATION, INTERFACE_OPTIONAL, offsetof(CMidiPlayer, mVisualization)},
 #ifdef ANDROID
-    {MPH_ANDROIDSTREAMTYPE, INTERFACE_IMPLICIT,
-        offsetof(CMidiPlayer, mAndroidStreamType)},
+    {MPH_ANDROIDSTREAMTYPE, INTERFACE_IMPLICIT, offsetof(CMidiPlayer, mAndroidStreamType)},
 #endif
 };
 
@@ -350,34 +271,24 @@ static const ClassTable CMidiPlayer_class = {
 // OutputMix class
 
 static const struct iid_vtable OutputMix_interfaces[INTERFACES_OutputMix] = {
-    {MPH_OBJECT, INTERFACE_IMPLICIT,
-        offsetof(COutputMix, mObject)},
+    {MPH_OBJECT, INTERFACE_IMPLICIT, offsetof(COutputMix, mObject)},
     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
         offsetof(COutputMix, mDynamicInterfaceManagement)},
-    {MPH_OUTPUTMIX, INTERFACE_IMPLICIT,
-        offsetof(COutputMix, mOutputMix)},
+    {MPH_OUTPUTMIX, INTERFACE_IMPLICIT, offsetof(COutputMix, mOutputMix)},
 #ifdef USE_OUTPUTMIXEXT
-    // FIXME should be internal implicit (available, but not advertised
+    // should be internal implicit (available, but not advertised
     // publicly or included in possible interface count)
-    {MPH_OUTPUTMIXEXT, INTERFACE_IMPLICIT,
-        offsetof(COutputMix, mOutputMixExt)},
+    {MPH_OUTPUTMIXEXT, INTERFACE_IMPLICIT, offsetof(COutputMix, mOutputMixExt)},
 #else
     {MPH_OUTPUTMIXEXT, INTERFACE_UNAVAILABLE, 0},
 #endif
-    {MPH_ENVIRONMENTALREVERB, INTERFACE_DYNAMIC_GAME,
-        offsetof(COutputMix, mEnvironmentalReverb)},
-    {MPH_EQUALIZER, INTERFACE_DYNAMIC_MUSIC_GAME,
-        offsetof(COutputMix, mEqualizer)},
-    {MPH_PRESETREVERB, INTERFACE_DYNAMIC_MUSIC,
-        offsetof(COutputMix, mPresetReverb)},
-    {MPH_VIRTUALIZER, INTERFACE_DYNAMIC_MUSIC_GAME,
-        offsetof(COutputMix, mVirtualizer)},
-    {MPH_VOLUME, INTERFACE_GAME_MUSIC,
-        offsetof(COutputMix, mVolume)},
-    {MPH_BASSBOOST, INTERFACE_OPTIONAL_DYNAMIC,
-        offsetof(COutputMix, mBassBoost)},
-    {MPH_VISUALIZATION, INTERFACE_OPTIONAL,
-        offsetof(COutputMix, mVisualization)}
+    {MPH_ENVIRONMENTALREVERB, INTERFACE_DYNAMIC_GAME, offsetof(COutputMix, mEnvironmentalReverb)},
+    {MPH_EQUALIZER, INTERFACE_DYNAMIC_MUSIC_GAME, offsetof(COutputMix, mEqualizer)},
+    {MPH_PRESETREVERB, INTERFACE_DYNAMIC_MUSIC, offsetof(COutputMix, mPresetReverb)},
+    {MPH_VIRTUALIZER, INTERFACE_DYNAMIC_MUSIC_GAME, offsetof(COutputMix, mVirtualizer)},
+    {MPH_VOLUME, INTERFACE_GAME_MUSIC, offsetof(COutputMix, mVolume)},
+    {MPH_BASSBOOST, INTERFACE_OPTIONAL_DYNAMIC, offsetof(COutputMix, mBassBoost)},
+    {MPH_VISUALIZATION, INTERFACE_OPTIONAL, offsetof(COutputMix, mVisualization)}
 };
 
 static const ClassTable COutputMix_class = {
@@ -395,12 +306,10 @@ static const ClassTable COutputMix_class = {
 // Vibra class
 
 static const struct iid_vtable VibraDevice_interfaces[INTERFACES_VibraDevice] = {
-    {MPH_OBJECT, INTERFACE_IMPLICIT,
-        offsetof(CVibraDevice, mObject)},
+    {MPH_OBJECT, INTERFACE_IMPLICIT, offsetof(CVibraDevice, mObject)},
     {MPH_DYNAMICINTERFACEMANAGEMENT, INTERFACE_IMPLICIT,
         offsetof(CVibraDevice, mDynamicInterfaceManagement)},
-    {MPH_VIBRA, INTERFACE_IMPLICIT,
-        offsetof(CVibraDevice, mVibra)}
+    {MPH_VIBRA, INTERFACE_IMPLICIT, offsetof(CVibraDevice, mVibra)}
 };
 
 static const ClassTable CVibraDevice_class = {
index ae630ef..ad7d11b 100644 (file)
@@ -109,7 +109,7 @@ const struct Vibra_id_descriptor Vibra_id_descriptors[] = {
     {0, NULL}
 };
 
-// FIXME should build this table from Caps table below
+// should build this table from Caps table below
 
 static const SLuint32 Codec_IDs[] = {
     SL_AUDIOCODEC_PCM,
index 8f4d44d..2ac8d52 100644 (file)
@@ -50,11 +50,13 @@ void object_unlock_exclusive_attributes(IObject *this, unsigned attributes)
             break;
         case SL_OBJECTID_OUTPUTMIX:
             // FIXME update gains on all players attached to this outputmix
-            fprintf(stderr, "[ FIXME: gain update on an SL_OBJECTID_OUTPUTMIX to be implemented ]\n");
+            fprintf(stderr,
+                "[ FIXME: gain update on an SL_OBJECTID_OUTPUTMIX to be implemented ]\n");
             break;
         case SL_OBJECTID_MIDIPLAYER:
-            // FIXME MIDI
-            fprintf(stderr, "[ FIXME: gain update on an SL_OBJECTID_MIDIPLAYER to be implemented ]\n");
+            // MIDI
+            fprintf(stderr,
+                "[ FIXME: gain update on an SL_OBJECTID_MIDIPLAYER to be implemented ]\n");
             break;
         default:
             break;
@@ -73,8 +75,9 @@ void object_unlock_exclusive_attributes(IObject *this, unsigned attributes)
 #endif
             break;
         case SL_OBJECTID_MIDIPLAYER:
-            // FIXME MIDI
-            fprintf(stderr, "[ FIXME: position update on an SL_OBJECTID_MIDIPLAYER to be implemented ]\n");
+            // MIDI
+            fprintf(stderr,
+                "[ FIXME: position update on an SL_OBJECTID_MIDIPLAYER to be implemented ]\n");
             break;
         default:
             break;
index 9682db4..f7c716e 100644 (file)
@@ -49,7 +49,6 @@ SLresult checkInterfaces(const ClassTable *class__, SLuint32 numInterfaces,
     const struct iid_vtable *interfaces = class__->mInterfaces;
     SLuint32 interfaceCount = class__->mInterfaceCount;
     SLuint32 i;
-    // FIXME This section could be pre-computed per class
     for (i = 0; i < interfaceCount; ++i) {
         switch (interfaces[i].mInterface) {
         case INTERFACE_IMPLICIT:
@@ -73,12 +72,6 @@ SLresult checkInterfaces(const ClassTable *class__, SLuint32 numInterfaces,
                     return SL_RESULT_FEATURE_UNSUPPORTED;
                 continue;
             }
-            // FIXME this seems a bit strong? what is correct logic?
-            // we are requesting a duplicate explicit interface,
-            // or we are requesting one which is already implicit ?
-            // if (exposedMask & (1 << index))
-            //    return SL_RESULT_PARAMETER_INVALID;
-            // can we request dynamic interfaces here?
             exposedMask |= (1 << index);
         }
     }
@@ -106,9 +99,9 @@ SLresult GetCodecCapabilities(SLuint32 codecId, SLuint32 *pIndex,
         if (cd->mCodecID == codecId) {
             if (0 == index) {
                 *pDescriptor = *cd->mDescriptor;
-#if 0   // FIXME Temporary workaround for Khronos bug 6331
+#if 0   // Temporary workaround for Khronos bug 6331
                 if (0 < pDescriptor->numSampleRatesSupported) {
-                    // FIXME The malloc is not in the 1.0.1 specification
+                    // The malloc is not in the 1.0.1 specification
                     SLmilliHertz *temp = (SLmilliHertz *) malloc(sizeof(SLmilliHertz) *
                         pDescriptor->numSampleRatesSupported);
                     assert(NULL != temp);
@@ -142,10 +135,9 @@ static SLresult checkDataLocator(void *pLocator, DataLocator *pDataLocator)
         break;
     case SL_DATALOCATOR_BUFFERQUEUE:
         pDataLocator->mBufferQueue = *(SLDataLocator_BufferQueue *)pLocator;
+        // number of buffers must be specified, there is no default value
         if (0 == pDataLocator->mBufferQueue.numBuffers)
             return SL_RESULT_PARAMETER_INVALID;
-            // pDataLocator->mBufferQueue.numBuffers = 2;
-        // FIXME check against a max
         break;
     case SL_DATALOCATOR_IODEVICE:
         {
@@ -374,7 +366,8 @@ SLresult checkSourceFormatVsInterfacesCompatibility(const DataLocatorFormat *pDa
         SLuint32 i;
         for (i = 0; i < numInterfaces; i++) {
             if (pInterfaceRequired[i] && (SL_IID_SEEK == pInterfaceIds[i])) {
-                fprintf(stderr, "Error: can't request SL_IID_SEEK with a buffer queue data source\n");
+                fprintf(stderr,
+                    "Error: can't request SL_IID_SEEK with a buffer queue data source\n");
                 return SL_RESULT_FEATURE_UNSUPPORTED;
             }
         }
@@ -739,8 +732,14 @@ SLresult SLAPIENTRY slQueryNumSupportedEngineInterfaces(SLuint32 *pNumSupportedI
     if (NULL == pNumSupportedInterfaces) {
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
-        const ClassTable *pCEngine_class = objectIDtoClass(SL_OBJECTID_ENGINE);
-        *pNumSupportedInterfaces = pCEngine_class->mInterfaceCount;
+        const ClassTable *class__ = objectIDtoClass(SL_OBJECTID_ENGINE);
+        assert(NULL != class__);
+        SLuint32 count = 0;
+        SLuint32 i;
+        for (i = 0; i < class__->mInterfaceCount; ++i)
+            if (class__->mInterfaces[i].mInterface != INTERFACE_UNAVAILABLE)
+                ++count;
+        *pNumSupportedInterfaces = count;
         result = SL_RESULT_SUCCESS;
     }
 
@@ -755,13 +754,20 @@ SLresult SLAPIENTRY slQuerySupportedEngineInterfaces(SLuint32 index, SLInterface
     if (NULL == pInterfaceId) {
         result = SL_RESULT_PARAMETER_INVALID;
     } else {
-        const ClassTable *pCEngine_class = objectIDtoClass(SL_OBJECTID_ENGINE);
-        if (pCEngine_class->mInterfaceCount <= index) {
-            *pInterfaceId = NULL;
-            result = SL_RESULT_PARAMETER_INVALID;
-        } else {
-            *pInterfaceId = &SL_IID_array[pCEngine_class->mInterfaces[index].mMPH];
-            result = SL_RESULT_SUCCESS;
+        *pInterfaceId = NULL;
+        const ClassTable *class__ = objectIDtoClass(SL_OBJECTID_ENGINE);
+        assert(NULL != class__);
+        result = SL_RESULT_PARAMETER_INVALID;   // will be reset later
+        SLuint32 i;
+        for (i = 0; i < class__->mInterfaceCount; ++i) {
+            if (INTERFACE_UNAVAILABLE == class__->mInterfaces[i].mInterface)
+                continue;
+            if (index == 0) {
+                *pInterfaceId = &SL_IID_array[class__->mInterfaces[i].mMPH];
+                result = SL_RESULT_SUCCESS;
+                break;
+            }
+            --index;
         }
     }
 
index ad6e2c4..1eded90 100644 (file)
@@ -27,6 +27,7 @@
 #include "MPH.h"
 #include "MPH_to.h"
 #include "devices.h"
+#include "OpenSLUT.h"
 #include "ThreadPool.h"
 
 typedef struct CAudioPlayer_struct CAudioPlayer;
@@ -43,6 +44,7 @@ typedef struct COutputMix_struct COutputMix;
 #endif // USE_SDL
 
 #ifdef ANDROID
+#include <utils/Log.h>
 #include "OpenSLES_Android.h"
 #include "media/AudioSystem.h"
 #include "media/AudioTrack.h"
@@ -83,6 +85,18 @@ typedef SLresult (*AsyncHook)(void *self, SLboolean async);
 #define INTERFACE_PHONE_GAME         INTERFACE_OPTIONAL
 #define INTERFACE_TBD                INTERFACE_IMPLICIT
 
+#ifdef USE_CONFORMANCE
+#define INTERFACE_IMPLICIT_CT        INTERFACE_IMPLICIT
+#define INTERFACE_EXPLICIT_CT        INTERFACE_EXPLICIT
+#define INTERFACE_EXPLICIT_GAME_CT   INTERFACE_EXPLICIT_GAME
+#define INTERFACE_OPTIONAL_CT        INTERFACE_OPTIONAL
+#else
+#define INTERFACE_IMPLICIT_CT        INTERFACE_UNAVAILABLE
+#define INTERFACE_EXPLICIT_CT        INTERFACE_UNAVAILABLE
+#define INTERFACE_EXPLICIT_GAME_CT   INTERFACE_UNAVAILABLE
+#define INTERFACE_OPTIONAL_CT        INTERFACE_UNAVAILABLE
+#endif
+
 // Describes how an interface is related to a given object
 
 #define INTERFACE_UNINITIALIZED 1  // not requested at object creation time
@@ -112,7 +126,6 @@ typedef struct {
     const struct iid_vtable *mInterfaces;
     SLuint32 mInterfaceCount;  // number of possible interfaces
     const signed char *mMPH_to_index;
-    // FIXME not yet used
     const char * const mName;
     size_t mSize;
     SLuint32 mObjectID;
@@ -211,11 +224,17 @@ typedef struct Object_interface {
     unsigned mGottenMask;           // interfaces which are exposed or added, and then gotten
     unsigned mLossOfControlMask;    // interfaces with loss of control enabled
     unsigned mAttributesMask;       // attributes which have changed since last sync
+#ifdef USE_CONFORMANCE
     SLint32 mPriority;
+#endif
     pthread_mutex_t mMutex;
     pthread_cond_t mCond;
     SLuint8 mState;                 // really SLuint32, but SLuint8 to save space
+#ifdef USE_CONFORMANCE
     SLuint8 mPreemptable;           // really SLboolean, but SLuint8 to save space
+#else
+    SLuint8 mPadding;
+#endif
     // for best alignment, do not add any fields here
 #define INTERFACES_Default 2
     SLuint8 mInterfaceStates[INTERFACES_Default];    // state of each of interface
@@ -401,7 +420,7 @@ typedef struct BufferQueue_interface {
 typedef struct {
     const struct SLDeviceVolumeItf_ *mItf;
     IObject *mThis;
-    SLint32 mVolume[MAX_DEVICE]; // FIXME Hard-coded for default in/out
+    SLint32 mVolume[MAX_DEVICE];
 } IDeviceVolume;
 
 typedef struct {
@@ -712,7 +731,7 @@ typedef struct /*Volume_interface*/ {
     // Values as specified by the application
     SLmillibel mLevel;
     SLpermille mStereoPosition;
-    SLuint8 /*SLboolean*/ mMute;    // FIXME move inside each object that supports the interface
+    SLuint8 /*SLboolean*/ mMute;
     SLuint8 /*SLboolean*/ mEnableStereoPosition;
 } IVolume;
 
@@ -867,6 +886,7 @@ typedef struct {
     I3DCommit m3DCommit;
     // optional interfaces
     IDeviceVolume mDeviceVolume;
+    // rest of fields are not related to the interfaces
     pthread_t mSyncThread;
 } CEngine;
 
@@ -1056,14 +1076,19 @@ extern const char * const interface_names[MPH_MAX];
 #define SL_DATALOCATOR_NULL 0    // application specified a NULL value for pLocator
 #define SL_DATAFORMAT_NULL 0     // application specified a NULL or undefined value for pFormat
 
-#ifdef NDEBUG
+// Trace debugging
+
+#ifndef USE_TRACE
+
 #define SL_ENTER_GLOBAL SLresult result;
 #define SL_LEAVE_GLOBAL return result;
 #define SL_ENTER_INTERFACE SLresult result;
 #define SL_LEAVE_INTERFACE return result;
 #define SL_ENTER_INTERFACE_VOID
 #define SL_LEAVE_INTERFACE_VOID return;
+
 #else
+
 extern void slEnterGlobal(const char *function);
 extern void slLeaveGlobal(const char *function, SLresult result);
 extern void slEnterInterface(const char *function);
@@ -1076,4 +1101,5 @@ extern void slLeaveInterfaceVoid(const char *function);
 #define SL_LEAVE_INTERFACE slLeaveInterface(__FUNCTION__, result); return result;
 #define SL_ENTER_INTERFACE_VOID slEnterInterfaceVoid(__FUNCTION__);
 #define SL_LEAVE_INTERFACE_VOID slLeaveInterfaceVoid(__FUNCTION__); return;
+
 #endif
similarity index 56%
rename from opensles/libopensles/debug.c
rename to opensles/libopensles/trace.c
index a257fb5..e890e4f 100644 (file)
  * limitations under the License.
  */
 
-/* debugging */
+/* trace debugging */
 
-#include "sles_allinclusive.h"
+#if 0 // ifdef ANDROID  // FIXME requires Stagefright LOG update
+//#define LOG_NDEBUG 0
+#define LOG_TAG "libOpenSLES"
+#else
+#define LOGV printf
+#define LOGE printf
+#endif
 
-#ifndef NDEBUG
+#include "sles_allinclusive.h"
 
-#define SL_RESULT_MAX (SL_RESULT_CONTROL_LOST + 1)
-static const char * const result_strings[SL_RESULT_MAX] = {
-    "SUCCESS",
-    "PRECONDITIONS_VIOLATED",
-    "PARAMETER_INVALID",
-    "MEMORY_FAILURE",
-    "RESOURCE_ERROR",
-    "RESOURCE_LOST",
-    "IO_ERROR",
-    "BUFFER_INSUFFICIENT",
-    "CONTENT_CORRUPTED",
-    "CONTENT_UNSUPPORTED",
-    "CONTENT_NOT_FOUND",
-    "PERMISSION_DENIED",
-    "FEATURE_UNSUPPORTED",
-    "INTERNAL_ERROR",
-    "UNKNOWN_ERROR",
-    "OPERATION_ABORTED",
-    "CONTROL_LOST"
-};
+#ifdef USE_TRACE
 
 void slEnterGlobal(const char *function)
 {
-    printf("Entering %s\n", function);
+    LOGV("Entering %s\n", function);
 }
 
 void slLeaveGlobal(const char *function, SLresult result)
 {
     if (SL_RESULT_SUCCESS != result) {
-        if (SL_RESULT_MAX > result)
-            printf("Leaving %s (%s)\n", function, result_strings[result]);
+        if (SLUT_RESULT_MAX > result)
+            LOGV("Leaving %s (%s)\n", function, slutResultStrings[result]);
         else
-            printf("Leaving %s (0x%X)\n", function, (unsigned) result);
+            LOGV("Leaving %s (0x%X)\n", function, (unsigned) result);
     }
 }
 
@@ -63,12 +50,12 @@ void slEnterInterface(const char *function)
     const char *underscore = function;
     while (*underscore != '\0') {
         if (*underscore == '_') {
-            printf("Entering %.*s::%s\n", underscore - function, function, &underscore[1]);
+            LOGV("Entering %.*s::%s\n", underscore - function, function, &underscore[1]);
             return;
         }
         ++underscore;
     }
-    printf("Entering %s\n", function);
+    LOGV("Entering %s\n", function);
 }
 
 void slLeaveInterface(const char *function, SLresult result)
@@ -79,20 +66,20 @@ void slLeaveInterface(const char *function, SLresult result)
         const char *underscore = function;
         while (*underscore != '\0') {
             if (*underscore == '_') {
-                if (SL_RESULT_MAX > result)
-                    printf("Leaving %.*s::%s (%s)\n", underscore - function, function,
-                        &underscore[1], result_strings[result]);
+                if (SLUT_RESULT_MAX > result)
+                    LOGE("Leaving %.*s::%s (%s)\n", underscore - function, function,
+                        &underscore[1], slutResultStrings[result]);
                 else
-                    printf("Leaving %.*s::%s (0x%X)\n", underscore - function, function,
+                    LOGE("Leaving %.*s::%s (0x%X)\n", underscore - function, function,
                         &underscore[1], (unsigned) result);
                 return;
             }
             ++underscore;
         }
-        if (SL_RESULT_MAX > result)
-            printf("Leaving %s (%s)\n", function, result_strings[result]);
+        if (SLUT_RESULT_MAX > result)
+            LOGE("Leaving %s (%s)\n", function, slutResultStrings[result]);
         else
-            printf("Leaving %s (0x%X)\n", function, (unsigned) result);
+            LOGE("Leaving %s (0x%X)\n", function, (unsigned) result);
     }
 }
 
@@ -106,4 +93,4 @@ void slLeaveInterfaceVoid(const char *function)
     slLeaveInterface(function, SL_RESULT_SUCCESS);
 }
 
-#endif // !defined(NDEBUG)
+#endif // defined(USE_TRACE)