Commit 1b8a4cff authored by Simon Morlat's avatar Simon Morlat

fixes relative to hardware AEC on Android 4.4

parent b83b82d6
......@@ -38,11 +38,18 @@ AudioRecord::AudioRecord(audio_source_t inputSource,
audio_input_flags_t flags){
mThis=new uint8_t[512];
mImpl=AudioRecordImpl::get();
mSessionId=-1;
if (mImpl->mCtorBeforeAPI17.isFound()) {
mImpl->mCtorBeforeAPI17.invoke(mThis,inputSource,sampleRate,format,channelMask,frameCount,(record_flags)0,cbf,user,notificationFrames,sessionId);
} else {
/* The flags parameter was removed in Android 4.2 (API level 17). */
if (AudioTrackImpl::get()->mSdkVersion>=19 && sessionId==0){
sessionId=AudioSystem::newAudioSessionId();
if (sessionId==-1){
sessionId=0;
}else mSessionId=sessionId;
}
mImpl->mCtor.invoke(mThis,inputSource,sampleRate,format,channelMask,frameCount,cbf,user,notificationFrames,sessionId,transferType,flags);
}
}
......@@ -92,7 +99,8 @@ audio_io_handle_t AudioRecord::getInput() const{
int AudioRecord::getSessionId() const{
if (mImpl->mGetSessionId.isFound()){
return mImpl->mGetSessionId.invoke(mThis);
}
}else if (mSessionId!=-1)
return mSessionId;
ms_warning("AudioRecord::getSessionId() not available");
return -1;
}
......@@ -109,7 +117,7 @@ void AudioRecord::readBuffer(const void *p_info, Buffer *buffer){
}
bool AudioRecord::isRefCounted()const{
return mImpl->mSdkVersion>=19;
return AudioTrackImpl::get()->mSdkVersion>=19;
}
void AudioRecord::destroy()const{
......@@ -117,7 +125,7 @@ void AudioRecord::destroy()const{
delete []mThis;
}
bool AudioRecordImpl::init(Library *lib, int sdkVersion){
bool AudioRecordImpl::init(Library *lib){
bool fail=false;
AudioRecordImpl *impl=new AudioRecordImpl(lib);
if (!impl->mCtorBeforeAPI17.isFound() && !impl->mCtor.isFound()) {
......@@ -139,7 +147,6 @@ bool AudioRecordImpl::init(Library *lib, int sdkVersion){
fail=true;
ms_error("AudioRecord::start() not found.");
}
impl->mSdkVersion=sdkVersion;
if (fail){
delete impl;
return false;
......
......@@ -361,11 +361,12 @@ protected:
private:
uint8_t *mThis;
AudioRecordImpl *mImpl;
int mSessionId;
};
class AudioRecordImpl{
public:
static bool init(Library *lib, int sdkVersion);
static bool init(Library *lib);
static AudioRecordImpl *get(){
return sImpl;
}
......@@ -401,7 +402,6 @@ public:
Function4<status_t, int*, uint32_t, int, int> mGetMinFrameCount;
Function1<int,const void *> mGetSessionId;
//Function1<audio_io_handle_t,void*> mGetInput;
int mSdkVersion;
private:
AudioRecordImpl(Library *lib);
static AudioRecordImpl *sImpl;
......
......@@ -59,6 +59,15 @@ status_t AudioSystem::setForceUse(audio_policy_force_use_t usage, audio_policy_f
return AudioSystemImpl::get()->mSetForceUse.invoke(usage, config);
}
int AudioSystem::newAudioSessionId(){
if (AudioSystemImpl::get()->mNewAudioSessionId.isFound())
return AudioSystemImpl::get()->mNewAudioSessionId.invoke();
else{
ms_warning("AudioSystem::newAudioSessionId() not found.");
return -1;
}
}
audio_io_handle_t AudioSystem::getInput(audio_source_t inputSource,
uint32_t samplingRate,
audio_format_t format,
......@@ -78,7 +87,8 @@ AudioSystemImpl::AudioSystemImpl(Library *lib) :
mGetOutputLatency(lib, "_ZN7android11AudioSystem16getOutputLatencyEPji"),
mSetParameters(lib,"_ZN7android11AudioSystem13setParametersEiRKNS_7String8E"),
mSetPhoneState(lib, "_ZN7android11AudioSystem13setPhoneStateEi"),
mSetForceUse(lib, "_ZN7android11AudioSystem11setForceUseENS0_9force_useENS0_13forced_configE") {
mSetForceUse(lib, "_ZN7android11AudioSystem11setForceUseENS0_9force_useENS0_13forced_configE"),
mNewAudioSessionId(lib,"_ZN7android11AudioSystem17newAudioSessionIdEv"){
//mGetInput(lib,"_ZN7android11AudioSystem8getInputEijjjNS0_18audio_in_acousticsE"){
mApi18=false;
// Try some Android 4.0 symbols if not found
......
......@@ -255,6 +255,7 @@ public:
Function2<status_t,audio_io_handle_t,const String8 &> mSetParameters;
Function1<status_t, audio_mode_t> mSetPhoneState;
Function2<status_t, audio_policy_force_use_t, audio_policy_forced_cfg_t> mSetForceUse;
Function0<int> mNewAudioSessionId;
//Function6<audio_io_handle_t,audio_source_t,uint32_t,audio_format_t,uint32_t,audio_in_acoustics_t,int> mGetInput;
private:
AudioSystemImpl(Library *lib);
......
......@@ -161,6 +161,7 @@ namespace fake_android{
mLatency(lib,"_ZNK7android10AudioTrack7latencyEv"),
mGetPosition(lib,"_ZNK7android10AudioTrack11getPositionEPj") //4.4 symbol
{
mSdkVersion=0;
// Try some Android 2.2 symbols if not found
if (!mCtor.isFound()) {
mCtor.load(lib,"_ZN7android10AudioTrackC1EijiiijPFviPvS1_ES1_i");
......@@ -170,6 +171,9 @@ namespace fake_android{
if (!mCtor.isFound()){
mCtor.load(lib,"_ZN7android10AudioTrackC1E19audio_stream_type_tj14audio_format_t"
"ji20audio_output_flags_tPFviPvS4_ES4_iiNS0_13transfer_typeEPK20audio_offload_info_ti");
if (mCtor.isFound()){
mSdkVersion=19;
}
}
}
......@@ -182,7 +186,7 @@ namespace fake_android{
}
}
bool AudioTrackImpl::init(Library *lib, int sdkVersion){
bool AudioTrackImpl::init(Library *lib){
bool fail=false;
AudioTrackImpl *impl=new AudioTrackImpl(lib);
......@@ -216,9 +220,11 @@ namespace fake_android{
ms_error("AudioTrack::getPosition() not found");
fail=true;
}
impl->mSdkVersion=sdkVersion;
if (!fail){
sImpl=impl;
if (impl->mSdkVersion>=19){
ms_message("AudioTrack and AudioRecord need refcounting.");
}
return true;
}else{
delete impl;
......
......@@ -441,7 +441,7 @@ private:
class AudioTrackImpl{
public:
static bool init(Library *lib, int sdk_version);
static bool init(Library *lib);
static AudioTrackImpl *get(){
return sImpl;
}
......
......@@ -248,8 +248,8 @@ static void android_snd_card_detect(MSSndCardManager *m){
if (libmedia && libutils){
/*perform initializations in order rather than in a if statement so that all missing symbols are shown in logs*/
audio_record_loaded=AudioRecordImpl::init(libmedia,get_sdk_version());
audio_track_loaded=AudioTrackImpl::init(libmedia,get_sdk_version());
audio_record_loaded=AudioRecordImpl::init(libmedia);
audio_track_loaded=AudioTrackImpl::init(libmedia);
audio_system_loaded=AudioSystemImpl::init(libmedia);
string8_loaded=String8Impl::init(libutils);
refbase_loaded=RefBaseImpl::init(libutils);
......
......@@ -148,7 +148,7 @@ typedef enum {
AUDIO_FORMAT_PCM_SUB_8_24_BIT),
} audio_format_t;
typedef enum {
enum {
/* output channels */
AUDIO_CHANNEL_OUT_FRONT_LEFT = 0x1,
AUDIO_CHANNEL_OUT_FRONT_RIGHT = 0x2,
......
......@@ -110,6 +110,8 @@ static SoundDeviceDescription devices[]={
{ "Amazon", "KFTT", "omap4", DEVICE_USE_ANDROID_MIC,200},
{ "LENOVO", "Lenovo B6000-F", "",DEVICE_HAS_BUILTIN_AEC_CRAPPY,300},
{ "Enspert", "IGGY", "" , 0, 320 ,0}, /*Wiko iggy*/
{ NULL, NULL, NULL, 0, 0,0}
};
......@@ -250,8 +252,7 @@ SoundDeviceDescription * sound_device_description_get(void){
}else exact_match=TRUE;
if (d) {
ms_message("Found AEC information for [%s/%s/%s] from internal table: builtin=[%s], delay=[%i] ms",
manufacturer,model,platform, (d->flags & DEVICE_HAS_BUILTIN_AEC) ? "yes" : "no", d->delay);
ms_message("Found AEC information for [%s/%s/%s] from internal table",manufacturer,model,platform);
}else d=&undefined;
if (declares_builtin_aec){
......@@ -262,6 +263,8 @@ SoundDeviceDescription * sound_device_description_get(void){
d->delay=0;
}
}
ms_message("Sound device information for [%s/%s/%s] is: builtin=[%s], delay=[%i] ms",
manufacturer,model,platform, (d->flags & DEVICE_HAS_BUILTIN_AEC) ? "yes" : "no", d->delay);
return d;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment