Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1309)

Unified Diff: webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java

Issue 2315363004: Avoids crash in WebRtcAudioTrack.initPlayout (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3e003294aac346827c2092c2698c6f97aaed7ff2..bee50af93ac2a1e705e17d336ef3c28256eef052 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
@@ -184,12 +184,22 @@ public class WebRtcAudioTrack {
AudioFormat.CHANNEL_OUT_MONO,
AudioFormat.ENCODING_PCM_16BIT);
Logging.d(TAG, "AudioTrack.getMinBufferSize: " + minBufferSizeInBytes);
- assertTrue(audioTrack == null);
-
// For the streaming mode, data must be written to the audio sink in
// chunks of size (given by byteBuffer.capacity()) less than or equal
- // to the total buffer size |minBufferSizeInBytes|.
- assertTrue(byteBuffer.capacity() < minBufferSizeInBytes);
+ // to the total buffer size |minBufferSizeInBytes|. But, we have seen
+ // reports of "getMinBufferSize(): error querying hardware". Hence, it
+ // can happen that |minBufferSizeInBytes| contains an invalid value.
+ if (byteBuffer.capacity() < minBufferSizeInBytes) {
+ Logging.e(TAG, "AudioTrack.getMinBufferSize returns an invalid value.");
magjed_webrtc 2016/09/08 09:45:21 nit: Maybe it would be nice to log this invalid va
henrika_webrtc 2016/09/08 09:46:52 But is is always logged above on line 186. OK?
magjed_webrtc 2016/09/08 09:48:18 OK.
+ return false;
+ }
+
+ // Ensure that prevision audio session was stopped correctly before trying
+ // to create a new AudioTrack.
+ if (audioTrack != null) {
+ Logging.e(TAG, "Conflict with existing AudioTrack.");
+ return false;
+ }
try {
// Create an AudioTrack object and initialize its associated audio buffer.
// The size of this buffer determines how long an AudioTrack can play
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698