Skip to content

Commit 918c2d2

Browse files
committed
对AutomaticGainControl和AcousticEchoCanceler实例添加判空保护
Change-Id: Ifdbc224355cd8c91d1e563f5f41787818368537c
1 parent 7e0ad6b commit 918c2d2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

sdk/video-link-android/src/main/java/com/tencent/iot/video/link/util/audio/AudioRecordUtil.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,12 @@ private boolean initAEC(int audioSession) {
487487
return false;
488488
}
489489
canceler = AcousticEchoCanceler.create(audioSession);
490-
canceler.setEnabled(true);
491-
return canceler.getEnabled();
490+
if (canceler != null) {
491+
canceler.setEnabled(true);
492+
return canceler.getEnabled();
493+
} else {
494+
return false;
495+
}
492496
}
493497
public boolean isDevicesSupportAGC() {
494498
return AutomaticGainControl.isAvailable();
@@ -503,8 +507,12 @@ private boolean initAGC(int audioSession) {
503507
return false;
504508
}
505509
control = AutomaticGainControl.create(audioSession);
506-
control.setEnabled(true);
507-
return control.getEnabled();
510+
if (control != null) {
511+
control.setEnabled(true);
512+
return control.getEnabled();
513+
} else {
514+
return false;
515+
}
508516
}
509517

510518
private byte[] onReadPlayerPlayPcm(int length) {

0 commit comments

Comments
 (0)