1 /* 2 * Copyright (C) 2023 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 #define LOG_TAG "AidlConversionCore" 18 //#define LOG_NDEBUG 0 19 #include <utils/Log.h> 20 21 #include <media/AidlConversionCore.h> 22 #include <media/AidlConversionCppNdk.h> 23 24 namespace aidl { 25 namespace android { 26 27 using MicrophoneDirection = hardware::audio::core::IStreamIn::MicrophoneDirection; 28 using ::android::BAD_VALUE; 29 using ::android::OK; 30 using ::android::status_t; 31 using ::android::base::unexpected; 32 33 ConversionResult<audio_microphone_direction_t> aidl2legacy_MicrophoneDirection_audio_microphone_direction_t(MicrophoneDirection aidl)34aidl2legacy_MicrophoneDirection_audio_microphone_direction_t(MicrophoneDirection aidl) { 35 switch (aidl) { 36 case MicrophoneDirection::UNSPECIFIED: 37 return MIC_DIRECTION_UNSPECIFIED; 38 case MicrophoneDirection::FRONT: 39 return MIC_DIRECTION_FRONT; 40 case MicrophoneDirection::BACK: 41 return MIC_DIRECTION_BACK; 42 case MicrophoneDirection::EXTERNAL: 43 return MIC_DIRECTION_EXTERNAL; 44 } 45 return unexpected(BAD_VALUE); 46 } 47 48 ConversionResult<MicrophoneDirection> legacy2aidl_audio_microphone_direction_t_MicrophoneDirection(audio_microphone_direction_t legacy)49legacy2aidl_audio_microphone_direction_t_MicrophoneDirection(audio_microphone_direction_t legacy) { 50 switch (legacy) { 51 case MIC_DIRECTION_UNSPECIFIED: 52 return MicrophoneDirection::UNSPECIFIED; 53 case MIC_DIRECTION_FRONT: 54 return MicrophoneDirection::FRONT; 55 case MIC_DIRECTION_BACK: 56 return MicrophoneDirection::BACK; 57 case MIC_DIRECTION_EXTERNAL: 58 return MicrophoneDirection::EXTERNAL; 59 } 60 return unexpected(BAD_VALUE); 61 } 62 63 } // namespace android 64 } // aidl 65