1 /* 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 22 namespace 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. 27 enum { 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, 35 AUDIO_JAVA_WOULD_BLOCK = -7, 36 }; 37 nativeToJavaStatus(status_t status)38 static constexpr 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; 50 case WOULD_BLOCK: 51 return AUDIO_JAVA_WOULD_BLOCK; 52 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 60