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
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 25c5e7a..ae3dd08 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -3484,7 +3484,7 @@
#ifdef USE_XML_AUDIO_POLICY_CONF
mVolumeCurves(new VolumeCurvesCollection()),
mConfig(mHwModulesAll, mAvailableOutputDevices, mAvailableInputDevices,
- mDefaultOutputDevice, static_cast<VolumeCurvesCollection*>(mVolumeCurves)),
+ mDefaultOutputDevice, static_cast<VolumeCurvesCollection*>(mVolumeCurves.get())),
#else
mVolumeCurves(new StreamDescriptorCollection()),
mConfig(mHwModulesAll, mAvailableOutputDevices, mAvailableInputDevices,