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

Commit 1f40f2fc authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "audio: introduce dedicated adev->cal_lock for gef interfaces"

parents 3f65e39c fa65d3e5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -877,7 +877,7 @@ int audio_extn_keep_alive_set_parameters(struct audio_device *adev,
#ifndef AUDIO_GENERIC_EFFECT_FRAMEWORK_ENABLED

#define audio_extn_gef_init(adev) (0)
#define audio_extn_gef_deinit() (0)
#define audio_extn_gef_deinit(adev) (0)
#define audio_extn_gef_notify_device_config(devices, cmask, sample_rate, acdb_id) (0)

#ifndef INSTANCE_ID_ENABLED
@@ -907,7 +907,7 @@ int audio_extn_keep_alive_set_parameters(struct audio_device *adev,
#else

void audio_extn_gef_init(struct audio_device *adev);
void audio_extn_gef_deinit();
void audio_extn_gef_deinit(struct audio_device *adev);

void audio_extn_gef_notify_device_config(audio_devices_t audio_device,
    audio_channel_mask_t channel_mask, int sample_rate, int acdb_id);
+28 −26
Original line number Diff line number Diff line
/*
 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -113,6 +113,7 @@ void audio_extn_gef_init(struct audio_device *adev)

    ALOGV("%s: Enter with error", __func__);

    pthread_mutex_init(&adev->cal_lock, (const pthread_mutexattr_t *) NULL);
    memset(&gef_hal_handle, 0, sizeof(gef_data));

    //: check error for dlopen
@@ -186,8 +187,8 @@ int audio_extn_gef_send_audio_cal(void* dev, int acdb_dev_id,
    ALOGV("%s: Enter", __func__);
    memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t));

    //lock adev
    pthread_mutex_lock(&adev->lock);
    //lock adev->cal_lock
    pthread_mutex_lock(&adev->cal_lock);

    //pack cal
    platform_make_cal_cfg(&cal, acdb_dev_id,
@@ -196,7 +197,7 @@ int audio_extn_gef_send_audio_cal(void* dev, int acdb_dev_id,

    ret = platform_send_audio_cal(adev->platform, &cal, data, length, persist);

    pthread_mutex_unlock(&adev->lock);
    pthread_mutex_unlock(&adev->cal_lock);

    ALOGV("%s: Exit with error %d", __func__, ret);

@@ -218,8 +219,8 @@ int audio_extn_gef_get_audio_cal(void* dev, int acdb_dev_id,
    ALOGV("%s: Enter", __func__);
    memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t));

    //lock adev
    pthread_mutex_lock(&adev->lock);
    //lock adev->cal_lock
    pthread_mutex_lock(&adev->cal_lock);

    //pack cal
    platform_make_cal_cfg(&cal, acdb_dev_id,
@@ -228,7 +229,7 @@ int audio_extn_gef_get_audio_cal(void* dev, int acdb_dev_id,

    ret = platform_get_audio_cal(adev->platform, &cal, data, length, persist);

    pthread_mutex_unlock(&adev->lock);
    pthread_mutex_unlock(&adev->cal_lock);

    ALOGV("%s: Exit with error %d", __func__, ret);

@@ -250,8 +251,8 @@ int audio_extn_gef_store_audio_cal(void* dev, int acdb_dev_id,
    ALOGV("%s: Enter", __func__);
    memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t));

    //lock adev
    pthread_mutex_lock(&adev->lock);
    //lock adev->cal_lock
    pthread_mutex_lock(&adev->cal_lock);

    //pack cal
    platform_make_cal_cfg(&cal, acdb_dev_id,
@@ -260,7 +261,7 @@ int audio_extn_gef_store_audio_cal(void* dev, int acdb_dev_id,

    ret = platform_store_audio_cal(adev->platform, &cal, data, length);

    pthread_mutex_unlock(&adev->lock);
    pthread_mutex_unlock(&adev->cal_lock);

    ALOGV("%s: Exit with error %d", __func__, ret);

@@ -281,8 +282,8 @@ int audio_extn_gef_retrieve_audio_cal(void* dev, int acdb_dev_id,
    ALOGV("%s: Enter", __func__);
    memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t));

    //lock adev
    pthread_mutex_lock(&adev->lock);
    //lock adev->cal_lock
    pthread_mutex_lock(&adev->cal_lock);

    //pack cal
    platform_make_cal_cfg(&cal, acdb_dev_id,
@@ -291,7 +292,7 @@ int audio_extn_gef_retrieve_audio_cal(void* dev, int acdb_dev_id,

    ret = platform_retrieve_audio_cal(adev->platform, &cal, data, length);

    pthread_mutex_unlock(&adev->lock);
    pthread_mutex_unlock(&adev->cal_lock);

    ALOGV("%s: Exit with error %d", __func__, ret);

@@ -313,8 +314,8 @@ int audio_extn_gef_send_audio_cal(void* dev, int acdb_dev_id,
    ALOGV("%s: Enter", __func__);
    memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t));

    //lock adev
    pthread_mutex_lock(&adev->lock);
    //lock adev->cal_lock
    pthread_mutex_lock(&adev->cal_lock);

    //pack cal
    platform_make_cal_cfg(&cal, acdb_dev_id,
@@ -323,7 +324,7 @@ int audio_extn_gef_send_audio_cal(void* dev, int acdb_dev_id,

    ret = platform_send_audio_cal(adev->platform, &cal, data, length, persist);

    pthread_mutex_unlock(&adev->lock);
    pthread_mutex_unlock(&adev->cal_lock);

    ALOGV("%s: Exit with error %d", __func__, ret);

@@ -345,8 +346,8 @@ int audio_extn_gef_get_audio_cal(void* dev, int acdb_dev_id,
    ALOGV("%s: Enter", __func__);
    memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t));

    //lock adev
    pthread_mutex_lock(&adev->lock);
    //lock adev->cal_lock
    pthread_mutex_lock(&adev->cal_lock);

    //pack cal
    platform_make_cal_cfg(&cal, acdb_dev_id,
@@ -355,7 +356,7 @@ int audio_extn_gef_get_audio_cal(void* dev, int acdb_dev_id,

    ret = platform_get_audio_cal(adev->platform, &cal, data, length, persist);

    pthread_mutex_unlock(&adev->lock);
    pthread_mutex_unlock(&adev->cal_lock);

    ALOGV("%s: Exit with error %d", __func__, ret);

@@ -376,8 +377,8 @@ int audio_extn_gef_store_audio_cal(void* dev, int acdb_dev_id,
    ALOGV("%s: Enter", __func__);
    memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t));

    //lock adev
    pthread_mutex_lock(&adev->lock);
    //lock adev->cal_lock
    pthread_mutex_lock(&adev->cal_lock);

    //pack cal
    platform_make_cal_cfg(&cal, acdb_dev_id,
@@ -386,7 +387,7 @@ int audio_extn_gef_store_audio_cal(void* dev, int acdb_dev_id,

    ret = platform_store_audio_cal(adev->platform, &cal, data, length);

    pthread_mutex_unlock(&adev->lock);
    pthread_mutex_unlock(&adev->cal_lock);

    ALOGV("%s: Exit with error %d", __func__, ret);

@@ -407,8 +408,8 @@ int audio_extn_gef_retrieve_audio_cal(void* dev, int acdb_dev_id,
    ALOGV("%s: Enter", __func__);
    memset(&cal, 0, sizeof(acdb_audio_cal_cfg_t));

    //lock adev
    pthread_mutex_lock(&adev->lock);
    //lock adev->cal_lock
    pthread_mutex_lock(&adev->cal_lock);

    //pack cal
    platform_make_cal_cfg(&cal, acdb_dev_id,
@@ -417,7 +418,7 @@ int audio_extn_gef_retrieve_audio_cal(void* dev, int acdb_dev_id,

    ret = platform_retrieve_audio_cal(adev->platform, &cal, data, length);

    pthread_mutex_unlock(&adev->lock);
    pthread_mutex_unlock(&adev->cal_lock);

    ALOGV("%s: Exit with error %d", __func__, ret);

@@ -442,7 +443,7 @@ void audio_extn_gef_notify_device_config(audio_devices_t audio_device,
    return;
}

void audio_extn_gef_deinit()
void audio_extn_gef_deinit(struct audio_device *adev)
{
    ALOGV("%s: Enter", __func__);

@@ -452,6 +453,7 @@ void audio_extn_gef_deinit()
        dlclose(gef_hal_handle.handle);
    }

    pthread_mutex_destroy(&adev->cal_lock);
    memset(&gef_hal_handle, 0, sizeof(gef_data));

    ALOGV("%s: Exit", __func__);
+7 −20
Original line number Diff line number Diff line
@@ -2111,10 +2111,6 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
    struct stream_out stream_out;
    audio_usecase_t hfp_ucid;
    int status = 0;
    audio_devices_t audio_device = AUDIO_DEVICE_NONE;
    audio_channel_mask_t channel_mask = AUDIO_CHANNEL_NONE;
    int sample_rate = 0;
    int acdb_id = 0;

    ALOGD("%s for use case (%s)", __func__, use_case_table[uc_id]);

@@ -2404,11 +2400,12 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
            usecase->stream.out->app_type_cfg.sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
        }

        /* Cache stream information to be notified to gef clients */
        audio_device = usecase->stream.out->devices;
        channel_mask = usecase->stream.out->channel_mask;
        sample_rate = usecase->stream.out->app_type_cfg.sample_rate;
        acdb_id = platform_get_snd_device_acdb_id(usecase->out_snd_device);
        /* Notify device change info to effect clients registered */
        audio_extn_gef_notify_device_config(
                usecase->stream.out->devices,
                usecase->stream.out->channel_mask,
                usecase->stream.out->app_type_cfg.sample_rate,
                platform_get_snd_device_acdb_id(usecase->out_snd_device));
    }
    enable_audio_route(adev, usecase);

@@ -2470,16 +2467,6 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
         }
    }

    /* Notify device change info to effect clients registered
     * NOTE: device lock has to be unlock temporarily here.
     * To the worst case, we notify stale info to clients.
     */
    if (usecase->type == PCM_PLAYBACK) {
        pthread_mutex_unlock(&adev->lock);
        audio_extn_gef_notify_device_config(audio_device, channel_mask, sample_rate, acdb_id);
        pthread_mutex_lock(&adev->lock);
    }

    if (usecase == voip_usecase) {
        struct stream_out *voip_out = voip_usecase->stream.out;
        audio_extn_utils_send_app_type_gain(adev,
@@ -8259,7 +8246,7 @@ static int adev_close(hw_device_t *device)
        if (audio_extn_qaf_is_enabled())
            audio_extn_qaf_deinit();
        audio_route_free(adev->audio_route);
        audio_extn_gef_deinit();
        audio_extn_gef_deinit(adev);
        free(adev->snd_dev_ref_cnt);
        platform_deinit(adev->platform);
        for (i = 0; i < ARRAY_SIZE(adev->use_case_table); ++i) {
+1 −0
Original line number Diff line number Diff line
@@ -489,6 +489,7 @@ typedef void (*adm_on_routing_change_t)(void *, audio_io_handle_t);
struct audio_device {
    struct audio_hw_device device;
    pthread_mutex_t lock; /* see note below on mutex acquisition order */
    pthread_mutex_t cal_lock;
    struct mixer *mixer;
    audio_mode_t mode;
    audio_devices_t out_device;