diff options
author | Joshua Lang <joshualang@google.com> | 2016-11-02 14:29:21 -0700 |
---|---|---|
committer | Joshua Lang <joshualang@google.com> | 2017-01-19 12:46:54 -0800 |
commit | e72995d4ac7fe80fb608599ceb35ecb13367f903 (patch) | |
tree | 802d504b8c45e73a2b4932c5f3650c5460a1adf8 /audio | |
parent | 2b7bbd49ed8ad21750b42a77e53fce2fa70da7ec (diff) | |
download | device_generic_goldfish-e72995d4ac7fe80fb608599ceb35ecb13367f903.tar.gz device_generic_goldfish-e72995d4ac7fe80fb608599ceb35ecb13367f903.tar.bz2 device_generic_goldfish-e72995d4ac7fe80fb608599ceb35ecb13367f903.zip |
Enable audio channels and set default volume
This fixes the audio device being muted by default.
Test: Boot emulator and check audio is not muted
Change-Id: Ied6b02910dcb23fdebd3b8a1e3f8ec23d2d78ff1
Diffstat (limited to 'audio')
-rw-r--r-- | audio/audio_hw.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c index 393494b8..4efd67b4 100644 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -47,6 +47,7 @@ struct generic_audio_device { struct audio_hw_device device; // Constant after init pthread_mutex_t lock; bool mic_mute; // Proteced by this->lock + struct mixer* mixer; // Proteced by this->lock }; /* If not NULL, this is a pointer to the fallback module. @@ -977,6 +978,9 @@ static int adev_close(hw_device_t *dev) } if ((--audio_device_ref_count) == 0) { + if (adev->mixer) { + mixer_close(adev->mixer); + } free(adev); } @@ -1035,6 +1039,32 @@ static int adev_open(const hw_module_t* module, const char* name, *device = &adev->device.common; + adev->mixer = mixer_open(PCM_CARD); + struct mixer_ctl *ctl; + + // Set default mixer ctls + // Enable channels and set volume + for (int i = 0; i < (int)mixer_get_num_ctls(adev->mixer); i++) { + ctl = mixer_get_ctl(adev->mixer, i); + ALOGD("mixer %d name %s", i, mixer_ctl_get_name(ctl)); + if (!strcmp(mixer_ctl_get_name(ctl), "Master Playback Volume") || + !strcmp(mixer_ctl_get_name(ctl), "Capture Volume")) { + for (int z = 0; z < (int)mixer_ctl_get_num_values(ctl); z++) { + ALOGD("set ctl %d to %d", z, 100); + mixer_ctl_set_percent(ctl, z, 100); + } + continue; + } + if (!strcmp(mixer_ctl_get_name(ctl), "Master Playback Switch") || + !strcmp(mixer_ctl_get_name(ctl), "Capture Switch")) { + for (int z = 0; z < (int)mixer_ctl_get_num_values(ctl); z++) { + ALOGD("set ctl %d to %d", z, 1); + mixer_ctl_set_value(ctl, z, 1); + } + continue; + } + } + audio_device_ref_count++; unlock: |