| Index: webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java
|
| diff --git a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java
|
| index 11eb51383d80730bf552adf543d5083c518f27ce..593f998dd37c01944ab2cce36a75226a819a2d09 100644
|
| --- a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java
|
| +++ b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java
|
| @@ -152,7 +152,7 @@ class WebRtcAudioTrack {
|
| }
|
| }
|
|
|
| - private void initPlayout(int sampleRate, int channels) {
|
| + private boolean initPlayout(int sampleRate, int channels) {
|
| Logging.d(TAG, "initPlayout(sampleRate=" + sampleRate + ", channels="
|
| + channels + ")");
|
| final int bytesPerFrame = channels * (BITS_PER_SAMPLE / 8);
|
| @@ -191,17 +191,27 @@ class WebRtcAudioTrack {
|
| AudioTrack.MODE_STREAM);
|
| } catch (IllegalArgumentException e) {
|
| Logging.d(TAG, e.getMessage());
|
| - return;
|
| + return false;
|
| + }
|
| +
|
| + // It can happen that an AudioTrack is created but it was not successfully
|
| + // initialized upon creation. Seems to be the case e.g. when the maximum
|
| + // number of globally available audio tracks is exceeded.
|
| + if (audioTrack.getState() != AudioTrack.STATE_INITIALIZED) {
|
| + Logging.e(TAG, "Initialization of audio track failed.");
|
| + return false;
|
| }
|
| - assertTrue(audioTrack.getState() == AudioTrack.STATE_INITIALIZED);
|
| - assertTrue(audioTrack.getPlayState() == AudioTrack.PLAYSTATE_STOPPED);
|
| - assertTrue(audioTrack.getStreamType() == AudioManager.STREAM_VOICE_CALL);
|
| + return true;
|
| }
|
|
|
| private boolean startPlayout() {
|
| Logging.d(TAG, "startPlayout");
|
| assertTrue(audioTrack != null);
|
| assertTrue(audioThread == null);
|
| + if (audioTrack.getState() != AudioTrack.STATE_INITIALIZED) {
|
| + Logging.e(TAG, "Audio track is not successfully initialized.");
|
| + return false;
|
| + }
|
| audioThread = new AudioTrackThread("AudioTrackJavaThread");
|
| audioThread.start();
|
| return true;
|
|
|