Hello there, I hope you're all doing well.
Finally, I fixed this issue up. I personally think this method is informal. But anyway...here is my solution.
I captured two logcats, one is the only audio record, another is video record.
After comparing these two logcats, I found there is a difference between audio record and video record.
logcat of Video record
StagefrightRecorder: setAudioSource: 5
StagefrightRecorder: fix the Audio source
StagefrightRecorder: setVideoSource: 1
StagefrightRecorder: setOutputFormat: 1
StagefrightRecorder: setVideoFrameRate: 30
StagefrightRecorder: setVideoSize: 1280x720
StagefrightRecorder: setParameters: video-param-encoding-bitrate=3000000
StagefrightRecorder: setParameter: key (video-param-encoding-bitrate) => value (3000000)
StagefrightRecorder: setParamVideoEncodingBitRate: 3000000
StagefrightRecorder: setVideoEncoder: 2
StagefrightRecorder: setParameters: audio-param-encoding-bitrate=96000
StagefrightRecorder: setParameter: key (audio-param-encoding-bitrate) => value (96000)
StagefrightRecorder: setParamAudioEncodingBitRate: 96000
StagefrightRecorder: setParameters: audio-param-number-of-channels=1
StagefrightRecorder: setParameter: key (audio-param-number-of-channels) => value (1)
StagefrightRecorder: setParamAudioNumberOfChannels: 1
StagefrightRecorder: setParameters: audio-param-sampling-rate=44100
StagefrightRecorder: setParameter: key (audio-param-sampling-rate) => value (44100)
StagefrightRecorder: setParamAudioSamplingRate: 44100
StagefrightRecorder: setAudioEncoder: 3
logcat of only audio record
StagefrightRecorder: init
StagefrightRecorder: setAudioSource: 1
StagefrightRecorder: fix the Audio source
StagefrightRecorder: setOutputFormat: 1
StagefrightRecorder: setAudioEncoder: 1
StagefrightRecorder: setParameters: audio-param-encoding-bitrate=12200
StagefrightRecorder: setParameter: key (audio-param-encoding-bitrate) => value (12200)
StagefrightRecorder: setParamAudioEncodingBitRate: 12200
StagefrightRecorder: setOutputFile: 36, 0, 0
StagefrightRecorder: start
StagefrightRecorder: prepare
StagefrightRecorder: clipAudioBitRate: encoder 1
StagefrightRecorder: clipAudioSampleRate: encoder 1
As you can see the StagefrightRecorder will set different parameters between audio record and video record.
Video record used AUDIO_SOURCE_CAMCORDER and AUDIO_ENCODER_AAC_ELD parameters.
And audio record used AUDIO_SOURCE_MIC and AUDIO_ENCODER_AMR_NB.
So I suspected the main bug is here. I tried to set the audio source and audio encoder parameters in AUDIO_SOURCE_MIC and AUDIO_ENCODER_AMR_NB no matter what kind of the application I launched. Then the beeping sound is gone. :smileyhappy:
This issue can be solved although this method is not the best way. But I'm still not able to understand how come does it happen when I use AUDIO_SOURCE_CAMCORDER and AUDIO_ENCODER_AAC_ELD.
If there is a good idea or experience, please feel free to let me know. Thank you.