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. */ 26struct 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 * + as input: 35 * - delay_ns is the delay introduced by playback buffers 36 * - time_stamp is the time stamp corresponding to the delay calculation 37 * + as output: 38 * unused 39 * when used for EchoReference::read(): 40 * + as input: 41 * - delay_ns is the delay introduced by capture buffers 42 * - time_stamp is the time stamp corresponding to the delay calculation 43 * + as output: 44 * - delay_ns is the delay between the returned frames and the capture time derived from 45 * delay and time stamp indicated as input. This delay is to be communicated to the AEC. 46 * - frame_count is updated with the actual number of frames returned 47 */ 48 49struct echo_reference_itfe { 50 int (*read)(struct echo_reference_itfe *echo_reference, struct echo_reference_buffer *buffer); 51 int (*write)(struct echo_reference_itfe *echo_reference, struct echo_reference_buffer *buffer); 52}; 53 54int create_echo_reference(audio_format_t rdFormat, 55 uint32_t rdChannelCount, 56 uint32_t rdSamplingRate, 57 audio_format_t wrFormat, 58 uint32_t wrChannelCount, 59 uint32_t wrSamplingRate, 60 struct echo_reference_itfe **); 61 62void release_echo_reference(struct echo_reference_itfe *echo_reference); 63 64__END_DECLS 65 66#endif // ANDROID_ECHO_REFERENCE_H 67