Commit 83267230 authored by Ghislain MARY's avatar Ghislain MARY

Fix audio record on devices that do not have AUDIO_SOURCE_VOICE_COMMUNICATION.

parent bc398d79
......@@ -36,16 +36,7 @@ AudioRecord::AudioRecord(audio_source_t inputSource,
int sessionId){
mThis=new uint8_t[512];
mImpl=AudioRecordImpl::get();
/*HACK for gingerbread */
/*
if ((channelMask & AUDIO_CHANNEL_IN_MONO) == AUDIO_CHANNEL_IN_MONO){
channelMask=0x4;
}else if ((channelMask & AUDIO_CHANNEL_IN_STEREO) == AUDIO_CHANNEL_IN_STEREO){
channelMask=0x4|0x8;
}
*/
mImpl->mCtor.invoke(mThis,inputSource,sampleRate,format,channelMask,frameCount,flags,cbf,user,notificationFrames,sessionId);
}
......
......@@ -41,7 +41,7 @@ namespace fake_android{
/* HACK for Froyo and Gingerbread */
/* This is needed because the enum values have changed between Gingerbread and ICS */
if (mImpl->mBeforeICS) {
ms_message("Android version older than ICS, apply audio channel hack");
ms_message("Android version older than ICS, apply audio channel hack for AudioTrack");
if ((channelMask & AUDIO_CHANNEL_OUT_MONO) == AUDIO_CHANNEL_OUT_MONO) {
channelMask = 0x4;
} else if ((channelMask & AUDIO_CHANNEL_OUT_STEREO) == AUDIO_CHANNEL_OUT_STEREO) {
......
......@@ -297,7 +297,7 @@ static void android_snd_read_preprocess(MSFilter *obj){
ad->mFilter=obj;
ad->read_samples=0;
ad->audio_source=AUDIO_SOURCE_VOICE_COMMUNICATION;
for(int i=0;i<3;i++){
for(int i=0;i<2;i++){
ad->rec=new AudioRecord(ad->audio_source,
ad->rate,
AUDIO_FORMAT_PCM_16_BIT,
......@@ -310,10 +310,7 @@ static void android_snd_read_preprocess(MSFilter *obj){
ms_error("Problem when setting up AudioRecord:%s source=%i,rate=%i,framecount=%i",strerror(-ss),ad->audio_source,ad->rate,ad->rec_buf_size);
delete ad->rec;
ad->rec=0;
if (i==0) {
ms_error("Retrying with AUDIO_SOURCE_VOICE_CALL");
ad->audio_source=AUDIO_SOURCE_VOICE_CALL;
}else if (i==1){
if (i == 0) {
ms_error("Retrying with AUDIO_SOURCE_MIC");
ad->audio_source=AUDIO_SOURCE_MIC;
}
......
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