1 /** 2 * Copyright (C) 2021 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 #include <dlfcn.h> 18 #include <host_src/eas_types.h> 19 #include <lib_src/eas_wtengine.h> 20 #include <stdbool.h> 21 #include <stdlib.h> 22 #include <string.h> 23 #include "../includes/common.h" 24 #include "../includes/memutils.h" 25 #define MEM_ALIGNMENT 16 26 #define PHASE_INCREMENT 555555 27 28 typedef void (*fp_WT_Process_Voice)(S_WT_VOICE *, S_WT_INT_FRAME *); 29 char enable_selective_overload = ENABLE_NONE; 30 void *libHandle = NULL; 31 void *phaseAccumPtr = NULL; 32 33 void exit_Handler(void) { 34 if (phaseAccumPtr) { 35 free(phaseAccumPtr); 36 } 37 if (libHandle) { 38 dlclose(libHandle); 39 } 40 } 41 42 int main() { 43 atexit(exit_Handler); 44 libHandle = dlopen("libsonivox.so", RTLD_NOW | RTLD_LOCAL); 45 FAIL_CHECK(libHandle); 46 fp_WT_Process_Voice functionWTProcessVoice = 47 (fp_WT_Process_Voice)dlsym(libHandle, "WT_ProcessVoice"); 48 FAIL_CHECK(functionWTProcessVoice); 49 50 S_WT_VOICE pWTVoice = {}; 51 enable_selective_overload = ENABLE_MEMALIGN_CHECK; 52 pWTVoice.phaseAccum = (EAS_U32)memalign(MEM_ALIGNMENT, sizeof(EAS_I16)); 53 FAIL_CHECK((void *)pWTVoice.phaseAccum); 54 phaseAccumPtr = ((void *)pWTVoice.phaseAccum); 55 enable_selective_overload = ENABLE_FREE_CHECK | ENABLE_REALLOC_CHECK; 56 pWTVoice.loopEnd = pWTVoice.phaseAccum; 57 pWTVoice.loopStart = pWTVoice.phaseAccum; 58 59 S_WT_INT_FRAME pWTIntFrame = {}; 60 pWTIntFrame.frame.phaseIncrement = PHASE_INCREMENT; 61 EAS_PCM pAudioBuffer; 62 EAS_I32 pMixBuffer; 63 pWTIntFrame.pAudioBuffer = &pAudioBuffer; 64 pWTIntFrame.pMixBuffer = &pMixBuffer; 65 pWTIntFrame.numSamples = 1; 66 67 functionWTProcessVoice(&pWTVoice, &pWTIntFrame); 68 69 return EXIT_SUCCESS; 70 } 71