FMRadio: Pause and stop AudioTrack before stopping
* According to documentation, stop will continue to play the last
buffer, while pause immediately halts playback.
* Pause to reduce latency to stop, then flush the AudioTrack buffer
before actually stopping in the render thread.
Change-Id: I0b497cd6b95b0921f63796746c7279a4f931dbd3
diff --git a/src/com/android/fmradio/FmService.java b/src/com/android/fmradio/FmService.java
index 32ffcf4..7e89237 100644
--- a/src/com/android/fmradio/FmService.java
+++ b/src/com/android/fmradio/FmService.java
@@ -503,6 +503,8 @@
mCurrentFrame = 0;
if (mAudioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING) {
+ mAudioTrack.pause();
+ mAudioTrack.flush();
mAudioTrack.stop();
}