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