• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 __BEGIN_DECLS
24 
25 /** Buffer descriptor used by read() and write() methods, including the time stamp and delay. */
26 struct echo_reference_buffer {
27     void *raw;                  // pointer to audio frame
28     size_t frame_count;         // number of frames in buffer
29     int32_t delay_ns;           // delay for this buffer (see comment below)
30     struct timespec time_stamp; // time stamp for this buffer (see comment below)
31                                 // default ALSA gettimeofday() format
32 };
33 
34 /**
35  * + as input:
36  *      - delay_ns is the delay introduced by playback buffers
37  *      - time_stamp is the time stamp corresponding to the delay calculation
38  * + as output:
39  *      unused
40  * when used for EchoReference::read():
41  * + as input:
42  *      - delay_ns is the delay introduced by capture buffers
43  *      - time_stamp is the time stamp corresponding to the delay calculation
44  * + as output:
45  *      - delay_ns is the delay between the returned frames and the capture time derived from
46  *      delay and time stamp indicated as input. This delay is to be communicated to the AEC.
47  *      - frame_count is updated with the actual number of frames returned
48  */
49 
50 struct echo_reference_itfe {
51     int (*read)(struct echo_reference_itfe *echo_reference, struct echo_reference_buffer *buffer);
52     int (*write)(struct echo_reference_itfe *echo_reference, struct echo_reference_buffer *buffer);
53 };
54 
55 int create_echo_reference(audio_format_t rdFormat,
56                           uint32_t rdChannelCount,
57                           uint32_t rdSamplingRate,
58                           audio_format_t wrFormat,
59                           uint32_t wrChannelCount,
60                           uint32_t wrSamplingRate,
61                           struct echo_reference_itfe **);
62 
63 void release_echo_reference(struct echo_reference_itfe *echo_reference);
64 
65 __END_DECLS
66 
67 #endif // ANDROID_ECHO_REFERENCE_H
68