[FM] There is no sound output after resuming playing when FM is over BT
Launch FM radio and play -> Stop FM -> Turn on BT and connect with BT
earphone with A2DP -> Open FM and resume playing, there is no sound
output after step 4.
Bug 19171819
from: https://partner-android-review.googlesource.com/#/c/199683/
Change-Id: I01d3975387840d9356c6f80d1f411eeb8526f930
Signed-off-by: Benson Huang <benson.huang@mediatek.com>
diff --git a/src/com/android/fmradio/FmService.java b/src/com/android/fmradio/FmService.java
index c00e8cf..7f2ef78 100644
--- a/src/com/android/fmradio/FmService.java
+++ b/src/com/android/fmradio/FmService.java
@@ -385,19 +385,16 @@
private synchronized void startRender() {
Log.d(TAG, "startRender " + AudioSystem.getForceUse(FOR_PROPRIETARY));
- // Stop old AudioRecord and create a new AudioRecord
- // when plugging out and then plugging in wired headset.
- // Otherwise, reading data from old AudioRecord will be blocked.
- if (AudioSystem.getForceUse(FOR_PROPRIETARY) ==
- AudioSystem.FORCE_SPEAKER && mIsSpeakerUsed) {
- if (mAudioRecord != null) {
- mAudioRecord.stop();
- }
- if (mAudioTrack != null) {
- mAudioTrack.stop();
- }
- initAudioRecordSink();
- }
+
+ // need to create new audio record and audio play back track,
+ // because input/output device may be changed.
+ if (mAudioRecord != null) {
+ mAudioRecord.stop();
+ }
+ if (mAudioTrack != null) {
+ mAudioTrack.stop();
+ }
+ initAudioRecordSink();
mIsRender = true;
synchronized (mRenderLock) {