Extend the audio HAL interface to support get/set master mute: DO NOT MERGE
Extend the audio HAL interface to allow HALs to optionally support HW
level master mute. This follows the same pattern as master volume and
is part of the fix for bug 6828363. Because of the divergences
between ICS and master, this change will need to be merged by hand.
Signed-off-by: John Grossman <johngro@google.com>
Change-Id: Ica6f5e37e13d13dde60463966f41f271ffa104fd
diff --git a/include/hardware/audio.h b/include/hardware/audio.h
index ac014a1..6770ce0 100644
--- a/include/hardware/audio.h
+++ b/include/hardware/audio.h
@@ -284,11 +284,26 @@
* master volume control. AudioFlinger will query this value from the
* primary audio HAL when the service starts and use the value for setting
* the initial master volume across all HALs. HALs which do not support
- * this method should may leave it set to NULL.
+ * this method may leave it set to NULL.
*/
int (*get_master_volume)(struct audio_hw_device *dev, float *volume);
/**
+ * set the audio mute status for all audio activities. If any value other
+ * than 0 is returned, the software mixer will emulate this capability.
+ */
+ int (*set_master_mute)(struct audio_hw_device *dev, bool mute);
+
+ /**
+ * Get the current master mute status for the HAL, if the HAL supports
+ * master mute control. AudioFlinger will query this value from the primary
+ * audio HAL when the service starts and use the value for setting the
+ * initial master mute across all HALs. HALs which do not support this
+ * method may leave it set to NULL.
+ */
+ int (*get_master_mute)(struct audio_hw_device *dev, bool *mute);
+
+ /**
* setMode is called when the audio mode changes. AUDIO_MODE_NORMAL mode
* is for standard audio playback, AUDIO_MODE_RINGTONE when a ringtone is
* playing, and AUDIO_MODE_IN_CALL when a call is in progress.
diff --git a/modules/audio/audio_hw.c b/modules/audio/audio_hw.c
index f25a053..47b3bb4 100644
--- a/modules/audio/audio_hw.c
+++ b/modules/audio/audio_hw.c
@@ -285,8 +285,17 @@
return -ENOSYS;
}
-static int adev_get_master_volume(struct audio_hw_device *dev,
- float *volume)
+static int adev_get_master_volume(struct audio_hw_device *dev, float *volume)
+{
+ return -ENOSYS;
+}
+
+static int adev_set_master_mute(struct audio_hw_device *dev, bool muted)
+{
+ return -ENOSYS;
+}
+
+static int adev_get_master_mute(struct audio_hw_device *dev, bool *muted)
{
return -ENOSYS;
}
@@ -415,6 +424,8 @@
adev->device.set_voice_volume = adev_set_voice_volume;
adev->device.set_master_volume = adev_set_master_volume;
adev->device.get_master_volume = adev_get_master_volume;
+ adev->device.set_master_mute = adev_set_master_mute;
+ adev->device.get_master_mute = adev_get_master_mute;
adev->device.set_mode = adev_set_mode;
adev->device.set_mic_mute = adev_set_mic_mute;
adev->device.get_mic_mute = adev_get_mic_mute;