diff options
author | Dan Pasanen <dan.pasanen@gmail.com> | 2015-08-10 19:55:39 -0500 |
---|---|---|
committer | Rashed Abdel-Tawab <rashed@linux.com> | 2015-10-09 18:28:45 -0400 |
commit | 1605a18347b2de64611db9fe18e988ee0b9c7d35 (patch) | |
tree | f8dd9c40236d38ccdf4ea297c0984c543d765937 | |
parent | 80615b76fe2f2c9e2526b75c3a31c4b6ab9f8bf0 (diff) | |
download | hardware_qcom_audio-1605a18347b2de64611db9fe18e988ee0b9c7d35.tar.gz hardware_qcom_audio-1605a18347b2de64611db9fe18e988ee0b9c7d35.tar.bz2 hardware_qcom_audio-1605a18347b2de64611db9fe18e988ee0b9c7d35.zip |
hal: only open the amplifier once
Change-Id: Ie9bbff74123e90b71e95809a84dcb3bbe9ba82fe
-rw-r--r-- | hal/audio_hw.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 12173f88..d10fbc82 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -257,35 +257,29 @@ static int set_voice_volume_l(struct audio_device *adev, float volume); 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; } |