audio: Fix volume control for offload playback
Update the mixer control name used for volume control during
offload playback. Add an option to try the newer control
if the first (default) one isn't present.
Change-Id: I02dee627cc97bfb454b0e5dec2558f693593bb85
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 2179b86..53aed41 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1322,9 +1322,17 @@
ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
if (!ctl) {
- ALOGE("%s: Could not get ctl for mixer cmd - %s",
- __func__, mixer_ctl_name);
- return -EINVAL;
+ /* try with the control based on device id */
+ int pcm_device_id = platform_get_pcm_device_id(out->usecase,
+ PCM_PLAYBACK);
+ char ctl_name[128] = {0};
+ snprintf(ctl_name, sizeof(ctl_name),
+ "Compress Playback %d Volume", pcm_device_id);
+ ctl = mixer_get_ctl_by_name(adev->mixer, ctl_name);
+ if (!ctl) {
+ ALOGE("%s: Could not get volume ctl mixer cmd", __func__);
+ return -EINVAL;
+ }
}
volume[0] = (int)(left * COMPRESS_PLAYBACK_VOLUME_MAX);
volume[1] = (int)(right * COMPRESS_PLAYBACK_VOLUME_MAX);