blob: c17a020f74fcfdbbc3a24e9e386257322b07a517 [file] [log] [blame]
Eric Laurentbc11a692014-05-16 12:19:25 -07001/*
2 * Copyright (C) 2014 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#ifndef ANDROID_MEDIA_AUDIOERRORS_H
18#define ANDROID_MEDIA_AUDIOERRORS_H
19
20#include <utils/Errors.h>
21
22namespace android {
23// status codes used by JAVA APIs. Translation from native error codes is done by
24// nativeToJavaStatus()
25// must be kept in sync with values in
26// frameworks/base/media/java/android/media/AudioSystem.java.
27enum {
28 AUDIO_JAVA_SUCCESS = 0,
29 AUDIO_JAVA_ERROR = -1,
30 AUDIO_JAVA_BAD_VALUE = -2,
31 AUDIO_JAVA_INVALID_OPERATION = -3,
32 AUDIO_JAVA_PERMISSION_DENIED = -4,
33 AUDIO_JAVA_NO_INIT = -5,
34 AUDIO_JAVA_DEAD_OBJECT = -6,
Eric Laurent4e1ccd32015-07-02 12:09:44 -070035 AUDIO_JAVA_WOULD_BLOCK = -7,
Eric Laurentbc11a692014-05-16 12:19:25 -070036};
37
38static inline jint nativeToJavaStatus(status_t status) {
39 switch (status) {
40 case NO_ERROR:
41 return AUDIO_JAVA_SUCCESS;
42 case BAD_VALUE:
43 return AUDIO_JAVA_BAD_VALUE;
44 case INVALID_OPERATION:
45 return AUDIO_JAVA_INVALID_OPERATION;
46 case PERMISSION_DENIED:
47 return AUDIO_JAVA_PERMISSION_DENIED;
48 case NO_INIT:
49 return AUDIO_JAVA_NO_INIT;
Eric Laurent4e1ccd32015-07-02 12:09:44 -070050 case WOULD_BLOCK:
51 return AUDIO_JAVA_WOULD_BLOCK;
Eric Laurentbc11a692014-05-16 12:19:25 -070052 case DEAD_OBJECT:
53 return AUDIO_JAVA_DEAD_OBJECT;
54 default:
55 return AUDIO_JAVA_ERROR;
56 }
57}
58}; // namespace android
59#endif // ANDROID_MEDIA_AUDIOERRORS_H