blob: 9e1d38b6f84607d9846f06f1e4fe52fdf479a727 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001/*
2** Copyright 2011, The Android Open-Source Project
3**
4** Licensed under the Apache License, Version 2.0 (the "License");
5** you may not use this file except in compliance with the License.
6** You may obtain a copy of the License at
7**
8** http://www.apache.org/licenses/LICENSE-2.0
9**
10** Unless required by applicable law or agreed to in writing, software
11** distributed under the License is distributed on an "AS IS" BASIS,
12** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13** See the License for the specific language governing permissions and
14** limitations under the License.
15*/
16
17#ifndef ANDROID_ECHO_REFERENCE_H
18#define ANDROID_ECHO_REFERENCE_H
19
20#include <stdint.h>
21#include <sys/time.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* Buffer descriptor used by read() and write() methods, including the time stamp and delay. */
28struct echo_reference_buffer {
29 void *raw; // pointer to audio frame
30 size_t frame_count; // number of frames in buffer
31 int32_t delay_ns; // delay for this buffer (see comment below)
32 struct timespec time_stamp; // time stamp for this buffer (see comment below)
33 // default ALSA gettimeofday() format
34};
35/**
36 * + as input:
37 * - delay_ns is the delay introduced by playback buffers
38 * - time_stamp is the time stamp corresponding to the delay calculation
39 * + as output:
40 * unused
41 * when used for EchoReference::read():
42 * + as input:
43 * - delay_ns is the delay introduced by capture buffers
44 * - time_stamp is the time stamp corresponding to the delay calculation
45 * + as output:
46 * - delay_ns is the delay between the returned frames and the capture time derived from
47 * delay and time stamp indicated as input. This delay is to be communicated to the AEC.
48 * - frame_count is updated with the actual number of frames returned
49 */
50
51struct echo_reference_itfe {
52 int (*read)(struct echo_reference_itfe *echo_reference, struct echo_reference_buffer *buffer);
53 int (*write)(struct echo_reference_itfe *echo_reference, struct echo_reference_buffer *buffer);
54};
55
56int create_echo_reference(audio_format_t rdFormat,
57 uint32_t rdChannelCount,
58 uint32_t rdSamplingRate,
59 audio_format_t wrFormat,
60 uint32_t wrChannelCount,
61 uint32_t wrSamplingRate,
62 uint32_t wrMaxFrameCount,
63 struct echo_reference_itfe **);
64
65void release_echo_reference(struct echo_reference_itfe *echo_reference);
66
67#ifdef __cplusplus
68}
69#endif
70
71#endif // ANDROID_ECHO_REFERENCE_H