[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit
Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/lib/libaudiomix/mix.c b/ap/lib/libaudiomix/mix.c
new file mode 100755
index 0000000..f0de0f9
--- /dev/null
+++ b/ap/lib/libaudiomix/mix.c
@@ -0,0 +1,86 @@
+/*****************************************************************************
+** °æÈ¨ËùÓÐ (C)2015, ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+**
+** ÎļþÃû³Æ: mix.c
+** Îļþ±êʶ:
+** ÄÚÈÝÕªÒª:
+** ʹÓ÷½·¨:
+**
+** ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ Ð޸ıê¼Ç ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
+** -----------------------------------------------------------------------------
+** 2019/09/25 V1.0 Create xxq ´´½¨
+**
+* ******************************************************************************/
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <stdint.h>
+#include <linux/volte_drv.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+
+#define MIX_DEV_INVALID_ID (-1)
+#define DRV_SUCCESS 0
+#define DRV_ERROR (-1)
+#define AUDIO_MIX_DEV_NAME "/dev/audio_mix_device"
+
+int audio_mix_devfd = MIX_DEV_INVALID_ID;
+
+int zDrvAudioMix_Write(unsigned char *pBuf, unsigned int uiLen)
+{
+ if(audio_mix_devfd == MIX_DEV_INVALID_ID)
+ {
+ printf("zte audio /dev/audio_mix_device zDrvAudioMix_WriteOneFrame invalid dev!\n");
+ return DRV_ERROR;
+ }
+
+ if(write(audio_mix_devfd, pBuf, uiLen) <= 0)
+ {
+ printf("zte audio /dev/audio_mix_device zDrvAudioMix_WriteOneFrame write failed!\n");
+ return DRV_ERROR;
+ }
+
+ return DRV_SUCCESS;
+}
+
+int zDrvAudioMix_Open(T_ZDrvAudioMix_Cfg *cfgParam)
+{
+ audio_mix_devfd = open(AUDIO_MIX_DEV_NAME, O_RDWR);
+ printf("open end! audio_mix_devfd=%d, audioType=%d, sample_rate=%d\n", audio_mix_devfd, cfgParam->audioType, cfgParam->sample_rate);
+ if(audio_mix_devfd < 0)
+ {
+ printf("zte audio /dev/audio_mix_device zDrvAudioMix_Open failed!\n");
+ return DRV_ERROR;
+ }
+
+ if(ioctl(audio_mix_devfd, AUDIOMIX_IOCTL_SET_CFG, cfgParam) < 0)
+ {
+ printf("zte audio /dev/audio_mix_device set cfg failed!\n");
+ goto err;
+ }
+
+ return DRV_SUCCESS;
+err:
+ close(audio_mix_devfd);
+ audio_mix_devfd = MIX_DEV_INVALID_ID;
+ printf("zte audio /dev/audio_mix_device zDrvAudioMix_Open failed!\n");
+ return DRV_ERROR;
+
+}
+
+int zDrvAudioMix_Close(void)
+{
+ if(audio_mix_devfd == MIX_DEV_INVALID_ID)
+ {
+ printf("zte audio /dev/audio_mix_device zDrvAudioMix_Close invalid dev!\n");
+ return DRV_ERROR;
+ }
+ close(audio_mix_devfd);
+ audio_mix_devfd = MIX_DEV_INVALID_ID;
+
+ return DRV_SUCCESS;
+}
+