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

Commit 59145161 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "hal: Add clear_devices to avoid memory leakage"

parents ec62fe0c 4f94784e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -236,6 +236,7 @@ void keep_alive_start(ka_mode_t ka_mode)
    }

exit:
    clear_devices(&out_devices);
    pthread_mutex_unlock(&ka.lock);
}

+3 −0
Original line number Diff line number Diff line
@@ -587,6 +587,7 @@ void audio_extn_sound_trigger_update_device_status(snd_device_t snd_device,
                                  __func__, event, snd_device);
        }
    }/*Events for output device, if required can be placed here in else*/
    clear_devices(&ev_info.device_info.devices);
}

void audio_extn_sound_trigger_update_stream_status(struct audio_usecase *uc_info,
@@ -645,6 +646,7 @@ void audio_extn_sound_trigger_update_stream_status(struct audio_usecase *uc_info
            }
        }
    }
    clear_devices(&ev_info.device_info.devices);
}

void audio_extn_sound_trigger_update_battery_status(bool charging)
@@ -874,6 +876,7 @@ void audio_extn_sound_trigger_deinit(struct audio_device *adev)
    if (st_dev && (st_dev->adev == adev) && st_dev->lib_handle) {
        audio_extn_snd_mon_unregister_listener(st_dev);
        dlclose(st_dev->lib_handle);
        clear_devices(&st_dev->st_ses_list);
        free(st_dev);
        st_dev = NULL;
    }
