Allows configuration of playout audio buffer
Playout audio buffer length in Java audio device configuration with fieldtrial. Bug: webrtc:10928 Change-Id: I79286f09591f4b2c6a6146f23d3dce92a29f6b21 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150657 Reviewed-by: Henrik Andreassson <henrika@webrtc.org> Commit-Queue: Alex Narest <alexnarest@google.com> Cr-Commit-Position: refs/heads/master@{#29005}
This commit is contained in:
@ -182,9 +182,11 @@ class WebRtcAudioTrack {
|
||||
}
|
||||
|
||||
@CalledByNative
|
||||
private boolean initPlayout(int sampleRate, int channels) {
|
||||
private boolean initPlayout(int sampleRate, int channels, double bufferSizeFactor) {
|
||||
threadChecker.checkIsOnValidThread();
|
||||
Logging.d(TAG, "initPlayout(sampleRate=" + sampleRate + ", channels=" + channels + ")");
|
||||
Logging.d(TAG,
|
||||
"initPlayout(sampleRate=" + sampleRate + ", channels=" + channels
|
||||
+ ", bufferSizeFactor=" + bufferSizeFactor + ")");
|
||||
final int bytesPerFrame = channels * (BITS_PER_SAMPLE / 8);
|
||||
byteBuffer = ByteBuffer.allocateDirect(bytesPerFrame * (sampleRate / BUFFERS_PER_SECOND));
|
||||
Logging.d(TAG, "byteBuffer.capacity: " + byteBuffer.capacity());
|
||||
@ -197,11 +199,11 @@ class WebRtcAudioTrack {
|
||||
// Get the minimum buffer size required for the successful creation of an
|
||||
// AudioTrack object to be created in the MODE_STREAM mode.
|
||||
// Note that this size doesn't guarantee a smooth playback under load.
|
||||
// TODO(henrika): should we extend the buffer size to avoid glitches?
|
||||
final int channelConfig = channelCountToConfiguration(channels);
|
||||
final int minBufferSizeInBytes =
|
||||
AudioTrack.getMinBufferSize(sampleRate, channelConfig, AudioFormat.ENCODING_PCM_16BIT);
|
||||
Logging.d(TAG, "AudioTrack.getMinBufferSize: " + minBufferSizeInBytes);
|
||||
final int minBufferSizeInBytes = (int) (AudioTrack.getMinBufferSize(sampleRate, channelConfig,
|
||||
AudioFormat.ENCODING_PCM_16BIT)
|
||||
* bufferSizeFactor);
|
||||
Logging.d(TAG, "minBufferSizeInBytes: " + minBufferSizeInBytes);
|
||||
// For the streaming mode, data must be written to the audio sink in
|
||||
// chunks of size (given by byteBuffer.capacity()) less than or equal
|
||||
// to the total buffer size |minBufferSizeInBytes|. But, we have seen
|
||||
|
||||
Reference in New Issue
Block a user