1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 * 4 */ 5 6 #ifndef __AUDIO_STREAM_H__ 7 #define __AUDIO_STREAM_H__ 8 9 10 enum stream_state { 11 STREAM_STOP = 0, 12 STREAM_SETUP, 13 STREAM_START, 14 STREAM_RUNNING, 15 }; 16 17 struct noise_suppression { 18 void *handler; 19 }; 20 21 struct auto_gain_control { 22 void *handler; 23 }; 24 25 struct out_stream { 26 #ifdef AUDIO_CACHE_ENABLE 27 uint8_t *buffer; 28 int buffer_size; 29 int buffer_dirty_size; 30 #endif 31 uint8_t silent:1; 32 enum stream_state state; 33 void *eq; 34 FILE *dump; 35 os_mutex_t lock; 36 struct pcm_device pcm; 37 }; 38 39 struct in_stream { 40 enum stream_state state; 41 os_mutex_t lock; 42 struct noise_suppression *ns; 43 struct auto_gain_control *agc; 44 void *aec; 45 void *vad; 46 struct pcm_device pcm; 47 }; 48 49 struct audio_device { 50 struct out_stream *out; 51 struct in_stream *in; 52 uint8_t noise_suppression:1; 53 uint8_t echo_cancellation:1; 54 uint8_t auto_gain_control:1; 55 uint8_t vad_enable:1; 56 uint8_t equalizer_enable:1; 57 uint8_t out_pcm_dump:1; 58 uint8_t vad_start:1; 59 uint8_t in_device_fix:1; 60 int out_volume; 61 snd_device_t out_device; 62 snd_device_t in_device; 63 snd_device_t fixed_out_device; 64 }; 65 66 int out_volume_set(int volume); 67 int out_volume_get(void); 68 int out_volume_range(int *max, int *min); 69 int out_device_set(snd_device_t device); 70 int out_extpa_set(audio_extpa_info_t *info); 71 int out_stream_reset(struct out_stream *out); 72 int out_stream_mute(struct out_stream *out, int mute); 73 bool out_stream_configured(struct out_stream *out); 74 int out_stream_configure(struct out_stream *out, media_pcminfo_t *pcminfo); 75 int out_stream_period_duration(struct out_stream *out); 76 int out_stream_write(struct out_stream *out, uint8_t *buffer, int nbytes); 77 int out_stream_silent(struct out_stream *out); 78 int out_stream_stop(struct out_stream *out); 79 struct out_stream *out_stream_create(void); 80 int out_stream_release(struct out_stream *out); 81 bool in_stream_configured(struct in_stream *in); 82 int in_stream_configure(struct in_stream *in, media_pcminfo_t *pcminfo); 83 int in_stream_read(struct in_stream *in, uint8_t *buffer, int nbytes); 84 int in_stream_stop(struct in_stream *in); 85 struct in_stream *in_stream_create(void); 86 int in_stream_release(struct in_stream *in); 87 int audio_param_set(int key, int value); 88 int audio_device_init(void); 89 int audio_device_deinit(void); 90 91 92 #endif /* __AUDIO_STREAM_H__ */ 93