1 /* 2 * Copyright (c) 2022 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 FRAMEWORK_COMMON_H 17 #define FRAMEWORK_COMMON_H 18 19 #include <stdio.h> 20 #include <stdlib.h> 21 22 #ifdef IDL_SAMPLE 23 #include "v1_0/audio_types.h" 24 #else 25 #include "audio_types.h" 26 #endif 27 28 #define AUDIO_FUNC_LOGE(fmt, arg...) do { \ 29 printf("%s: [%s]: [%d]:[ERROR]:" fmt"\n", __FILE__, __func__, __LINE__, ##arg); \ 30 } while (0) 31 32 struct AudioHeadInfo { 33 uint32_t riffId; 34 uint32_t riffSize; 35 uint32_t waveType; 36 uint32_t audioFileFmtId; 37 uint32_t audioFileFmtSize; 38 uint16_t audioFileFormat; 39 uint16_t audioChannelNum; 40 uint32_t audioSampleRate; 41 uint32_t audioByteRate; 42 uint16_t audioBlockAlign; 43 uint16_t audioBitsPerSample; 44 uint32_t dataId; 45 uint32_t dataSize; 46 }; 47 48 enum AudioPcmBit { 49 PCM_8_BIT = 8, /* 8-bit PCM */ 50 PCM_16_BIT = 16, /* 16-bit PCM */ 51 PCM_24_BIT = 24, /* 24-bit PCM */ 52 PCM_32_BIT = 32, /* 32-bit PCM */ 53 }; 54 55 enum LoadingMode { 56 DIRECT = 1, 57 SERVICE = 2, 58 }; 59 60 void SystemInputFail(void); 61 uint32_t StringToInt(const char *flag); 62 int32_t CheckPcmFormat(int32_t val, uint32_t *audioPcmFormat); 63 uint32_t PcmFormatToBits(enum AudioFormat formatBit); 64 void CleanStdin(void); 65 void FileClose(FILE **file); 66 int32_t FormatLoadLibPath(char *resolvedPath, int32_t pathLen, int choice); 67 #endif 68