[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit
Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/lib/libaudiomix/mixtest.c b/ap/lib/libaudiomix/mixtest.c
new file mode 100755
index 0000000..bec220d
--- /dev/null
+++ b/ap/lib/libaudiomix/mixtest.c
@@ -0,0 +1,87 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <signal.h>
+
+#include <linux/volte_drv.h>
+#include "../libaudiomix/include/audiomix_lib.h"
+
+T_ZDrvAudioMix_Cfg testParam;
+#define BUFFER_BYTES 1024//×î´ó1024×Ö½Ú
+int main(int argc, char **argv) //×¢Ê͵ô±àÒë¿ÉÖ´ÐÐÎļþ+++++
+{
+ FILE *file;
+
+ char *filename;
+ int more_chunks = 1;
+ unsigned char buffer[BUFFER_BYTES] = {0};
+ int ret = 0;
+
+ testParam.sample_rate = 8000;//Òª±£Ö¤Í¬²ÉÑùƵÂÊ(½öÏÞ16KºÍ8K)
+ testParam.audioType = 1;//1-TX,2-RX//RX±»×¢Ê͵ô£¬Ö§³ÖºóÐøÀ©Õ¹
+
+ printf("enter main\n");
+
+ if (argc < 2) {
+ fprintf(stderr, "Usage: %s \n", argv[0]);
+ printf("Usage: %s \n", argv[0]);
+ return 1;
+ }
+
+ filename = argv[1];
+ file = fopen(filename, "rb");
+ printf("fopen '%s' end\n", filename);
+ if (!file) {
+ fprintf(stderr, "Unable to open file '%s'\n", filename);
+ printf("Unable to open file '%s'\n", filename);
+ return 1;
+ }
+
+ fseek(file, 0, SEEK_SET);
+ long begin = ftell(file);
+ fseek(file, 0, SEEK_END);
+ long end = ftell(file);
+ long file_size = end - begin;//×Ö½ÚÊý
+ int read_times = 0;
+ int remain_size = 0;
+
+ fseek(file, 0, SEEK_SET);//ÖØÐÂÖûØÎļþ¿ªÍ·
+
+ printf("zDrvAudioMix_Open start, file size is %ld\n", file_size);
+ ret = zDrvAudioMix_Open(&testParam);
+ if(ret != 0)
+ return 1;
+ printf("zDrvAudioMix_Open end\n");
+
+ while (more_chunks){
+ more_chunks = fread(buffer, sizeof(buffer), 1, file);
+
+ if(more_chunks == 1){
+ read_times++;
+ ret = zDrvAudioMix_Write(buffer, sizeof(buffer));
+ if(ret != 0)
+ break;
+ }
+ else{
+ remain_size = file_size - read_times * sizeof(buffer);
+ printf("more_chunks=%d, read_times=%d, remain_size is %d\n", more_chunks, read_times, remain_size);
+ if(remain_size == 0)
+ break;
+ ret = zDrvAudioMix_Write(buffer, remain_size);
+ if(ret != 0)
+ break;
+ }
+ }
+ printf("while(more_chunks) end\n");
+
+ ret = zDrvAudioMix_Close();
+ if(ret != 0)
+ return 1;
+ printf("zDrvAudioMix_Close end\n");
+ fclose(file);
+ printf("fclose end\n");
+
+ return ret;
+}
+