Skip to content
Snippets Groups Projects
Commit 76b2c967 authored by Dhananjay Kumar's avatar Dhananjay Kumar Committed by Gerrit - the friendly Code Review server
Browse files

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
parent c9829e56
No related branches found
No related tags found
No related merge requests found
...@@ -283,10 +283,6 @@ public class FMRadioService extends Service ...@@ -283,10 +283,6 @@ public class FMRadioService extends Service
cancelAlarms(); cancelAlarms();
//release the audio focus listener //release the audio focus listener
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
if (isMuted()) {
mMuted = false;
audioManager.setStreamMute(AudioManager.STREAM_MUSIC,false);
}
audioManager.abandonAudioFocus(mAudioFocusListener); audioManager.abandonAudioFocus(mAudioFocusListener);
/* Remove the Screen On/off listener */ /* Remove the Screen On/off listener */
if (mScreenOnOffReceiver != null) { if (mScreenOnOffReceiver != null) {
...@@ -356,6 +352,8 @@ public class FMRadioService extends Service ...@@ -356,6 +352,8 @@ public class FMRadioService extends Service
AUDIO_SAMPLE_RATE, AUDIO_CHANNEL_CONFIG, AUDIO_SAMPLE_RATE, AUDIO_CHANNEL_CONFIG,
AUDIO_ENCODING_FORMAT, FM_RECORD_BUF_SIZE, AUDIO_ENCODING_FORMAT, FM_RECORD_BUF_SIZE,
AudioTrack.MODE_STREAM); AudioTrack.MODE_STREAM);
if (mMuted)
mAudioTrack.setVolume(0.0f);
} }
private synchronized void startRecordSink() { private synchronized void startRecordSink() {
...@@ -1530,8 +1528,6 @@ public class FMRadioService extends Service ...@@ -1530,8 +1528,6 @@ public class FMRadioService extends Service
mSpeakerDisableHandler.postDelayed(mSpeakerDisableTask, 0); mSpeakerDisableHandler.postDelayed(mSpeakerDisableTask, 0);
} }
if (true == mPlaybackInProgress) { if (true == mPlaybackInProgress) {
if(mMuted)
unMute();
stopFM(); stopFM();
} }
if (mSpeakerPhoneOn) { if (mSpeakerPhoneOn) {
...@@ -2145,7 +2141,6 @@ public class FMRadioService extends Service ...@@ -2145,7 +2141,6 @@ public class FMRadioService extends Service
if(audioManager != null) if(audioManager != null)
{ {
Log.d(LOGTAG, "audioManager.setFmRadioOn = false \n" ); Log.d(LOGTAG, "audioManager.setFmRadioOn = false \n" );
unMute();
stopFM(); stopFM();
//audioManager.setParameters("FMRadioOn=false"); //audioManager.setParameters("FMRadioOn=false");
Log.d(LOGTAG, "audioManager.setFmRadioOn false done \n" ); Log.d(LOGTAG, "audioManager.setFmRadioOn false done \n" );
...@@ -2396,7 +2391,9 @@ public class FMRadioService extends Service ...@@ -2396,7 +2391,9 @@ public class FMRadioService extends Service
if (audioManager != null) if (audioManager != null)
{ {
mMuted = true; mMuted = true;
audioManager.setStreamMute(AudioManager.STREAM_MUSIC,true); audioManager.setParameters("fm_mute=1");
if (mAudioTrack != null)
mAudioTrack.setVolume(0.0f);
} }
return bCommandSent; return bCommandSent;
} }
...@@ -2416,7 +2413,9 @@ public class FMRadioService extends Service ...@@ -2416,7 +2413,9 @@ public class FMRadioService extends Service
if (audioManager != null) if (audioManager != null)
{ {
mMuted = false; mMuted = false;
audioManager.setStreamMute(AudioManager.STREAM_MUSIC,false); audioManager.setParameters("fm_mute=0");
if (mAudioTrack != null)
mAudioTrack.setVolume(1.0f);
if (mResumeAfterCall) if (mResumeAfterCall)
{ {
//We are unmuting FM in a voice call. Need to enable FM audio routing. //We are unmuting FM in a voice call. Need to enable FM audio routing.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment