1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef AUDIO_ADAPTER_INFO_COMMON_H 17 #define AUDIO_ADAPTER_INFO_COMMON_H 18 19 #include <dlfcn.h> 20 #include <errno.h> 21 #include <fcntl.h> 22 #include <stdio.h> 23 #include <stdlib.h> 24 #include <string.h> 25 #include <sys/stat.h> 26 #include <sys/types.h> 27 #include <time.h> 28 29 #include "audio_internal.h" 30 #include "audio_types.h" 31 #include "securec.h" 32 33 #define AUDIO_PRIMARY_ID_MIN 0 34 #define AUDIO_PRIMARY_ID_MAX 10 35 36 #define AUDIO_PRIMARY_EXT_ID_MIN 11 37 #define AUDIO_PRIMARY_EXT_ID_MAX 20 38 39 #define AUDIO_HDMI_ID_MIN 11 40 #define AUDIO_HDMI_ID_MAX 20 41 42 #define AUDIO_USB_ID_MIN 21 43 #define AUDIO_USB_ID_MAX 30 44 45 #define AUDIO_A2DP_ID_MIN 31 46 #define AUDIO_A2DP_ID_MAX 40 47 48 enum AudioAdapterType { 49 AUDIO_ADAPTER_PRIMARY = 0, /* internal sound card */ 50 AUDIO_ADAPTER_PRIMARY_EXT, /* extern sound card */ 51 AUDIO_ADAPTER_HDMI, /* hdmi sound card */ 52 AUDIO_ADAPTER_USB, /* usb sound card */ 53 AUDIO_ADAPTER_A2DP, /* blue tooth sound card */ 54 AUDIO_ADAPTER_MAX, /* Invalid value. */ 55 }; 56 57 enum AudioAdapterType MatchAdapterType(const char *adapterName, uint32_t portId); 58 int32_t AudioAdapterCheckPortId(const char *adapterName, uint32_t portId); 59 60 struct AudioAdapterDescriptor *AudioAdapterGetConfigDescs(void); 61 int32_t AudioAdapterGetAdapterNum(void); 62 int32_t AudioAdapterExist(const char *adapterName); 63 int32_t InitPortForCapabilitySub(struct AudioPort portIndex, struct AudioPortCapability *capabilityIndex); 64 int32_t KeyValueListToMap(const char *keyValueList, struct ParamValMap mParamValMap[], int32_t *count); 65 int32_t AddElementToList(char *keyValueList, int32_t listLenth, const char *key, void *value); 66 int32_t GetErrorReason(int reason, char* reasonDesc); 67 int32_t GetCurrentTime(char *currentTime); 68 int32_t CheckAttrRoute(int32_t param); 69 int32_t CheckAttrChannel(uint32_t param); 70 int32_t TransferRoute(const char *value, int32_t *route); 71 int32_t TransferFormat(const char *value, int32_t *format); 72 int32_t TransferChannels(const char *value, uint32_t *channels); 73 int32_t TransferFrames(const char *value, uint64_t *frames); 74 int32_t TransferSampleRate(const char *value, uint32_t *sampleRate); 75 int32_t FormatToBits(enum AudioFormat format, uint32_t *formatBits); 76 int32_t BitsToFormat(enum AudioFormat *format, int32_t formatBits); 77 int32_t SetExtParam(const char *key, const char *value, struct ExtraParams *mExtraParams); 78 int32_t AudioSetExtraParams(const char *keyValueList, int32_t *count, 79 struct ExtraParams *mExtraParams, int32_t *sumOk); 80 bool ReleaseAudioManagerObjectComm(const struct AudioManager *object); 81 void AudioAdapterReleaseDescs(const struct AudioAdapterDescriptor *descs, int32_t adapterNum); 82 #endif 83