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

Commit 4c6fc9f8 authored by Sandhya Mutha Naga Venkata's avatar Sandhya Mutha Naga Venkata Committed by Gerrit - the friendly Code Review server
Browse files

audio: hal: Fix for memory leaks.

Change-Id: I3206b5a05869f3eb2c4dffaaf44ebf4ce0f08b4a
parent b186e5e0
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -4,6 +4,10 @@
 *
 * Copyright (C) 2013 The Android Open Source Project
 *
 * Changes from Qualcomm Innovation Center are provided under the following license:
 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
 * SPDX-License-Identifier: BSD-3-Clause-Clear
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -243,6 +247,19 @@ cleanup:
            list_remove(node);
            free(key_info);
        }

        if (result < 0) {

            if (snd_card_name)
                free((void *)snd_card_name);

            if (my_data->acdb_init_data.snd_card_name)
                free(my_data->acdb_init_data.snd_card_name);

            if (my_data)
                platform_info_deinit();
        }

        free(my_data);
    }

+26 −12
Original line number Diff line number Diff line
@@ -1909,6 +1909,7 @@ static snd_device_t derive_playback_snd_device(void * platform,

    snd_device_t d1 = uc->out_snd_device;
    snd_device_t d2 = new_snd_device;
    snd_device_t ret = 0;

    list_init(&a1);
    list_init(&a2);
@@ -1939,28 +1940,39 @@ static snd_device_t derive_playback_snd_device(void * platform,
                      __func__,
                      list_length(&a1) > 1 ? d1 : d2);
            }
            ret = d2;
            goto end;
        }

        if (platform_check_backends_match(d3[0], d3[1])) {
            return d2; // case 5
            ret = d2;
            goto end; // case 5
        } else {
            if ((list_length(&a1) > 1) && (list_length(&a2) > 1) &&
                 platform_check_backends_match(d1, d2))
                return d2; //case 9
            if (list_length(&a1) > 1)
                return d1; //case 7
                 platform_check_backends_match(d1, d2)) {
                    ret = d2;
                    goto end; //case 9
                 }
            if (list_length(&a1) > 1) {
                ret = d1;
                goto end; //case 7
            }
            // check if d1 is related to any of d3's
            if (d1 == d3[0] || d1 == d3[1])
                return d1; // case 1
            else
                return d3[1]; // case 8
            if (d1 == d3[0] || d1 == d3[1]) {
                ret = d1;
                goto end; // case 1
            } else {
                 ret = d3[1];
                goto end; // case 8
            }
        }
    } else {
        if (platform_check_backends_match(d1, d2)) {
            return d2; // case 2, 4
           ret = d2;
           goto end; // case 2, 4
        } else {
            return d1; // case 6, 3
            ret = d1;
            goto end; // case 6, 3
        }
    }

@@ -1968,7 +1980,9 @@ static snd_device_t derive_playback_snd_device(void * platform,
    clear_devices(&a2);

end:
    return d2; // return whatever was calculated before.
    clear_devices(&a1);
    clear_devices(&a2);
    return ret; // return whatever was calculated before.
}

static void check_usecases_codec_backend(struct audio_device *adev,
+5 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved.
 *
 * Changes from Qualcomm Innovation Center are provided under the following license:
 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
 * SPDX-License-Identifier: BSD-3-Clause-Clear
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
@@ -1001,7 +1005,7 @@ void hw_info_deinit(void *hw_info)
{
    struct hardware_info *my_data = (struct hardware_info*) hw_info;

    if(!my_data)
    if (my_data)
        free(my_data);
}

+0 −2
Original line number Diff line number Diff line
@@ -2729,8 +2729,6 @@ static void set_platform_defaults(struct platform_data * my_data)
    hw_interface_table[SND_DEVICE_IN_CAPTURE_FM] = strdup("SLIMBUS_8_TX");
    hw_interface_table[SND_DEVICE_IN_AANC_HANDSET_MIC] = strdup("SLIMBUS_0_TX");
    hw_interface_table[SND_DEVICE_IN_QUAD_MIC] = strdup("SLIMBUS_0_TX");
    hw_interface_table[SND_DEVICE_IN_HANDSET_DMIC_STEREO] = strdup("SLIMBUS_0_TX");
    hw_interface_table[SND_DEVICE_IN_SPEAKER_DMIC_STEREO] = strdup("SLIMBUS_0_TX");
    hw_interface_table[SND_DEVICE_IN_CAPTURE_VI_FEEDBACK] = strdup("SLIMBUS_4_TX");
    hw_interface_table[SND_DEVICE_IN_CAPTURE_VI_FEEDBACK_MONO_1] = strdup("SLIMBUS_4_TX");
    hw_interface_table[SND_DEVICE_IN_CAPTURE_VI_FEEDBACK_MONO_2] = strdup("SLIMBUS_4_TX");
+1 −0
Original line number Diff line number Diff line
@@ -293,6 +293,7 @@ void platform_add_app_type(const char *uc_type,

/* From platform_info.c */
int platform_info_init(const char *filename, void *, caller_t);
void platform_info_deinit();

void platform_snd_card_update(void *platform, card_status_t scard_status);

Loading