1 /* 2 * Copyright (C) 2022 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_AUDIOMIXERATTRIBUTES_H 18 #define ANDROID_MEDIA_AUDIOMIXERATTRIBUTES_H 19 20 #include <system/audio.h> 21 22 // Keep sync with AudioMixerAttributes.java 23 #define MIXER_BEHAVIOR_DEFAULT 0 24 #define MIXER_BEHAVIOR_BIT_PERFECT 1 25 // Invalid value is not added in JAVA API, but keep sync with native value 26 #define MIXER_BEHAVIOR_INVALID -1 27 audioMixerBehaviorToNative(int mixerBehavior)28static inline audio_mixer_behavior_t audioMixerBehaviorToNative(int mixerBehavior) { 29 switch (mixerBehavior) { 30 case MIXER_BEHAVIOR_DEFAULT: 31 return AUDIO_MIXER_BEHAVIOR_DEFAULT; 32 case MIXER_BEHAVIOR_BIT_PERFECT: 33 return AUDIO_MIXER_BEHAVIOR_BIT_PERFECT; 34 default: 35 return AUDIO_MIXER_BEHAVIOR_INVALID; 36 } 37 } 38 audioMixerBehaviorFromNative(audio_mixer_behavior_t mixerBehavior)39static inline jint audioMixerBehaviorFromNative(audio_mixer_behavior_t mixerBehavior) { 40 switch (mixerBehavior) { 41 case AUDIO_MIXER_BEHAVIOR_DEFAULT: 42 return MIXER_BEHAVIOR_DEFAULT; 43 case AUDIO_MIXER_BEHAVIOR_BIT_PERFECT: 44 return MIXER_BEHAVIOR_BIT_PERFECT; 45 case AUDIO_MIXER_BEHAVIOR_INVALID: 46 default: 47 return MIXER_BEHAVIOR_INVALID; 48 } 49 } 50 51 #endif 52