+19 −1
Original line number Diff line number Diff line
@@ -1398,6 +1398,7 @@ int enable_audio_route(struct audio_device *adev,

                platform_set_echo_reference(adev, true, &out_devices);
                in->ec_opened = true;
                clear_devices(&out_devices);
            }
        }
    } else if ((usecase->type == TRANSCODE_LOOPBACK_TX) || ((usecase->type == PCM_HFP_CALL) &&
@@ -1524,6 +1525,7 @@ int disable_audio_route(struct audio_device *adev,
            list_init(&out_devices);
            platform_set_echo_reference(in->dev, false, &out_devices);
            in->ec_opened = false;
            clear_devices(&out_devices);
        }
    }
    if (usecase->id == adev->fluence_nn_usecase_id) {
@@ -1933,6 +1935,9 @@ static snd_device_t derive_playback_snd_device(void * platform,
        }
    }

    clear_devices(&a1);
    clear_devices(&a2);

end:
    return d2; // return whatever was calculated before.
}
@@ -2923,6 +2928,7 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
        out_snd_device = platform_get_output_snd_device(adev->platform, &stream_out, usecase->type);
        assign_devices(&usecase->device_list,
                       &usecase->stream.inout->out_config.device_list);
        clear_devices(&stream_out.device_list);
    } else if (usecase->type == TRANSCODE_LOOPBACK_TX ) {
        if (usecase->stream.inout == NULL) {
            ALOGE("%s: stream.inout is NULL", __func__);
@@ -2934,6 +2940,7 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
                                                      &out_devices, usecase->type);
        assign_devices(&usecase->device_list,
                       &usecase->stream.inout->in_config.device_list);
        clear_devices(&out_devices);
    } else {
        /*
         * If the voice call is active, use the sound devices of voice call usecase
@@ -3073,6 +3080,7 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
                                                                  priority_in,
                                                                  &out_devices,
                                                                  usecase->type);
                clear_devices(&out_devices);
            }
        }
    }
@@ -3405,6 +3413,7 @@ static int stop_input_stream(struct stream_in *in)
        audio_extn_keep_alive_stop(KEEP_ALIVE_OUT_PRIMARY);

    list_remove(&uc_info->list);
    clear_devices(&uc_info->device_list);
    free(uc_info);

    if (priority_in == in) {
@@ -4057,6 +4066,7 @@ static int stop_output_stream(struct stream_out *out)
        }
    }

    clear_devices(&uc_info->device_list);
    free(uc_info);
    ALOGV("%s: exit: status(%d)", __func__, ret);
    return ret;
@@ -4241,6 +4251,7 @@ int start_output_stream(struct stream_out *out)
                                AUDIO_DEVICE_OUT_SPEAKER, "");
            select_devices(adev, out->usecase);
            assign_devices(&out->device_list, &dev);
            clear_devices(&dev);
        }
    } else {
        select_devices(adev, out->usecase);
@@ -4258,6 +4269,7 @@ int start_output_stream(struct stream_out *out)
                                    AUDIO_DEVICE_OUT_SPEAKER, "");
                select_devices(adev, out->usecase);
                assign_devices(&out->device_list, &dev);
                clear_devices(&dev);
            } else {
                ret = -EINVAL;
                goto error_open;
@@ -8060,6 +8072,7 @@ static void in_update_sink_metadata(struct audio_stream_in *stream,
        }
    }

    clear_devices(&devices);
    pthread_mutex_unlock(&adev->lock);
    pthread_mutex_unlock(&in->lock);
}
@@ -9047,6 +9060,7 @@ void adev_close_output_stream(struct audio_hw_device *dev __unused,
    pthread_mutex_destroy(&out->position_query_lock);

    pthread_mutex_lock(&adev->lock);
    clear_devices(&out->device_list);
    free(stream);
    pthread_mutex_unlock(&adev->lock);
    ALOGV("%s: exit", __func__);
@@ -10221,6 +10235,7 @@ static void adev_close_input_stream(struct audio_hw_device *dev,
        struct listnode out_devices;
        list_init(&out_devices);
        platform_set_echo_reference(adev, false, &out_devices);
        clear_devices(&out_devices);
    } else
        audio_extn_sound_trigger_update_ec_ref_status(false);

@@ -10272,6 +10287,7 @@ static void adev_close_input_stream(struct audio_hw_device *dev,
        ALOGV("%s: sound trigger pcm stop lab", __func__);
        audio_extn_sound_trigger_stop_lab(in);
    }
    clear_devices(&in->device_list);
    free(stream);
    pthread_mutex_unlock(&adev->lock);
    return;
@@ -10584,7 +10600,6 @@ int adev_create_audio_patch(struct audio_hw_device *dev,
    if (stream != NULL) {
        if (p_info->patch_type == PATCH_PLAYBACK) {
            ret = route_output_stream((struct stream_out *) stream, &devices);
            clear_devices(&devices);
        } else if (p_info->patch_type == PATCH_CAPTURE) {
            ret = route_input_stream((struct stream_in *) stream, &devices, input_source);
        }
@@ -10608,6 +10623,7 @@ int adev_create_audio_patch(struct audio_hw_device *dev,
    }

done:
    clear_devices(&devices);
    audio_extn_hw_loopback_create_audio_patch(dev,
                                        num_sources,
                                        sources,
@@ -10693,6 +10709,7 @@ int adev_release_audio_patch(struct audio_hw_device *dev,
            ret = route_output_stream((struct stream_out *) stream, &devices);
        else if (patch_type == PATCH_CAPTURE)
            ret = route_input_stream((struct stream_in *) stream, &devices, input_source);
        clear_devices(&devices);
    }

    if (ret < 0)
@@ -10930,6 +10947,7 @@ int check_a2dp_restore_l(struct audio_device *adev, struct stream_out *out, bool
        }
        pthread_mutex_unlock(&out->latch_lock);
    }
    clear_devices(&devices);
    ALOGV("%s: exit", __func__);
    return 0;
}
+2 −0
Original line number Diff line number Diff line
@@ -6940,6 +6940,7 @@ snd_device_t platform_get_output_snd_device(void *platform, struct stream_out *o
        ALOGE("%s: Unknown device(s) %#x", __func__, get_device_types(&devices));
    }
exit:
    clear_devices(&devices);
    ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]);
    return snd_device;
}
@@ -7784,6 +7785,7 @@ snd_device_t platform_get_input_snd_device(void *platform,
        }
    }
exit:
    clear_devices(&in_devices);
    ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]);
    return snd_device;
}