audio policy: create spatializer mixer only when needed

Only open a spatializer output when spatial audio is enabled
in order to save memory resources consumed by the dedicated mixer and
audio effect when instantiated.

For the special case where the spatializer output is the only route
available to a specific device, leave it open. This can happen when the
software necoder path is used for Bluetooth A2DP.

Bug: 227740874
Test: make and music playback with and without spatial audio

Change-Id: Id149d0ce000c939c7f45e63b47f2fd1d7a98995a
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index 715ee6d..0d9b5bf 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -1097,6 +1097,16 @@
         void checkVirtualizerClientRoutes();
 
         /**
+         * @brief Returns true if at least one device can only be reached via the output passed
+         * as argument. Always returns false for duplicated outputs.
+         * This can be used to decide if an output can be closed without forbidding
+         * playback to any given device.
+         * @param outputDesc the output to consider
+         * @return true if at least one device can only be reached via the output.
+         */
+        bool isOutputOnlyAvailableRouteToSomeDevice(const sp<SwAudioOutputDescriptor>& outputDesc);
+
+        /**
          * @brief getInputForDevice selects an input handle for a given input device and
          * requester context
          * @param device to be used by requester, selected by policy mix rules or engine