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

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

Issue 2574053003: Improves release of allocated audio resources on Android (Closed)
Patch Set: restored one error check Created 4 years 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 | webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java » ('j') | 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/WebRtcAudioRecord.java
diff --git a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java
index 136cce45e0a8af3b8009091c362235bb6cb01728..23b2c60c9c585b430dc07baa4dd84c6628c76ad7 100644
--- a/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java
+++ b/webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java
@@ -189,10 +189,12 @@ public class WebRtcAudioRecord {
AudioFormat.ENCODING_PCM_16BIT, bufferSizeInBytes);
} catch (IllegalArgumentException e) {
Logging.e(TAG, e.getMessage());
+ releaseAudioResources();
return -1;
}
if (audioRecord == null || audioRecord.getState() != AudioRecord.STATE_INITIALIZED) {
Logging.e(TAG, "Failed to create a new AudioRecord instance");
+ releaseAudioResources();
return -1;
}
if (effects != null) {
@@ -233,8 +235,7 @@ public class WebRtcAudioRecord {
if (effects != null) {
effects.release();
}
- audioRecord.release();
- audioRecord = null;
+ releaseAudioResources();
return true;
}
@@ -274,4 +275,12 @@ public class WebRtcAudioRecord {
Logging.w(TAG, "setMicrophoneMute(" + mute + ")");
microphoneMute = mute;
}
+
+ // Releases the native AudioRecord resources.
+ private void releaseAudioResources() {
+ if (audioRecord != null) {
+ audioRecord.release();
+ audioRecord = null;
+ }
+ }
}
« no previous file with comments | « no previous file | webrtc/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698