Added an API to disable VolumeLogger on Android.
Change-Id: Ib16c9e02fe18e1d6628f2192a21c53515753bcde Bug: webrtc:14321 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/270621 Reviewed-by: Xavier Lepaul <xalep@webrtc.org> Commit-Queue: Xavier Lepaul <xalep@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37693}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
5bb566cf1e
commit
a0e090ff5a
@ -50,6 +50,7 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
private boolean useStereoOutput;
|
||||
private AudioAttributes audioAttributes;
|
||||
private boolean useLowLatency;
|
||||
private boolean enableVolumeLogger;
|
||||
|
||||
private Builder(Context context) {
|
||||
this.context = context;
|
||||
@ -57,6 +58,7 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
this.inputSampleRate = WebRtcAudioManager.getSampleRate(audioManager);
|
||||
this.outputSampleRate = WebRtcAudioManager.getSampleRate(audioManager);
|
||||
this.useLowLatency = false;
|
||||
this.enableVolumeLogger = true;
|
||||
}
|
||||
|
||||
public Builder setScheduler(ScheduledExecutorService scheduler) {
|
||||
@ -213,6 +215,12 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Disables the volume logger on the audio output track. */
|
||||
public Builder setEnableVolumeLogger(boolean enableVolumeLogger) {
|
||||
this.enableVolumeLogger = enableVolumeLogger;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an AudioDeviceModule based on the supplied arguments. The caller takes ownership
|
||||
* and is responsible for calling release().
|
||||
@ -248,8 +256,9 @@ public class JavaAudioDeviceModule implements AudioDeviceModule {
|
||||
final WebRtcAudioRecord audioInput = new WebRtcAudioRecord(context, executor, audioManager,
|
||||
audioSource, audioFormat, audioRecordErrorCallback, audioRecordStateCallback,
|
||||
samplesReadyCallback, useHardwareAcousticEchoCanceler, useHardwareNoiseSuppressor);
|
||||
final WebRtcAudioTrack audioOutput = new WebRtcAudioTrack(context, audioManager,
|
||||
audioAttributes, audioTrackErrorCallback, audioTrackStateCallback, useLowLatency);
|
||||
final WebRtcAudioTrack audioOutput =
|
||||
new WebRtcAudioTrack(context, audioManager, audioAttributes, audioTrackErrorCallback,
|
||||
audioTrackStateCallback, useLowLatency, enableVolumeLogger);
|
||||
return new JavaAudioDeviceModule(context, audioManager, audioInput, audioOutput,
|
||||
inputSampleRate, outputSampleRate, useStereoInput, useStereoOutput);
|
||||
}
|
||||
|
||||
@ -154,19 +154,20 @@ class WebRtcAudioTrack {
|
||||
@CalledByNative
|
||||
WebRtcAudioTrack(Context context, AudioManager audioManager) {
|
||||
this(context, audioManager, null /* audioAttributes */, null /* errorCallback */,
|
||||
null /* stateCallback */, false /* useLowLatency */);
|
||||
null /* stateCallback */, false /* useLowLatency */, true /* enableVolumeLogger */);
|
||||
}
|
||||
|
||||
WebRtcAudioTrack(Context context, AudioManager audioManager,
|
||||
@Nullable AudioAttributes audioAttributes, @Nullable AudioTrackErrorCallback errorCallback,
|
||||
@Nullable AudioTrackStateCallback stateCallback, boolean useLowLatency) {
|
||||
@Nullable AudioTrackStateCallback stateCallback, boolean useLowLatency,
|
||||
boolean enableVolumeLogger) {
|
||||
threadChecker.detachThread();
|
||||
this.context = context;
|
||||
this.audioManager = audioManager;
|
||||
this.audioAttributes = audioAttributes;
|
||||
this.errorCallback = errorCallback;
|
||||
this.stateCallback = stateCallback;
|
||||
this.volumeLogger = new VolumeLogger(audioManager);
|
||||
this.volumeLogger = enableVolumeLogger ? new VolumeLogger(audioManager) : null;
|
||||
this.useLowLatency = useLowLatency;
|
||||
Logging.d(TAG, "ctor" + WebRtcAudioUtils.getThreadInfo());
|
||||
}
|
||||
@ -266,7 +267,9 @@ class WebRtcAudioTrack {
|
||||
@CalledByNative
|
||||
private boolean startPlayout() {
|
||||
threadChecker.checkIsOnValidThread();
|
||||
volumeLogger.start();
|
||||
if (volumeLogger != null) {
|
||||
volumeLogger.start();
|
||||
}
|
||||
Logging.d(TAG, "startPlayout");
|
||||
assertTrue(audioTrack != null);
|
||||
assertTrue(audioThread == null);
|
||||
@ -298,7 +301,9 @@ class WebRtcAudioTrack {
|
||||
@CalledByNative
|
||||
private boolean stopPlayout() {
|
||||
threadChecker.checkIsOnValidThread();
|
||||
volumeLogger.stop();
|
||||
if (volumeLogger != null) {
|
||||
volumeLogger.stop();
|
||||
}
|
||||
Logging.d(TAG, "stopPlayout");
|
||||
assertTrue(audioThread != null);
|
||||
logUnderrunCount();
|
||||
|
||||
Reference in New Issue
Block a user