summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDhananjay Kumar <dhakumar@codeaurora.org>2015-04-07 14:23:13 +0530
committerEric Laurent <elaurent@google.com>2015-04-07 23:59:53 +0000
commite26a1c248f7149118334839fe32ecd57f1fa926e (patch)
tree38d963f2c61444b32a9789e99a6cd4ec1238ac9c
parent4f33aa31c5cc96bfb7abca4ad1c8f6f8c04e46af (diff)
downloadFMRadio-e26a1c248f7149118334839fe32ecd57f1fa926e.tar.gz
CreatePatch returns error if a port is connected to an output device on a hal version less than 3.0. Hence on error fallback same path for HEADSET/Headphone as is implemented for speaker. Bug: 20104423. Change-Id: I7f165849038cb867ce6799777e92052ced147ef4 (cherry picked from commit 19ca9f8472208d429eff4e5c736d3084eb712b17)
-rw-r--r--src/com/android/fmradio/FmService.java26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/com/android/fmradio/FmService.java b/src/com/android/fmradio/FmService.java
index 35efe56..21a36b8 100644
--- a/src/com/android/fmradio/FmService.java
+++ b/src/com/android/fmradio/FmService.java
@@ -390,9 +390,13 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan
// because input/output device may be changed.
if (mAudioRecord != null) {
mAudioRecord.stop();
+ mAudioRecord.release();
+ mAudioRecord = null;
}
if (mAudioTrack != null) {
mAudioTrack.stop();
+ mAudioTrack.release();
+ mAudioTrack = null;
}
initAudioRecordSink();
@@ -1284,11 +1288,12 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan
SAMPLE_RATE, CHANNEL_CONFIG, AUDIO_FORMAT, RECORD_BUF_SIZE, AudioTrack.MODE_STREAM);
}
- private synchronized void createAudioPatch() {
+ private synchronized int createAudioPatch() {
Log.d(TAG, "createAudioPatch");
+ int status = AudioManager.SUCCESS;
if (mAudioPatch != null) {
Log.d(TAG, "createAudioPatch, mAudioPatch is not null, return");
- return;
+ return status;
}
mAudioSource = null;
@@ -1312,11 +1317,12 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan
.activeConfig();
AudioDevicePortConfig sinkConfig = (AudioDevicePortConfig) mAudioSink.activeConfig();
AudioPatch[] audioPatchArray = new AudioPatch[] {null};
- mAudioManager.createAudioPatch(audioPatchArray,
+ status = mAudioManager.createAudioPatch(audioPatchArray,
new AudioPortConfig[] {sourceConfig},
new AudioPortConfig[] {sinkConfig});
mAudioPatch = audioPatchArray[0];
}
+ return status;
}
private FmOnAudioPortUpdateListener mAudioPortUpdateListener = null;
@@ -1369,9 +1375,14 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan
ArrayList<AudioPatch> patches = new ArrayList<AudioPatch>();
mAudioManager.listAudioPatches(patches);
if (isPatchMixerToEarphone(patches)) {
+ int status;
stopAudioTrack();
stopRender();
- createAudioPatch();
+ status = createAudioPatch();
+ if (status != AudioManager.SUCCESS){
+ Log.d(TAG, "onAudioPatchListUpdate: fallback as createAudioPatch failed");
+ startRender();
+ }
}
}
}
@@ -1645,9 +1656,14 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan
mAudioManager.listAudioPatches(patches);
if (mAudioPatch == null) {
if (isPatchMixerToEarphone(patches)) {
+ int status;
stopAudioTrack();
stopRender();
- createAudioPatch();
+ status = createAudioPatch();
+ if (status != AudioManager.SUCCESS){
+ Log.d(TAG, "enableFmAudio: fallback as createAudioPatch failed");
+ startRender();
+ }
} else {
startRender();
}