Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14245984 authored by Dhananjay Kumar's avatar Dhananjay Kumar
Browse files

hal: fix segfalut from call to send audio calibration

- In case of speaker protection, capture usecase is not having
  valid input stream associated with it. Hence attempt to access
  stream info while sending calibration may result in segfaults.
- Add check in send calibration, to use stream info only if its
  available, and fallback to defaults if stream is not set.

Change-Id: I880f8c66e6cba65947846dd2fef74a74be125aa9
parent 284a7f44
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 *
 * Copyright (C) 2014 The Android Open Source Project
@@ -1162,7 +1162,7 @@ void audio_extn_utils_send_audio_calibration(struct audio_device *adev,
{
    int type = usecase->type;

    if (type == PCM_PLAYBACK) {
    if (type == PCM_PLAYBACK && usecase->stream.out != NULL) {
        struct stream_out *out = usecase->stream.out;
        int snd_device = usecase->out_snd_device;
        snd_device = (snd_device == SND_DEVICE_OUT_SPEAKER) ?
@@ -1170,7 +1170,7 @@ void audio_extn_utils_send_audio_calibration(struct audio_device *adev,
        platform_send_audio_calibration(adev->platform, usecase,
                                        out->app_type_cfg.app_type,
                                        usecase->stream.out->app_type_cfg.sample_rate);
    } else if (type == PCM_CAPTURE) {
    } else if (type == PCM_CAPTURE && usecase->stream.in != NULL) {
        platform_send_audio_calibration(adev->platform, usecase,
                         usecase->stream.in->app_type_cfg.app_type,
                         usecase->stream.in->app_type_cfg.sample_rate);