I am quite new in android and java development. I have access to an app that was written by my teammate for CAT S61 phone using oboe library. The phone is using the two microphones to localize a sound source using audio of both microphones. However, when I try it on other phones, it is not working as expected, it is as if it does not recognize one of the microphones (this is just an assumption as I can't really figure out why is it not working). Beside CAT S61, I could only make it work on xiaomi mi 9t pro.
This is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion '30.0.3'
defaultConfig {
applicationId "com.example.project"
minSdkVersion 26
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
//arguments "-DANDROID_ARM_MODE=arm", "-DANDROID_STL=c++_shared"
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
sourceSets {
main {
// let gradle pack the shared library into apk
jni.srcDirs = []
jniLibs.srcDirs = ['distribution/lib']
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.10.2"
}
}
ndkVersion '21.0.6113669'
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.navigation:navigation-fragment:2.3.1'
implementation 'androidx.navigation:navigation-ui:2.3.1'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
this is where it has been configured to use the built in mic
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
AudioDeviceInfo[] adi = audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS);
for (AudioDeviceInfo ad : adi)
{
if (ad.getType() == AudioDeviceInfo.TYPE_BUILTIN_MIC)
{
LiveEffectEngine.setRecordingDeviceId(ad.getId());
}
}
this is the permission part of manifest file
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Now this is LOGCAT after running the app on RAZER 2 phone where the app is NOT working
2020-12-28 17:32:46.435 26570-26570/? I/OboeAudio: openStream() OUTPUT -------- OboeVersion1.4.2 --------
2020-12-28 17:32:46.435 26570-26570/? D/OboeAudio: AAudioLoader(): dlopen(libaaudio.so) returned 0xf9a9a01a74d4a8d9
2020-12-28 17:32:46.436 26570-26570/? D/AAudio: AAudioStreamBuilder_openStream() called ----------------------------------------
2020-12-28 17:32:46.436 26570-26570/? D/AudioStreamBuilder: build() EXCLUSIVE sharing mode not supported. Use SHARED.
2020-12-28 17:32:46.437 26570-26570/? I/AAudioStream: open() rate = 0, channels = 1, format = 1, sharing = SH, dir = OUTPUT
2020-12-28 17:32:46.437 26570-26570/? I/AAudioStream: open() device = 0, sessionId = 0, perfMode = 12, callback: ON with frames = 0
2020-12-28 17:32:46.437 26570-26570/? I/AAudioStream: open() usage = 1, contentType = 2, inputPreset = 6
2020-12-28 17:32:46.437 26570-26570/? D/AudioStreamTrack: open(), request notificationFrames = 0, frameCount = 8192
2020-12-28 17:32:46.438 720-928/? D/AudioFlinger: Client defaulted notificationFrames to 96 for frameCount 8192
2020-12-28 17:32:46.440 680-680/? D/compress_voip: voice_extn_compress_voip_out_get_parameters: enter
2020-12-28 17:32:46.441 26570-26570/? I/AudioTrack: AUDIO_OUTPUT_FLAG_FAST successful; frameCount 8192 -> 8192
2020-12-28 17:32:46.441 26570-26570/? W/AudioStreamTrack: open() sampleRate changed from 0 to 48000
2020-12-28 17:32:46.442 26570-26570/? D/AAudio: AAudioStreamBuilder_openStream() returns 0 = AAUDIO_OK for (0x7da765c180) ----------------
2020-12-28 17:32:46.443 26570-26570/? D/OboeAudio: AudioStreamAAudio.open() format=1, sampleRate=48000, capacity = 8192
2020-12-28 17:32:46.443 26570-26570/? D/OboeAudio: AudioStreamAAudio.open: AAudioStream_Open() returned AAUDIO_OK
2020-12-28 17:32:46.443 26570-26570/? I/OboeAudio: openStream() INPUT -------- OboeVersion1.4.2 --------
2020-12-28 17:32:46.443 26570-26570/? D/AAudio: AAudioStreamBuilder_openStream() called ----------------------------------------
2020-12-28 17:32:46.443 26570-26570/? D/AudioStreamBuilder: build() EXCLUSIVE sharing mode not supported. Use SHARED.
2020-12-28 17:32:46.443 26570-26570/? I/AAudioStream: open() rate = 44100, channels = 2, format = 1, sharing = SH, dir = INPUT
2020-12-28 17:32:46.443 26570-26570/? I/AAudioStream: open() device = 17, sessionId = 0, perfMode = 12, callback: OFF with frames = 0
2020-12-28 17:32:46.443 26570-26570/? I/AAudioStream: open() usage = 1, contentType = 2, inputPreset = 6
2020-12-28 17:32:46.446 680-4020/? D/audio_hw_primary: adev_open_input_stream: enter: sample_rate(44100) channel_mask(0xc) devices(0x80000080) stream_handle(0xea253180) io_handle(1742) source(6) format 1
2020-12-28 17:32:46.446 680-4020/? W/audio_hw_utils: audio_extn_utils_update_stream_input_app_type_cfg: App type could not be selected. Falling back to default
2020-12-28 17:32:46.447 720-26649/? I/AudioFlinger: AudioFlinger's thread 0xe59035c0 tid=26649 ready to run
2020-12-28 17:32:46.448 680-4020/? D/audio_hw_primary: in_standby: enter: stream (0xea253180) usecase(18: audio-record)
2020-12-28 17:32:46.448 720-2283/? W/AudioFlinger: createRecordTrack_l(): mismatch between requested flags (00000005) and input flags (00000001)
2020-12-28 17:32:46.448 680-4020/? D/audio_hw_primary: in_standby: enter: stream (0xea253180) usecase(18: audio-record)
2020-12-28 17:32:46.450 680-4020/? D/audio_hw_primary: adev_close_input_stream: enter:stream_handle(0xea253180)
2020-12-28 17:32:46.450 680-4020/? D/soundtrigger: audio_extn_sound_trigger_check_ec_ref_enable: EC Reference is disabled
2020-12-28 17:32:46.450 680-4020/? D/sound_trigger_hw: handle_audio_ec_ref_enabled: Enter
2020-12-28 17:32:46.450 680-4020/? D/sound_trigger_hw: handle_audio_ec_ref_enabled: Exit audio ec ref=0
and this is for xiaomi mi 9t pro phone where the app is working
2020-12-28 17:52:29.102 24540-24540/? W/Activity: Slow Operation: Activity com.example.convoaid/.MainActivity onResume took 165ms
2020-12-28 17:52:29.115 24540-24540/? W/Looper: Slow Looper main: Activity com.example.convoaid/.MainActivity is 308ms late (wall=277ms running=236ms ClientTransaction{ callbacks=[android.app.servertransaction.ActivityRelaunchItem] lifecycleRequest=android.app.servertransaction.ResumeActivityItem }) because of 6 msg, msg 1 took 395ms (seq=89 running=212ms runnable=73ms late=22ms h=android.app.ActivityThread$H w=159), msg 3 took 102ms (seq=91 running=27ms runnable=17ms late=392ms h=android.view.Choreographer$FrameHandler c=android.view.Choreographer$FrameDisplayEventReceiver)
2020-12-28 17:52:29.175 24540-24540/? W/Looper: Slow Looper main: doFrame is 311ms late because of 6 msg, msg 1 took 102ms (seq=91 running=27ms runnable=17ms late=392ms h=android.view.Choreographer$FrameHandler c=android.view.Choreographer$FrameDisplayEventReceiver), msg 5 took 277ms (seq=95 running=236ms runnable=9ms late=308ms h=android.app.ActivityThread$H w=159)
2020-12-28 17:52:52.996 24540-24540/? I/OboeAudio: openStream() OUTPUT -------- OboeVersion1.4.2 --------
2020-12-28 17:52:52.997 24540-24540/? D/OboeAudio: AAudioLoader(): dlopen(libaaudio.so) returned 0xbd8f620ee08e9787
2020-12-28 17:52:52.997 24540-24540/? I/AAudio: AAudioStreamBuilder_openStream() called ----------------------------------------
2020-12-28 17:52:52.997 24540-24540/? I/AudioStreamBuilder: rate = 0, channels = 1, format = 1, sharing = EX, dir = OUTPUT
2020-12-28 17:52:52.997 24540-24540/? I/AudioStreamBuilder: device = 0, sessionId = -1, perfMode = 12, callback: ON with frames = 0
2020-12-28 17:52:52.997 24540-24540/? I/AudioStreamBuilder: usage = 1, contentType = 2, inputPreset = 6, allowedCapturePolicy = 0
2020-12-28 17:52:53.008 24540-24540/? D/AudioStreamInternal_Client: open() - openStream() returned -889, try switching from MONO to STEREO
2020-12-28 17:52:53.036 24540-24540/? D/AudioStreamInternal_Client: open() original HW burst = 48, minMicros = 2000 => SW burst = 96
2020-12-28 17:52:53.037 24540-24540/? I/AAudio: AAudioStreamBuilder_openStream() returns 0 = AAUDIO_OK for s#1 ----------------
2020-12-28 17:52:53.037 24540-24540/? D/OboeAudio: AudioStreamAAudio.open() format=1, sampleRate=48000, capacity = 12288
2020-12-28 17:52:53.037 24540-24540/? D/OboeAudio: AudioStreamAAudio.open: AAudioStream_Open() returned AAUDIO_OK
2020-12-28 17:52:53.037 24540-24540/? I/OboeAudio: openStream() INPUT -------- OboeVersion1.4.2 --------
2020-12-28 17:52:53.037 24540-24540/? I/AAudio: AAudioStreamBuilder_openStream() called ----------------------------------------
2020-12-28 17:52:53.037 24540-24540/? I/AudioStreamBuilder: rate = 44100, channels = 2, format = 1, sharing = EX, dir = INPUT
2020-12-28 17:52:53.037 24540-24540/? I/AudioStreamBuilder: device = 19, sessionId = -1, perfMode = 12, callback: OFF with frames = 0
2020-12-28 17:52:53.037 24540-24540/? I/AudioStreamBuilder: usage = 1, contentType = 2, inputPreset = 6, allowedCapturePolicy = 0
2020-12-28 17:52:53.257 24540-24540/? W/BpBinder: Slow Binder: BpBinder transact took 219 ms, interface=IAAudioService, code=2 oneway=false
2020-12-28 17:52:53.258 24540-24540/? D/AudioRecord: set(): inputSource 0, sampleRate 44100, format 0x1, channelMask 0xc, frameCount 8192, notificationFrames 0, sessionId 0, transferType 3, flags 0x5, opPackageName uid -1, pid -1
2020-12-28 17:52:53.289 24540-24540/? W/AudioStreamRecord: open() flags changed from 0x00000005 to 0x00000000
2020-12-28 17:52:53.289 24540-24540/? W/AudioStreamRecord: open() perfMode changed from 12 to 10
2020-12-28 17:52:53.289 24540-24540/? I/AAudio: AAudioStreamBuilder_openStream() returns 0 = AAUDIO_OK for s#3 ----------------
2020-12-28 17:52:53.289 24540-24540/? D/OboeAudio: AudioStreamAAudio.open() format=1, sampleRate=44100, capacity = 8192
2020-12-28 17:52:53.289 24540-24540/? D/OboeAudio: AudioStreamAAudio.open: AAudioStream_Open() returned AAUDIO_OK
2020-12-28 17:52:53.289 24540-24540/? V/Convoaid: Frames per burst (from native): 888, buffer size: 8192
2020-12-28 17:52:53.289 24540-24540/? V/Convoaid: framesize: 4096, 44100
2020-12-28 17:52:53.290 24540-24540/? D/AAudio: AAudioStream_requestStart(s#3) called --------------
2020-12-28 17:52:53.290 24540-24540/? D/AudioRecord: start(7998): sync event 0 trigger session 0 mSessionID=46985
2020-12-28 17:52:53.300 24540-24540/? D/AAudio: AAudioStream_requestStart(s#3) returned 0 ---------
2020-12-28 17:52:53.300 24540-24540/? D/AAudio: AAudioStream_requestStart(s#1) called --------------
2020-12-28 17:52:53.302 24540-24563/? D/AudioStreamLegacy: onAudioDeviceUpdate() devId 19 => 19
2020-12-28 17:52:53.302 24540-24563/? D/AudioStreamLegacy: onAudioDeviceUpdate() devId 19 => 19
2020-12-28 17:52:53.431 24540-24540/? D/AAudio: AAudioStream_requestStart(s#1) returned 0 ---------
2020-12-28 17:52:53.433 24540-24690/? D/AudioStreamInternalPlay_Client: callbackLoop() entering >>>>>>>>>>>>>>>
2020-12-28 17:52:53.433 24540-24540/? V/Convoaid: Angle set to -90.000000, resulting shift in frames: -18.677647
2020-12-28 17:52:53.433 24540-24540/? V/Convoaid: Shifting ch1 by 18.677647 and ch2 by 0.000000
2020-12-28 17:52:53.433 24540-24690/? D/AudioStreamInternal_Client: onEventFromServer - got AAUDIO_SERVICE_EVENT_STARTED
I would appreciate it if anyone could give me a clue about what could be wrong? is there some specific configuration based on each mobile that I should be aware of?
User contributions licensed under CC BY-SA 3.0