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

Commit 6430a69d authored by Dan Pasanen's avatar Dan Pasanen Committed by Dan Pasanen
Browse files

hal: only open the amplifier once

Change-Id: Ie9bbff74123e90b71e95809a84dcb3bbe9ba82fe
parent 90414b3b
Loading
Loading
Loading
Loading
+9 −15
Original line number Diff line number Diff line
@@ -255,36 +255,30 @@ static pthread_mutex_t adev_init_lock;
static unsigned int audio_device_ref_count;

static amplifier_device_t * get_amplifier_device(void)
{
    if (adev)
        return adev->amp;

    return NULL;
}

static int amplifier_open(void)
{
    int rc;
    amplifier_module_t *module;

    if (adev->amp)
        return adev->amp;

    rc = hw_get_module(AMPLIFIER_HARDWARE_MODULE_ID,
            (const hw_module_t **) &module);
    if (rc) {
        ALOGV("%s: Failed to obtain reference to amplifier module: %s\n",
                __func__, strerror(-rc));
        return NULL;
        return -ENODEV;
    }

    rc = amplifier_device_open((const hw_module_t *) module, &adev->amp);
    if (rc) {
        ALOGV("%s: Failed to open amplifier hardware device: %s\n",
                __func__, strerror(-rc));
        return NULL;
    }

    return adev->amp;
}

static int amplifier_open(void)
{
    amplifier_device_t *amp = get_amplifier_device();

    if (!amp) {
        return -ENODEV;
    }