lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <stdint.h> |
| 4 | #include <string.h> |
| 5 | #include <signal.h> |
| 6 | |
| 7 | #include <linux/volte_drv.h> |
| 8 | #include "../libaudiomix/include/audiomix_lib.h" |
| 9 | |
| 10 | T_ZDrvAudioMix_Cfg testParam; |
| 11 | #define BUFFER_BYTES 1024//×î´ó1024×Ö½Ú |
| 12 | int main(int argc, char **argv) //×¢Ê͵ô±àÒë¿ÉÖ´ÐÐÎļþ+++++ |
| 13 | { |
| 14 | FILE *file; |
| 15 | |
| 16 | char *filename; |
| 17 | int more_chunks = 1; |
| 18 | unsigned char buffer[BUFFER_BYTES] = {0}; |
| 19 | int ret = 0; |
| 20 | |
| 21 | testParam.sample_rate = 8000;//Òª±£Ö¤Í¬²ÉÑùƵÂÊ(½öÏÞ16KºÍ8K) |
| 22 | testParam.audioType = 1;//1-TX,2-RX//RX±»×¢Ê͵ô£¬Ö§³ÖºóÐøÀ©Õ¹ |
| 23 | |
| 24 | printf("enter main\n"); |
| 25 | |
| 26 | if (argc < 2) { |
| 27 | fprintf(stderr, "Usage: %s \n", argv[0]); |
| 28 | printf("Usage: %s \n", argv[0]); |
| 29 | return 1; |
| 30 | } |
| 31 | |
| 32 | filename = argv[1]; |
| 33 | file = fopen(filename, "rb"); |
| 34 | printf("fopen '%s' end\n", filename); |
| 35 | if (!file) { |
| 36 | fprintf(stderr, "Unable to open file '%s'\n", filename); |
| 37 | printf("Unable to open file '%s'\n", filename); |
| 38 | return 1; |
| 39 | } |
| 40 | |
| 41 | fseek(file, 0, SEEK_SET); |
| 42 | long begin = ftell(file); |
| 43 | fseek(file, 0, SEEK_END); |
| 44 | long end = ftell(file); |
| 45 | long file_size = end - begin;//×Ö½ÚÊý |
| 46 | int read_times = 0; |
| 47 | int remain_size = 0; |
| 48 | |
| 49 | fseek(file, 0, SEEK_SET);//ÖØÐÂÖûØÎļþ¿ªÍ· |
| 50 | |
| 51 | printf("zDrvAudioMix_Open start, file size is %ld\n", file_size); |
| 52 | ret = zDrvAudioMix_Open(&testParam); |
| 53 | if(ret != 0) |
| 54 | return 1; |
| 55 | printf("zDrvAudioMix_Open end\n"); |
| 56 | |
| 57 | while (more_chunks){ |
| 58 | more_chunks = fread(buffer, sizeof(buffer), 1, file); |
| 59 | |
| 60 | if(more_chunks == 1){ |
| 61 | read_times++; |
| 62 | ret = zDrvAudioMix_Write(buffer, sizeof(buffer)); |
| 63 | if(ret != 0) |
| 64 | break; |
| 65 | } |
| 66 | else{ |
| 67 | remain_size = file_size - read_times * sizeof(buffer); |
| 68 | printf("more_chunks=%d, read_times=%d, remain_size is %d\n", more_chunks, read_times, remain_size); |
| 69 | if(remain_size == 0) |
| 70 | break; |
| 71 | ret = zDrvAudioMix_Write(buffer, remain_size); |
| 72 | if(ret != 0) |
| 73 | break; |
| 74 | } |
| 75 | } |
| 76 | printf("while(more_chunks) end\n"); |
| 77 | |
| 78 | ret = zDrvAudioMix_Close(); |
| 79 | if(ret != 0) |
| 80 | return 1; |
| 81 | printf("zDrvAudioMix_Close end\n"); |
| 82 | fclose(file); |
| 83 | printf("fclose end\n"); |
| 84 | |
| 85 | return ret; |
| 86 | } |
| 87 | |