blob: f0de0f95492d57c44d0379dc3fd9468e9220f8c5 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*****************************************************************************
2** °æÈ¨ËùÓÐ (C)2015, ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
3**
4** ÎļþÃû³Æ: mix.c
5** Îļþ±êʶ:
6** ÄÚÈÝÕªÒª:
7** ʹÓ÷½·¨:
8**
9** ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ Ð޸ıê¼Ç ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
10** -----------------------------------------------------------------------------
11** 2019/09/25 V1.0 Create xxq ´´½¨
12**
13* ******************************************************************************/
14
15#include <stdio.h>
16#include <unistd.h>
17#include <string.h>
18#include <stdlib.h>
19
20#include <stdint.h>
21#include <linux/volte_drv.h>
22#include <sys/ioctl.h>
23#include <fcntl.h>
24
25#define MIX_DEV_INVALID_ID (-1)
26#define DRV_SUCCESS 0
27#define DRV_ERROR (-1)
28#define AUDIO_MIX_DEV_NAME "/dev/audio_mix_device"
29
30int audio_mix_devfd = MIX_DEV_INVALID_ID;
31
32int zDrvAudioMix_Write(unsigned char *pBuf, unsigned int uiLen)
33{
34 if(audio_mix_devfd == MIX_DEV_INVALID_ID)
35 {
36 printf("zte audio /dev/audio_mix_device zDrvAudioMix_WriteOneFrame invalid dev!\n");
37 return DRV_ERROR;
38 }
39
40 if(write(audio_mix_devfd, pBuf, uiLen) <= 0)
41 {
42 printf("zte audio /dev/audio_mix_device zDrvAudioMix_WriteOneFrame write failed!\n");
43 return DRV_ERROR;
44 }
45
46 return DRV_SUCCESS;
47}
48
49int zDrvAudioMix_Open(T_ZDrvAudioMix_Cfg *cfgParam)
50{
51 audio_mix_devfd = open(AUDIO_MIX_DEV_NAME, O_RDWR);
52 printf("open end! audio_mix_devfd=%d, audioType=%d, sample_rate=%d\n", audio_mix_devfd, cfgParam->audioType, cfgParam->sample_rate);
53 if(audio_mix_devfd < 0)
54 {
55 printf("zte audio /dev/audio_mix_device zDrvAudioMix_Open failed!\n");
56 return DRV_ERROR;
57 }
58
59 if(ioctl(audio_mix_devfd, AUDIOMIX_IOCTL_SET_CFG, cfgParam) < 0)
60 {
61 printf("zte audio /dev/audio_mix_device set cfg failed!\n");
62 goto err;
63 }
64
65 return DRV_SUCCESS;
66err:
67 close(audio_mix_devfd);
68 audio_mix_devfd = MIX_DEV_INVALID_ID;
69 printf("zte audio /dev/audio_mix_device zDrvAudioMix_Open failed!\n");
70 return DRV_ERROR;
71
72}
73
74int zDrvAudioMix_Close(void)
75{
76 if(audio_mix_devfd == MIX_DEV_INVALID_ID)
77 {
78 printf("zte audio /dev/audio_mix_device zDrvAudioMix_Close invalid dev!\n");
79 return DRV_ERROR;
80 }
81 close(audio_mix_devfd);
82 audio_mix_devfd = MIX_DEV_INVALID_ID;
83
84 return DRV_SUCCESS;
85}
86