移动开发

MT6589平台通话录音时播放提示音给对方功能的具体实现

2020-11-06 18:08:53 阅读数 9178 收藏 0
1.修改AudioMTKStreamOut.cpp ssize_t AudioMTKStreamOut::write(const void *buffer, size_t bytes)
{
case android_audio_legacy::AudioSystem::MODE_IN_CALL:
case android_audio_legacy::AudioSystem::MODE_IN_CALL_2:
修改pBGSPlayer->Open(pSpeechDriver, 0x0, 0xFF); 為pBGSPlayer->Open(pSpeechDriver, 0xFF, 0xFF);

2.修改InCallScreen.java
a.添加: import android.media.ToneGenerator;
b. 添加成员:private ToneGenerator mToneGenerator;
c. 修改函数 private void onRecordClick(MenuItem menuItem)
在 startRecord(); 之前添加:
mToneGenerator = new ToneGenerator(AudioManager.STREAM_MUSIC, 240);
setVolumeControlStream(AudioManager.STREAM_MUSIC); mToneGenerator.startTone(24, 1000);
d.修改函数 private void stopRecord() 添加:
if (mToneGenerator != null) { mToneGenerator.release(); mToneGenerator = null; }