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 }; 36 37 static inline jint nativeToJavaStatus(status_t status) { 38 switch (status) { 39 case NO_ERROR: 40 return AUDIO_JAVA_SUCCESS; 41 case BAD_VALUE: 42 return AUDIO_JAVA_BAD_VALUE; 43 case INVALID_OPERATION: 44 return AUDIO_JAVA_INVALID_OPERATION; 45 case PERMISSION_DENIED: 46 return AUDIO_JAVA_PERMISSION_DENIED; 47 case NO_INIT: 48 return AUDIO_JAVA_NO_INIT; 49 case DEAD_OBJECT: 50 return AUDIO_JAVA_DEAD_OBJECT; 51 default: 52 return AUDIO_JAVA_ERROR; 53 } 54 } 55 }; // namespace android 56 #endif // ANDROID_MEDIA_AUDIOERRORS_H 57