diff options
author | Pin-chih Lin <johnylin@google.com> | 2021-03-02 16:31:18 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-02 13:15:06 +0000 |
commit | 9e0cdc10a93848567cf82e3ac7fa28fde97720e9 (patch) | |
tree | 10e42b15af7955abd5810c715345603c3e687884 | |
parent | 002cea28db763b00631444afdc27a2639ad15fdd (diff) | |
download | adhd-9e0cdc10a93848567cf82e3ac7fa28fde97720e9.tar.gz |
CRAS: check ucm manager exists before noise cancellation functions
The variable ucm could be NULL for alsa_io if there is no UCM config for
the device. We should check if it exists before usage, e.g. the noise
cancellation set/check which we recently added.
BUG=b:181329545
TEST=Check USB Headset play/record is worked on Caroline
Change-Id: I3c46615902ca8e074a74b7bc03da36b85c035f69
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2728905
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
Reviewed-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
Commit-Queue: Pin-chih Lin <johnylin@chromium.org>
Tested-by: Pin-chih Lin <johnylin@chromium.org>
Auto-Submit: Pin-chih Lin <johnylin@chromium.org>
-rw-r--r-- | cras/src/server/cras_alsa_io.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/cras/src/server/cras_alsa_io.c b/cras/src/server/cras_alsa_io.c index 32b22247..275a6810 100644 --- a/cras/src/server/cras_alsa_io.c +++ b/cras/src/server/cras_alsa_io.c @@ -414,7 +414,7 @@ static int open_dev(struct cras_iodev *iodev) aio->handle = handle; /* Enable or disable noise cancellation if it supports. */ - if (iodev->direction == CRAS_STREAM_INPUT && + if (aio->ucm && iodev->direction == CRAS_STREAM_INPUT && ucm_node_noise_cancellation_exists(aio->ucm, iodev->active_node->name)) { enable_noise_cancellation = @@ -2039,7 +2039,7 @@ static int support_noise_cancellation(const struct cras_iodev *iodev) { struct alsa_io *aio = (struct alsa_io *)iodev; - if (!iodev->active_node) + if (!aio->ucm || !iodev->active_node) return 0; return ucm_node_noise_cancellation_exists(aio->ucm, |