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

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

Merge "hal: Increase ffv process thread priority"

parents 6df8ce84 999d5648
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -494,6 +494,7 @@ ifeq ($(strip $(AUDIO_FEATURE_ENABLED_AHAL_EXT)),true)
    LOCAL_SHARED_LIBRARIES += vendor.qti.hardware.audiohalext@1.0
endif

LOCAL_CFLAGS += -D_GNU_SOURCE
LOCAL_CFLAGS += -Wall -Werror

LOCAL_COPY_HEADERS_TO   := mm-audio
+20 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
#include <cutils/properties.h>
#include <log/log.h>
#include <unistd.h>

#include "audio_hw.h"
#include "audio_extn.h"
#include "voice_extn.h"
@@ -409,6 +410,25 @@ void audio_extn_check_and_set_dts_hpx_state(const struct audio_device *adev)
}
#endif

/* Affine AHAL thread to CPU core */
void audio_extn_set_cpu_affinity()
{
    cpu_set_t cpuset;
    struct sched_param sched_param;
    int policy = SCHED_FIFO, rc = 0;

    ALOGV("%s: Set CPU affinity for read thread", __func__);
    CPU_ZERO(&cpuset);
    if (sched_setaffinity(0, sizeof(cpuset), &cpuset) != 0)
        ALOGE("%s: CPU Affinity allocation failed for Capture thread",
               __func__);

    sched_param.sched_priority = sched_get_priority_min(policy);
    rc = sched_setscheduler(0, policy, &sched_param);
    if (rc != 0)
         ALOGE("%s: Failed to set realtime priority", __func__);
}

// START: VBAT =============================================================
void vbat_feature_init(bool is_feature_enabled)
{
+2 −0
Original line number Diff line number Diff line
@@ -1209,4 +1209,6 @@ int audio_extn_get_fluence_parameters(const struct audio_device *adev,

bool audio_extn_is_custom_stereo_enabled();
void audio_extn_send_dual_mono_mixing_coefficients(struct stream_out *out);

void audio_extn_set_cpu_affinity();
#endif /* AUDIO_EXTN_H */

hal/audio_extn/ffv.c

100755 → 100644
+20 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2017-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
@@ -45,6 +45,8 @@
#include <cutils/log.h>
#include <pthread.h>
#include <sys/resource.h>
#include <unistd.h>
#include <system/thread_defs.h>

#include "audio_hw.h"
#include "audio_extn.h"
@@ -599,6 +601,7 @@ int audio_extn_ffv_init_ec_ref_loopback(struct audio_device *adev,
    int param_size = 0;
    FfvStatusType status_type;
    int ret = 0;
    ffv_quadrx_use_dwnmix_param_t quad_downmix;

    ALOGV("%s: entry", __func__);
    /* notify library to reset AEC during each start */
@@ -620,6 +623,20 @@ int audio_extn_ffv_init_ec_ref_loopback(struct audio_device *adev,
        return -ENOMEM;
    }

    if (in_snd_device == SND_DEVICE_IN_EC_REF_LOOPBACK_QUAD) {
        quad_downmix.quadrx_dwnmix_enable = true;
        ALOGD("%s: set param for 4 ch ec, handle %p", __func__, ffvmod.handle);
        status_type = ffv_set_param_fn(ffvmod.handle,
            (char *)&quad_downmix,
            FFV_QUADRX_USE_DWNMIX_PARAM,
            sizeof(ffv_quadrx_use_dwnmix_param_t));
        if (status_type) {
            ALOGE("%s: ERROR. ffv_set_param_fn for quad channel ec ref %d",
                __func__, status_type);
            return -EINVAL;
        }
    }

    pthread_mutex_lock(&ffvmod.init_lock);
    uc_info_tx->id = USECASE_AUDIO_EC_REF_LOOPBACK;
    uc_info_tx->type = PCM_CAPTURE;
@@ -775,6 +792,8 @@ int32_t audio_extn_ffv_read(struct audio_stream_in *stream __unused,
                return status;
            }
        }
        audio_extn_set_cpu_affinity();
        setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_AUDIO);
        ffvmod.capture_started = true;
    }