From 34029e209d6d116c338e7d65d6980cc395184658 Mon Sep 17 00:00:00 2001 From: henrika Date: Mon, 6 Nov 2017 11:59:15 +0100 Subject: [PATCH] Removes usage of AudioRecord.Builder on Android NOTRY=TRUE Bug: b/32742417 Change-Id: Ib56e3d9da45b3d3fbe8b1658aaf6d97a99ea1886 Reviewed-on: https://webrtc-review.googlesource.com/18461 Commit-Queue: Henrik Andreassson Reviewed-by: Alex Glaznev Cr-Commit-Position: refs/heads/master@{#20621} --- .../webrtc/voiceengine/WebRtcAudioRecord.java | 38 +------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java b/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java index 6ead58fe02..38af6b125b 100644 --- a/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java +++ b/modules/audio_device/android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java @@ -219,16 +219,8 @@ public class WebRtcAudioRecord { int bufferSizeInBytes = Math.max(BUFFER_SIZE_FACTOR * minBufferSize, byteBuffer.capacity()); Logging.d(TAG, "bufferSizeInBytes: " + bufferSizeInBytes); try { - if (WebRtcAudioUtils.runningOnMarshmallowOrHigher()) { - // Use AudioRecord.Builder to create the AudioRecord instance if we are on API level 23 or - // higher. - audioRecord = createAudioRecordOnMarshmallowOrHigher( - sampleRate, channelConfig, bufferSizeInBytes); - } else { - // Use default constructor for API levels below 23. - audioRecord = new AudioRecord(AudioSource.VOICE_COMMUNICATION, sampleRate, - channelConfig, AudioFormat.ENCODING_PCM_16BIT, bufferSizeInBytes); - } + audioRecord = new AudioRecord(AudioSource.VOICE_COMMUNICATION, sampleRate, + channelConfig, AudioFormat.ENCODING_PCM_16BIT, bufferSizeInBytes); } catch (IllegalArgumentException e) { reportWebRtcAudioRecordInitError("AudioRecord ctor error: " + e.getMessage()); releaseAudioResources(); @@ -243,7 +235,6 @@ public class WebRtcAudioRecord { effects.enable(audioRecord.getAudioSessionId()); } logMainParameters(); - logMainParametersExtended(); return framesPerBuffer; } @@ -306,31 +297,6 @@ public class WebRtcAudioRecord { + "sample rate: " + audioRecord.getSampleRate()); } - @TargetApi(23) - private void logMainParametersExtended() { - if (WebRtcAudioUtils.runningOnMarshmallowOrHigher()) { - Logging.d(TAG, "AudioRecord: " - // The frame count of the native AudioRecord buffer. - + "buffer size in frames: " + audioRecord.getBufferSizeInFrames()); - } - } - - // Creates an AudioRecord instance using AudioRecord.Builder which was added in API level 23. - @TargetApi(23) - private AudioRecord createAudioRecordOnMarshmallowOrHigher( - int sampleRateInHz, int channelConfig, int bufferSizeInBytes) { - Logging.d(TAG, "createAudioRecordOnMarshmallowOrHigher"); - return new AudioRecord.Builder() - .setAudioSource(AudioSource.VOICE_COMMUNICATION) - .setAudioFormat(new AudioFormat.Builder() - .setEncoding(AudioFormat.ENCODING_PCM_16BIT) - .setSampleRate(sampleRateInHz) - .setChannelMask(channelConfig) - .build()) - .setBufferSizeInBytes(bufferSizeInBytes) - .build(); - } - // Helper method which throws an exception when an assertion has failed. private static void assertTrue(boolean condition) { if (!condition) {