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

Side by Side Diff: webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java

Issue 2276973003: Avoids java.lang.NullPointerException in WebRtcAudioRecord (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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 if (DEBUG) { 98 if (DEBUG) {
99 long nowTime = System.nanoTime(); 99 long nowTime = System.nanoTime();
100 long durationInMs = 100 long durationInMs =
101 TimeUnit.NANOSECONDS.toMillis((nowTime - lastTime)); 101 TimeUnit.NANOSECONDS.toMillis((nowTime - lastTime));
102 lastTime = nowTime; 102 lastTime = nowTime;
103 Logging.d(TAG, "bytesRead[" + durationInMs + "] " + bytesRead); 103 Logging.d(TAG, "bytesRead[" + durationInMs + "] " + bytesRead);
104 } 104 }
105 } 105 }
106 106
107 try { 107 try {
108 audioRecord.stop(); 108 if (audioRecord != null) {
109 audioRecord.stop();
110 }
109 } catch (IllegalStateException e) { 111 } catch (IllegalStateException e) {
110 Logging.e(TAG, "AudioRecord.stop failed: " + e.getMessage()); 112 Logging.e(TAG, "AudioRecord.stop failed: " + e.getMessage());
111 } 113 }
112 } 114 }
113 115
114 // Stops the inner thread loop and also calls AudioRecord.stop(). 116 // Stops the inner thread loop and also calls AudioRecord.stop().
115 // Does not block the calling thread. 117 // Does not block the calling thread.
116 public void stopThread() { 118 public void stopThread() {
117 Logging.d(TAG, "stopThread"); 119 Logging.d(TAG, "stopThread");
118 keepAlive = false; 120 keepAlive = false;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 286
285 private native void nativeDataIsRecorded(int bytes, long nativeAudioRecord); 287 private native void nativeDataIsRecorded(int bytes, long nativeAudioRecord);
286 288
287 // Sets all recorded samples to zero if |mute| is true, i.e., ensures that 289 // Sets all recorded samples to zero if |mute| is true, i.e., ensures that
288 // the microphone is muted. 290 // the microphone is muted.
289 public static void setMicrophoneMute(boolean mute) { 291 public static void setMicrophoneMute(boolean mute) {
290 Logging.w(TAG, "setMicrophoneMute(" + mute + ")"); 292 Logging.w(TAG, "setMicrophoneMute(" + mute + ")");
291 microphoneMute = mute; 293 microphoneMute = mute;
292 } 294 }
293 } 295 }
OLDNEW
« 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