| 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;
|
| + }
|
| + }
|
| }
|
|
|