diff options
author | Dhananjay Kumar <dhakumar@codeaurora.org> | 2016-01-25 20:30:17 +0530 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2016-03-22 00:14:35 +0100 |
commit | 525a5c6162f828132ef86c0e685e5122f9c618c6 (patch) | |
tree | 60b938edb63592deedea7b692e26dabce106721c | |
parent | 4df923ab5f5eb8f94168454850e6ad187f7f8632 (diff) | |
download | android_hardware_qcom_fm-525a5c6162f828132ef86c0e685e5122f9c618c6.tar.gz android_hardware_qcom_fm-525a5c6162f828132ef86c0e685e5122f9c618c6.tar.bz2 android_hardware_qcom_fm-525a5c6162f828132ef86c0e685e5122f9c618c6.zip |
Update mute API usage to fix pops and consistency
Remove deprecated setStreamMute API and instead control volume of audio
track. Since we are controlling mute/unmute state of FM audio track, we
don't have to save/restore it for other audio applications.
CRs-Fixed: 966690
Change-Id: I242c63c3edd988ed4b85e631b857d0696935cb76
-rw-r--r-- | fmapp2/src/com/caf/fmradio/FMRadioService.java | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java index 9ce5133..bc28f62 100644 --- a/fmapp2/src/com/caf/fmradio/FMRadioService.java +++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java @@ -290,10 +290,6 @@ public class FMRadioService extends Service cancelAlarms(); //release the audio focus listener AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); - if (isMuted()) { - mMuted = false; - audioManager.setStreamMute(AudioManager.STREAM_MUSIC,false); - } audioManager.abandonAudioFocus(mAudioFocusListener); /* Remove the Screen On/off listener */ if (mScreenOnOffReceiver != null) { @@ -363,6 +359,8 @@ public class FMRadioService extends Service AUDIO_SAMPLE_RATE, AUDIO_CHANNEL_CONFIG, AUDIO_ENCODING_FORMAT, FM_RECORD_BUF_SIZE, AudioTrack.MODE_STREAM); + if (mMuted) + mAudioTrack.setVolume(0.0f); } private synchronized void startRecordSink() { @@ -1580,8 +1578,6 @@ public class FMRadioService extends Service mSpeakerDisableHandler.postDelayed(mSpeakerDisableTask, 0); } if (true == mPlaybackInProgress) { - if(mMuted) - unMute(); stopFM(); } if (mSpeakerPhoneOn) { @@ -2200,7 +2196,6 @@ public class FMRadioService extends Service if(audioManager != null) { Log.d(LOGTAG, "audioManager.setFmRadioOn = false \n" ); - unMute(); stopFM(); //audioManager.setParameters("FMRadioOn=false"); Log.d(LOGTAG, "audioManager.setFmRadioOn false done \n" ); @@ -2460,7 +2455,9 @@ public class FMRadioService extends Service if (audioManager != null) { mMuted = true; - audioManager.setStreamMute(AudioManager.STREAM_MUSIC,true); + audioManager.setParameters("fm_mute=1"); + if (mAudioTrack != null) + mAudioTrack.setVolume(0.0f); } return bCommandSent; } @@ -2480,7 +2477,9 @@ public class FMRadioService extends Service if (audioManager != null) { mMuted = false; - audioManager.setStreamMute(AudioManager.STREAM_MUSIC,false); + audioManager.setParameters("fm_mute=0"); + if (mAudioTrack != null) + mAudioTrack.setVolume(1.0f); if (mResumeAfterCall) { //We are unmuting FM in a voice call. Need to enable FM audio routing. |