audio spatializer: more resource usage optimizations
Enable the spatializer effect, only when active AND spatialized tracks
are present on the spatializer mixer.
This is useful for the case where only one output mixer is available to
reach a particular device (e.g. A2DP) and this mixer is a spatializer
mixer. In this case, non spatialized tracks are the majority of the activity
on this mixer.
Also only create the head pose controller when the desired head tracking
mode is not static and there is a head pose sensor registered. The max
calculation interval is also changed so that no calculation happens
unless explicitely requested by the spatializer.
Bug: 227740874
Test: regular and spatial audio playback on a Bluetooth headphone with
LDAC codec.
Change-Id: Ib3197da54f47fca63f0e4a6c95546b56a7065b6f
diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h
index 119ac62..d863ff1 100644
--- a/services/audiopolicy/service/AudioPolicyService.h
+++ b/services/audiopolicy/service/AudioPolicyService.h
@@ -1008,7 +1008,16 @@
void loadAudioPolicyManager();
void unloadAudioPolicyManager();
- size_t countActiveClientsOnOutput_l(audio_io_handle_t output) REQUIRES(mLock);
+ /**
+ * Returns the number of active audio tracks on the specified output mixer.
+ * The query can be specified to only include spatialized audio tracks or consider
+ * all tracks.
+ * @param output the I/O handle of the output mixer to consider
+ * @param spatializedOnly true if only spatialized tracks should be considered
+ * @return the number of active tracks.
+ */
+ size_t countActiveClientsOnOutput_l(
+ audio_io_handle_t output, bool spatializedOnly = true) REQUIRES(mLock);
mutable Mutex mLock; // prevents concurrent access to AudioPolicy manager functions changing
// device connection state or routing