audio policy: fix volume burst on user switch.
Fix two main problems in setStreamVolumeIndex():
1) the conventional initialization or user switch behavior consisting in first
applying volume for AUDIO_DEVICE_OUT_DEFAULT device which resets all volumes
and then apply device specific volumes is problematic: if this is done while
a stream is active, it will temporarily reset the volume to its default
(usually loud) and then back causing an audible glitch.
2) The logic consisting in applying the requested volume to all outputs with a
device selected by the routing strategy corresponding to the requested stream
is problematic: it will cause device specific volumes for other devices than
current one to be applied to active streams.
Restrict the logic to cases of multiple device selections including the
requested device.
Bug: 27557733
Change-Id: Ia14cd51766a7516c42221abff76843d47699105f
4 files changed