Extract audio source to a static constant

For consistency with the other parameters.
This commit is contained in:
Romain Vimont 2023-05-24 21:31:47 +02:00
parent e926bf1fe8
commit 38900d7730

View file

@ -18,6 +18,7 @@ import java.nio.ByteBuffer;
public final class AudioCapture { public final class AudioCapture {
public static final int SOURCE = MediaRecorder.AudioSource.REMOTE_SUBMIX;
public static final int SAMPLE_RATE = 48000; public static final int SAMPLE_RATE = 48000;
public static final int CHANNEL_CONFIG = AudioFormat.CHANNEL_IN_STEREO; public static final int CHANNEL_CONFIG = AudioFormat.CHANNEL_IN_STEREO;
public static final int CHANNELS = 2; public static final int CHANNELS = 2;
@ -50,7 +51,7 @@ public final class AudioCapture {
// On older APIs, Workarounds.fillAppInfo() must be called beforehand // On older APIs, Workarounds.fillAppInfo() must be called beforehand
builder.setContext(FakeContext.get()); builder.setContext(FakeContext.get());
} }
builder.setAudioSource(MediaRecorder.AudioSource.REMOTE_SUBMIX); builder.setAudioSource(SOURCE);
builder.setAudioFormat(createAudioFormat()); builder.setAudioFormat(createAudioFormat());
int minBufferSize = AudioRecord.getMinBufferSize(SAMPLE_RATE, CHANNEL_CONFIG, FORMAT); int minBufferSize = AudioRecord.getMinBufferSize(SAMPLE_RATE, CHANNEL_CONFIG, FORMAT);
// This buffer size does not impact latency // This buffer size does not impact latency