slesutResult.c revision 262059f71a68edc5e510427c63f5f1623d3672a8
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <stdlib.h>
18#include "SLES/OpenSLES.h"
19#include "OpenSLESUT.h"
20
21
22/** \brief Maximum result return code */
23
24#define SLESUT_RESULT_MAX (SL_RESULT_CONTROL_LOST + 1)
25
26/** \brief Array of strings correponding to each result code */
27
28static const char * const slesutResultStrings[SLESUT_RESULT_MAX] = {
29    "SL_RESULT_SUCCESS",
30    "SL_RESULT_PRECONDITIONS_VIOLATED",
31    "SL_RESULT_PARAMETER_INVALID",
32    "SL_RESULT_MEMORY_FAILURE",
33    "SL_RESULT_RESOURCE_ERROR",
34    "SL_RESULT_RESOURCE_LOST",
35    "SL_RESULT_IO_ERROR",
36    "SL_RESULT_BUFFER_INSUFFICIENT",
37    "SL_RESULT_CONTENT_CORRUPTED",
38    "SL_RESULT_CONTENT_UNSUPPORTED",
39    "SL_RESULT_CONTENT_NOT_FOUND",
40    "SL_RESULT_PERMISSION_DENIED",
41    "SL_RESULT_FEATURE_UNSUPPORTED",
42    "SL_RESULT_INTERNAL_ERROR",
43    "SL_RESULT_UNKNOWN_ERROR",
44    "SL_RESULT_OPERATION_ABORTED",
45    "SL_RESULT_CONTROL_LOST"
46};
47
48
49/** \brief Convert a result code to a string or NULL. */
50
51const char *slesutResultToString(SLresult result)
52{
53    // note that SLresult is unsigned
54    return result < SLESUT_RESULT_MAX ? slesutResultStrings[result] : NULL;
55}
56