Avoids crash in AudioTrack when audio starts in background mode

TBR=noahric

Bug: NONE
Change-Id: Ie528b36cc03d53b15fbfd56a386309a8c3adce73
Reviewed-on: https://webrtc-review.googlesource.com/2681
Commit-Queue: Henrik Andreassson <henrika@webrtc.org>
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#19927}
diff --git a/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java b/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java
index ab55567..148632b 100644
--- a/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java
+++ b/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java
@@ -120,12 +120,19 @@
         // This priming will avoid an immediate underrun, but is not required.
         // TODO(henrika): initial tests have shown that priming is not required.
         audioTrack.play();
-        assertTrue(audioTrack.getPlayState() == AudioTrack.PLAYSTATE_PLAYING);
       } catch (IllegalStateException e) {
         reportWebRtcAudioTrackStartError("AudioTrack.play failed: " + e.getMessage());
         releaseAudioResources();
         return;
       }
+      // We have seen reports that AudioTrack.play() can sometimes start in a
+      // paued mode (e.g. when application is in background mode).
+      // TODO(henrika): consider calling reportWebRtcAudioTrackStartError()
+      // and release audio resources here as well. For now, let the thread start
+      // and hope that the audio session can be restored later.
+      if (audioTrack.getPlayState() != AudioTrack.PLAYSTATE_PLAYING) {
+        Logging.w(TAG, "AudioTrack failed to enter playing state.");
+      }
 
       // Fixed size in bytes of each 10ms block of audio data that we ask for
       // using callbacks to the native WebRTC client.