*pDevice = NULL;
unsigned exposedMask;
const ClassTable *pCLEDDevice_class = objectIDtoClass(SL_OBJECTID_LEDDEVICE);
- result = checkInterfaces(pCLEDDevice_class, numInterfaces, pInterfaceIds,
- pInterfaceRequired, &exposedMask);
+ if (NULL == pCLEDDevice_class) {
+ result = SL_RESULT_FEATURE_UNSUPPORTED;
+ } else {
+ result = checkInterfaces(pCLEDDevice_class, numInterfaces, pInterfaceIds,
+ pInterfaceRequired, &exposedMask);
+ }
if (SL_RESULT_SUCCESS == result) {
CLEDDevice *this = (CLEDDevice *) construct(pCLEDDevice_class, exposedMask, self);
if (NULL == this) {
*pDevice = NULL;
unsigned exposedMask;
const ClassTable *pCVibraDevice_class = objectIDtoClass(SL_OBJECTID_VIBRADEVICE);
- result = checkInterfaces(pCVibraDevice_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask);
+ if (NULL == pCVibraDevice_class) {
+ result = SL_RESULT_FEATURE_UNSUPPORTED;
+ } else {
+ result = checkInterfaces(pCVibraDevice_class, numInterfaces,
+ pInterfaceIds, pInterfaceRequired, &exposedMask);
+ }
if (SL_RESULT_SUCCESS == result) {
CVibraDevice *this = (CVibraDevice *) construct(pCVibraDevice_class, exposedMask, self);
if (NULL == this) {
*pPlayer = NULL;
unsigned exposedMask;
const ClassTable *pCAudioPlayer_class = objectIDtoClass(SL_OBJECTID_AUDIOPLAYER);
+ assert(NULL != pCAudioPlayer_class);
result = checkInterfaces(pCAudioPlayer_class, numInterfaces,
pInterfaceIds, pInterfaceRequired, &exposedMask);
if (SL_RESULT_SUCCESS == result) {
*pRecorder = NULL;
unsigned exposedMask;
const ClassTable *pCAudioRecorder_class = objectIDtoClass(SL_OBJECTID_AUDIORECORDER);
- result = checkInterfaces(pCAudioRecorder_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask);
+ if (NULL == pCAudioRecorder_class) {
+ result = SL_RESULT_FEATURE_UNSUPPORTED;
+ } else {
+ result = checkInterfaces(pCAudioRecorder_class, numInterfaces,
+ pInterfaceIds, pInterfaceRequired, &exposedMask);
+ }
if (SL_RESULT_SUCCESS == result) {
*pPlayer = NULL;
unsigned exposedMask;
const ClassTable *pCMidiPlayer_class = objectIDtoClass(SL_OBJECTID_MIDIPLAYER);
- result = checkInterfaces(pCMidiPlayer_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask);
+ if (NULL == pCMidiPlayer_class) {
+ result = SL_RESULT_FEATURE_UNSUPPORTED;
+ } else {
+ result = checkInterfaces(pCMidiPlayer_class, numInterfaces,
+ pInterfaceIds, pInterfaceRequired, &exposedMask);
+ }
if (SL_RESULT_SUCCESS == result) {
CMidiPlayer *this = (CMidiPlayer *) construct(pCMidiPlayer_class, exposedMask, self);
if (NULL == this) {
*pListener = NULL;
unsigned exposedMask;
const ClassTable *pCListener_class = objectIDtoClass(SL_OBJECTID_LISTENER);
- result = checkInterfaces(pCListener_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask);
+ if (NULL == pCListener_class) {
+ result = SL_RESULT_FEATURE_UNSUPPORTED;
+ } else {
+ result = checkInterfaces(pCListener_class, numInterfaces,
+ pInterfaceIds, pInterfaceRequired, &exposedMask);
+ }
if (SL_RESULT_SUCCESS == result) {
CListener *this = (CListener *) construct(pCListener_class, exposedMask, self);
if (NULL == this) {
*pGroup = NULL;
unsigned exposedMask;
const ClassTable *pC3DGroup_class = objectIDtoClass(SL_OBJECTID_3DGROUP);
- result = checkInterfaces(pC3DGroup_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask);
+ if (NULL == pC3DGroup_class) {
+ result = SL_RESULT_FEATURE_UNSUPPORTED;
+ } else {
+ result = checkInterfaces(pC3DGroup_class, numInterfaces,
+ pInterfaceIds, pInterfaceRequired, &exposedMask);
+ }
if (SL_RESULT_SUCCESS == result) {
C3DGroup *this = (C3DGroup *) construct(pC3DGroup_class, exposedMask, self);
if (NULL == this) {
*pMix = NULL;
unsigned exposedMask;
const ClassTable *pCOutputMix_class = objectIDtoClass(SL_OBJECTID_OUTPUTMIX);
+ assert(NULL != pCOutputMix_class);
result = checkInterfaces(pCOutputMix_class, numInterfaces,
pInterfaceIds, pInterfaceRequired, &exposedMask);
if (SL_RESULT_SUCCESS == result) {
unsigned exposedMask;
const ClassTable *pCMetadataExtractor_class =
objectIDtoClass(SL_OBJECTID_METADATAEXTRACTOR);
- result = checkInterfaces(pCMetadataExtractor_class, numInterfaces,
- pInterfaceIds, pInterfaceRequired, &exposedMask);
+ if (NULL == pCMetadataExtractor_class) {
+ result = SL_RESULT_FEATURE_UNSUPPORTED;
+ } else {
+ result = checkInterfaces(pCMetadataExtractor_class, numInterfaces,
+ pInterfaceIds, pInterfaceRequired, &exposedMask);
+ }
if (SL_RESULT_SUCCESS == result) {
CMetadataExtractor *this = (CMetadataExtractor *)
construct(pCMetadataExtractor_class, exposedMask, self);
{
SL_ENTER_INTERFACE
-#if USE_PROFILES & USE_PROFILES_BASE
if (NULL == pNumSupportedInterfaces) {
result = SL_RESULT_PARAMETER_INVALID;
} else {
result = SL_RESULT_SUCCESS;
}
}
-#else
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-#endif
SL_LEAVE_INTERFACE;
}
{
SL_ENTER_INTERFACE
-#if USE_PROFILES & USE_PROFILES_BASE
if (NULL == pInterfaceId) {
result = SL_RESULT_PARAMETER_INVALID;
} else {
}
}
}
-#else
- result = SL_RESULT_FEATURE_UNSUPPORTED;
-#endif
SL_LEAVE_INTERFACE
};
// IObject is the first interface in a class, so the index for MPH_OBJECT must be zero.
// Don't cross streams, otherwise bad things happen.
+
+#if USE_PROFILES & USE_PROFILE_GAME
const signed char MPH_to_3DGroup[MPH_MAX] = {
#ifdef USE_DESIGNATED_INITIALIZERS
[0 ... MPH_MAX-1] = -1,
END
#endif
};
+#endif
const signed char MPH_to_AudioPlayer[MPH_MAX] = {
#ifdef USE_DESIGNATED_INITIALIZERS
#endif
};
+#if (USE_PROFILES & USE_PROFILES_OPTIONAL) || defined(ANDROID)
const signed char MPH_to_AudioRecorder[MPH_MAX] = {
#ifdef USE_DESIGNATED_INITIALIZERS
[0 ... MPH_MAX-1] = -1,
END
#endif
};
+#endif
const signed char MPH_to_Engine[MPH_MAX] = {
#ifdef USE_DESIGNATED_INITIALIZERS
#endif
};
+#if USE_PROFILES & USE_PROFILES_OPTIONAL
const signed char MPH_to_LEDDevice[MPH_MAX] = {
#ifdef USE_DESIGNATED_INITIALIZERS
[0 ... MPH_MAX-1] = -1,
END
#endif
};
+#endif
+#if USE_PROFILES & USE_PROFILE_GAME
const signed char MPH_to_Listener[MPH_MAX] = {
#ifdef USE_DESIGNATED_INITIALIZERS
[0 ... MPH_MAX-1] = -1,
END
#endif
};
+#endif
+#if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_MUSIC)
const signed char MPH_to_MetadataExtractor[MPH_MAX] = {
#ifdef USE_DESIGNATED_INITIALIZERS
[0 ... MPH_MAX-1] = -1,
END
#endif
};
+#endif
+#if USE_PROFILES & USE_PROFILE_GAME
const signed char MPH_to_MidiPlayer[MPH_MAX] = {
#ifdef USE_DESIGNATED_INITIALIZERS
[0 ... MPH_MAX-1] = -1,
END
#endif
};
+#endif
const signed char MPH_to_OutputMix[MPH_MAX] = {
#ifdef USE_DESIGNATED_INITIALIZERS
#endif
};
+#if USE_PROFILES & USE_PROFILE_OPTIONAL
const signed char MPH_to_Vibra[MPH_MAX] = {
#ifdef USE_DESIGNATED_INITIALIZERS
[0 ... MPH_MAX-1] = -1,
END
#endif
};
+#endif
// note that SLresult is unsigned
return result < SLESUT_RESULT_MAX ? slesutResultStrings[result] : "UNKNOWN";
}
+
+
+/** \brief Convert an object ID to a string or NULL. */
+
+const char *slesutObjectIDToString(SLuint32 objectID)
+{
+ static const char * const objectIDstrings[10] = {
+ "SL_OBJECTID_ENGINE",
+ "SL_OBJECTID_LEDDEVICE",
+ "SL_OBJECTID_VIBRADEVICE",
+ "SL_OBJECTID_AUDIOPLAYER",
+ "SL_OBJECTID_AUDIORECORDER",
+ "SL_OBJECTID_MIDIPLAYER",
+ "SL_OBJECTID_LISTENER",
+ "SL_OBJECTID_3DGROUP",
+ "SL_OBJECTID_OUTPUTMIX",
+ "SL_OBJECTID_METADATAEXTRACTOR"
+ };
+ return (0x1001 <= objectID) && (objectID <= 0x100A) ? objectIDstrings[objectID - 0x1001] : NULL;
+}
extern const char * const slesutResultStrings[SLESUT_RESULT_MAX];
extern void slesutPrintIID(SLInterfaceID iid);
extern const char *slesutResultToString(SLresult result);
+extern const char *slesutObjectIDToString(SLuint32 objectID);
#ifdef __cplusplus
}
#include "sles_allinclusive.h"
+
+#if USE_PROFILES & USE_PROFILES_GAME
+
// 3DGroup class
static const struct iid_vtable _3DGroup_interfaces[INTERFACES_3DGroup] = {
C3DGroup_PreDestroy
};
+#endif
+
+
// AudioPlayer class
static const struct iid_vtable AudioPlayer_interfaces[INTERFACES_AudioPlayer] = {
CAudioPlayer_PreDestroy
};
+
+#if (USE_PROFILES & USE_PROFILES_OPTIONAL) || defined(ANDROID)
+
// AudioRecorder class
static const struct iid_vtable AudioRecorder_interfaces[INTERFACES_AudioRecorder] = {
CAudioRecorder_PreDestroy
};
+#endif
+
+
// Engine class
static const struct iid_vtable Engine_interfaces[INTERFACES_Engine] = {
CEngine_PreDestroy
};
+
+#if USE_PROFILES & USE_PROFILES_OPTIONAL
+
// LEDDevice class
static const struct iid_vtable LEDDevice_interfaces[INTERFACES_LEDDevice] = {
NULL
};
+#endif
+
+
+#if USE_PROFILES & USE_PROFILES_GAME
+
// Listener class
static const struct iid_vtable Listener_interfaces[INTERFACES_Listener] = {
NULL
};
+#endif
+
+
+#if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_MUSIC)
+
// MetadataExtractor class
static const struct iid_vtable MetadataExtractor_interfaces[INTERFACES_MetadataExtractor] = {
NULL
};
+#endif
+
+
+#if USE_PROFILES & USE_PROFILES_GAME
+
// MidiPlayer class
static const struct iid_vtable MidiPlayer_interfaces[INTERFACES_MidiPlayer] = {
NULL
};
+#endif
+
+
// OutputMix class
static const struct iid_vtable OutputMix_interfaces[INTERFACES_OutputMix] = {
COutputMix_PreDestroy
};
+
+#if USE_PROFILES & USE_PROFILES_OPTIONAL
+
// Vibra class
static const struct iid_vtable VibraDevice_interfaces[INTERFACES_VibraDevice] = {
NULL
};
-/* Map SL_OBJECTID to class */
+#endif
+
static const ClassTable * const classes[] = {
// Do not change order of these entries; they are in numerical order
&CEngine_class,
+#if USE_PROFILES & USE_PROFILES_OPTIONAL
&CLEDDevice_class,
&CVibraDevice_class,
+#else
+ NULL,
+ NULL,
+#endif
&CAudioPlayer_class,
+#if (USE_PROFILES & USE_PROFILES_OPTIONAL) || defined(ANDROID)
&CAudioRecorder_class,
+#else
+ NULL,
+#endif
+#if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_PHONE)
&CMidiPlayer_class,
+#else
+ NULL,
+#endif
+#if USE_PROFILES & USE_PROFILES_GAME
&CListener_class,
&C3DGroup_class,
+#else
+ NULL,
+ NULL,
+#endif
&COutputMix_class,
+#if USE_PROFILES & (USE_PROFILES_GAME | USE_PROFILES_MUSIC)
&CMetadataExtractor_class
+#else
+ NULL
+#endif
};
+
+/* \brief Map SL_OBJECTID to class or NULL if object ID not supported */
+
const ClassTable *objectIDtoClass(SLuint32 objectID)
{
+ // object ID is the engine and always present
+ assert(NULL != classes[0]);
SLuint32 objectID0 = classes[0]->mObjectID;
- if (objectID0 <= objectID &&
- classes[sizeof(classes)/sizeof(classes[0])-1]->mObjectID >= objectID)
+ if ((objectID0 <= objectID) && ((objectID0 + sizeof(classes)/sizeof(classes[0])) > objectID)) {
return classes[objectID - objectID0];
+ }
return NULL;
}
unsigned exposedMask;
const ClassTable *pCEngine_class = objectIDtoClass(SL_OBJECTID_ENGINE);
+ assert(NULL != pCEngine_class);
result = checkInterfaces(pCEngine_class, numInterfaces,
pInterfaceIds, pInterfaceRequired, &exposedMask);
if (SL_RESULT_SUCCESS != result) {
libutils \
libOpenSLES
+LOCAL_STATIC_LIBRARIES := \
+ libOpenSLESUT
+
ifeq ($(TARGET_OS),linux)
LOCAL_CFLAGS += -DXP_UNIX
endif
LOCAL_MODULE:= slesTest_engine
include $(BUILD_EXECUTABLE)
+
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_C_INCLUDES:= \
+ system/media/opensles/include
+
+LOCAL_SRC_FILES:= \
+ object.c
+
+LOCAL_SHARED_LIBRARIES := \
+ libutils \
+ libOpenSLES
+
+LOCAL_STATIC_LIBRARIES := \
+ libOpenSLESUT
+
+ifeq ($(TARGET_OS),linux)
+ LOCAL_CFLAGS += -DXP_UNIX
+endif
+
+LOCAL_MODULE:= slesTest_object
+
+include $(BUILD_EXECUTABLE)
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "SLES/OpenSLES.h"
+#include "SLES/OpenSLESUT.h"
+
+int main(int arg, char **argv)
+{
+ SLresult result;
+
+ printf("Create engine\n");
+ SLObjectItf engineObject;
+ // create engine
+ result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
+ assert(SL_RESULT_SUCCESS == result);
+ result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
+ assert(SL_RESULT_SUCCESS == result);
+ SLEngineItf engineEngine;
+ result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
+ assert(SL_RESULT_SUCCESS == result);
+ // loop through both valid and invalid object IDs
+ SLuint32 objectID;
+ for (objectID = 0x1000; objectID <= 0x100B; ++objectID) {
+ printf("object ID %lx", objectID);
+ const char *string = slesutObjectIDToString(objectID);
+ if (NULL != string)
+ printf(" (%s)", string);
+ printf(":\n");
+ SLuint32 numSupportedInterfaces = 12345;
+ result = (*engineEngine)->QueryNumSupportedInterfaces(engineEngine, objectID,
+ &numSupportedInterfaces);
+ if (SL_RESULT_FEATURE_UNSUPPORTED == result) {
+ printf(" unsupported\n");
+ continue;
+ }
+ assert(SL_RESULT_SUCCESS == result);
+ printf("numSupportedInterfaces %lu\n", numSupportedInterfaces);
+ SLuint32 i;
+ for (i = 0; i < numSupportedInterfaces + 1; ++i) {
+ SLInterfaceID interfaceID;
+ result = (*engineEngine)->QuerySupportedInterfaces(engineEngine, objectID, i,
+ &interfaceID);
+ if (i < numSupportedInterfaces) {
+ assert(SL_RESULT_SUCCESS == result);
+ printf(" interface %lu ", i);
+ slesutPrintIID(interfaceID);
+ } else {
+ assert(SL_RESULT_PARAMETER_INVALID == result);
+ }
+ }
+ }
+ return EXIT_SUCCESS;
+}