libaudiohal: fix device connection issues.
1. Use the requested config to create port config instead of default
config when there is not an active one. The reason is that the HAL,
such as AOSP USB HAL, may require exactly match on the
configuration when creating patch. The default one may be different
from the requested one.
2. Reset all unused patches and configs when calling prepareToOpenStream.
The reason is that the stream may be closed without resetting patch
and config. Leaving the unused patches and configs may result in
unable to create new config and patch.
3. When resetting unused port configs, do not reset the initial configs.
The initial configs work as template config. They should be always
cached by libaudiohal.
4. Make bit-prefect output flag as an optional flag. When requesting
without bit-perfect output flag, it should be able to use the mix
port that has bit-prefect output flag if all other requested flags
are matched.
Bug: 277955540
Test: make, manully
(cherry picked from https://android-review.googlesource.com/q/commit:28de9b6ead040310c46af53405522e7f5c097cec)
Merged-In: I043d69022d05e154b273492e0729eb45ffa8efad
Change-Id: I043d69022d05e154b273492e0729eb45ffa8efad
diff --git a/media/libaudiohal/impl/DeviceHalAidl.h b/media/libaudiohal/impl/DeviceHalAidl.h
index e4d5ec6..a336043 100644
--- a/media/libaudiohal/impl/DeviceHalAidl.h
+++ b/media/libaudiohal/impl/DeviceHalAidl.h
@@ -215,6 +215,7 @@
::aidl::android::hardware::audio::core::AudioPatch* patch, bool* created);
status_t findOrCreatePortConfig(
const ::aidl::android::media::audio::common::AudioDevice& device,
+ const ::aidl::android::media::audio::common::AudioConfig* config,
::aidl::android::media::audio::common::AudioPortConfig* portConfig,
bool* created);
status_t findOrCreatePortConfig(
@@ -284,6 +285,7 @@
int32_t mDefaultInputPortId = -1;
int32_t mDefaultOutputPortId = -1;
PortConfigs mPortConfigs;
+ std::set<int32_t> mInitialPortConfigIds;
Patches mPatches;
RoutingMatrix mRoutingMatrix;
Streams mStreams;