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

Commit 0e6eb099 authored by David Lin's avatar David Lin Committed by android-build-merger
Browse files

hal: speaker protect: Add deinit function to clean up

am: 41b4fe4c

Change-Id: I163cf83f1161ff5da73f2f89c53d1b63564e2866
parents 4d63db8a 41b4fe4c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ void audio_extn_set_snd_card_split(const char* in_snd_card_name);
#define audio_extn_spkr_prot_stop_processing(snd_device)     (0)
#define audio_extn_spkr_prot_is_enabled() (false)
#define audio_extn_get_spkr_prot_snd_device(snd_device) (snd_device)
#define audio_extn_spkr_prot_deinit(adev)       (0)
#else
void audio_extn_spkr_prot_init(void *adev);
int audio_extn_spkr_prot_start_processing(snd_device_t snd_device);
@@ -49,6 +50,8 @@ void audio_extn_spkr_prot_stop_processing(snd_device_t snd_device);
bool audio_extn_spkr_prot_is_enabled();
int audio_extn_get_spkr_prot_snd_device(snd_device_t snd_device);
void audio_extn_spkr_prot_calib_cancel(void *adev);
void audio_extn_spkr_prot_deinit(void *adev);

#endif

#ifndef HFP_ENABLED
+12 −0
Original line number Diff line number Diff line
@@ -190,6 +190,18 @@ void audio_extn_spkr_prot_init(void *adev) {
#endif
}

void audio_extn_spkr_prot_deinit(void *adev __unused) {
    ALOGV("%s: Entry", __func__);

#ifdef ENABLE_CIRRUS_DETECTION
    pthread_join(handle.failure_detect_thread, NULL);
#endif
    pthread_join(handle.calibration_thread, NULL);
    pthread_mutex_destroy(&handle.fb_prot_mutex);

    ALOGV("%s: Exit", __func__);
}

#ifdef CIRRUS_FACTORY_CALIBRATION
static int audio_extn_cirrus_run_calibration() {
    struct audio_device *adev = handle.adev_handle;
+5 −0
Original line number Diff line number Diff line
@@ -780,6 +780,11 @@ void audio_extn_spkr_prot_init(void *adev)
    }
}

void audio_extn_spkr_prot_deinit(void *adev __unused)
{
    ALOGV("%s: Entry", __func__);
}

int audio_extn_get_spkr_prot_snd_device(snd_device_t snd_device)
{
    if (!handle.spkr_prot_enable)
+2 −0
Original line number Diff line number Diff line
@@ -1205,6 +1205,8 @@ void platform_deinit(void *platform)
    struct operator_specific_device *device_item;
    struct listnode *node;

    audio_extn_spkr_prot_deinit(my_data->adev);

    hw_info_deinit(my_data->hw_info);

    for (dev = 0; dev < SND_DEVICE_MAX; dev++) {
+2 −0
Original line number Diff line number Diff line
@@ -1834,6 +1834,8 @@ void platform_deinit(void *platform)
    struct platform_data *my_data = (struct platform_data *)platform;
    close_csd_client(my_data->csd);

    audio_extn_spkr_prot_deinit(my_data->adev);

    hw_info_deinit(my_data->hw_info);

    for (dev = 0; dev < SND_DEVICE_MAX; dev++) {