Fix issue 2045911: Camera Shutter tone does not play correctly while listening to music.

The problem is partly due to the fact that if music is playing in the headset, a routing change is done to play the shutter sound in both headset+speaker. When the shutter sound ends, the routing is reset to headset, but the change is immediate and there is still audio data pertaining to the shutter sound in the audio hardware buffer queue. As the shutter sound is short, sometimes none of it is output to the speaker before the audio path is reset to the headset.
Another factor is the long time taken by the audio hardware to execute some routing or volume change commands (especially in call volume). Current AudioPolicyManager design reapplies all stream volumes when the output device is changed which adds an unecessary delay in the routing command execution.
Another side problem is that althoough the music is muted while the shutter sound is played, the audio latency makes that some music is heard briefly before the shutter sound in the speaker.
In addition a regression in change 21083 broke the mute mechanism.

This fix consists in:
1 Delay the routing change when the shutter sound stops by a duration longer than the audio output latency.
2 Do not send unecessary volume changes by comparing current value with requested value.
3 Wait until the music is muted before proceding with the reset of the audio routing change when starting the shutter sound.
4 fix mute regression
2 files changed