summaryrefslogtreecommitdiffstats
path: root/opensles/tests/sandbox/object.c
blob: 2285ed76002a7fcfe74f40c1ec3767e3f85eb9ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * 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;
}