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 <henrika@webrtc.org> Reviewed-by: Alex Glaznev <glaznev@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20621}
This commit is contained in:
parent
8ebac24511
commit
34029e209d
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user