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
2 files changed