audio policy: manage stream volume per device

Improve volume management by keeping track of volume for each type
of device independently.

Added functions at the audio policy interface to set and get stream volume
for a particular device.

Change-Id: Ic8899e82e48193cb65b3673e9d20383efed943b5
diff --git a/include/hardware/audio_policy.h b/include/hardware/audio_policy.h
index add14f8..7485953 100644
--- a/include/hardware/audio_policy.h
+++ b/include/hardware/audio_policy.h
@@ -91,7 +91,7 @@
                                        audio_policy_dev_state_t state,
                                        const char *device_address);
 
-    /* retreive a device connection status */
+    /* retrieve a device connection status */
     audio_policy_dev_state_t (*get_device_connection_state)(
                                             const struct audio_policy *pol,
                                             audio_devices_t device,
@@ -110,7 +110,7 @@
                           audio_policy_force_use_t usage,
                           audio_policy_forced_cfg_t config);
 
-    /* retreive current device category forced for a given usage */
+    /* retrieve current device category forced for a given usage */
     audio_policy_forced_cfg_t (*get_force_use)(const struct audio_policy *pol,
                                                audio_policy_force_use_t usage);
 
@@ -174,23 +174,37 @@
      */
 
     /* initialises stream volume conversion parameters by specifying volume
-     * index range. */
+     * index range. The index range for each stream is defined by AudioService. */
     void (*init_stream_volume)(struct audio_policy *pol,
                                audio_stream_type_t stream,
                                int index_min,
                                int index_max);
 
     /* sets the new stream volume at a level corresponding to the supplied
-     * index */
+     * index. The index is within the range specified by init_stream_volume() */
     int (*set_stream_volume_index)(struct audio_policy *pol,
                                    audio_stream_type_t stream,
                                    int index);
 
-    /* retreive current volume index for the specified stream */
+    /* retrieve current volume index for the specified stream */
     int (*get_stream_volume_index)(const struct audio_policy *pol,
                                    audio_stream_type_t stream,
                                    int *index);
 
+    /* sets the new stream volume at a level corresponding to the supplied
+     * index for the specified device.
+     * The index is within the range specified by init_stream_volume() */
+    int (*set_stream_volume_index_for_device)(struct audio_policy *pol,
+                                   audio_stream_type_t stream,
+                                   int index,
+                                   audio_devices_t device);
+
+    /* retrieve current volume index for the specified stream for the specified device */
+    int (*get_stream_volume_index_for_device)(const struct audio_policy *pol,
+                                   audio_stream_type_t stream,
+                                   int *index,
+                                   audio_devices_t device);
+
     /* return the strategy corresponding to a given stream type */
     uint32_t (*get_strategy_for_stream)(const struct audio_policy *pol,
                                         audio_stream_type_t stream);