audiopolicy: Add more tests, fix issues found

Added tests that ensure correct initialization of APM.

Fixed issues:

  -- UB in VolumeCurvesForStream::volIndexToDb due to not
     checking that the pointer is non-null;

  -- AudioInputDescriptor::open and SwAudioOutputDescriptor::open
     were not checking that the returned IO handle is valid,
     this was causing an infinite loop in
     AudioPolicyManager::selectOutputForMusicEffects, added an
     assertion.

  -- Memory leak of VolumeCurves collection in APM.

Test: audiopolicy_tests
Change-Id: Ia4ecca1dd03b74d7f93720f042da05d5a0c74a6b
8 files changed