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:
Ranveer Aggarwal
2022-08-04 16:20:56 +00:00
committed by WebRTC LUCI CQ
parent 5bb566cf1e
commit a0e090ff5a
2 changed files with 21 additions and 7 deletions

View File

@ -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();