Resolves crash in AudioTrack.flush() on Android.

BUG=b/65286737

Review-Url: https://codereview.webrtc.org/3010973002
Cr-Commit-Position: refs/heads/master@{#19706}
This commit is contained in:
henrika 2017-09-06 02:58:22 -07:00 committed by Commit Bot
parent a0a8ed78c3
commit 789825c42d

View File

@ -173,12 +173,14 @@ public class WebRtcAudioTrack {
// Stops playing the audio data. Since the instance was created in
// MODE_STREAM mode, audio will stop playing after the last buffer that
// was written has been played.
final AudioTrack at = audioTrack;
if (at != null) {
if (audioTrack != null) {
Logging.d(TAG, "Stopping the audio track...");
at.stop();
Logging.d(TAG, "The audio track has now been stopped.");
at.flush();
try {
audioTrack.stop();
Logging.d(TAG, "The audio track has now been stopped.");
} catch (IllegalStateException e) {
Logging.e(TAG, "AudioTrack.stop failed: " + e.getMessage());
}
}
}