Do not hold the lock while invoking callbacks

Holding the lock creates a burden on the client, so easier to handle
here.

Test: Manual verification using logs.
Bug: 188502620
Change-Id: I1b3a417315bd05bd421b8d643fd15f832faace02
diff --git a/services/audiopolicy/service/SpatializerPoseController.h b/services/audiopolicy/service/SpatializerPoseController.h
index 619dc7b..fcb7a46 100644
--- a/services/audiopolicy/service/SpatializerPoseController.h
+++ b/services/audiopolicy/service/SpatializerPoseController.h
@@ -38,15 +38,13 @@
  * - By setting a timeout in the ctor, a calculation will be triggered after the timeout elapsed
  *   from the last calculateAsync() call.
  *
- * This class is thread-safe. Callbacks are invoked with the lock held, so it is illegal to call
- * into this module from the callbacks.
+ * This class is thread-safe.
  */
 class SpatializerPoseController : private media::SensorPoseProvider::Listener {
   public:
     /**
      * Listener interface for getting pose and mode updates.
-     * Methods will always be invoked from a designated thread. Calling into the parent class from
-     * within the callbacks is disallowed (will result in a deadlock).
+     * Methods will always be invoked from a designated thread.
      */
     class Listener {
       public:
@@ -109,7 +107,7 @@
 
     /**
      * Blocks until calculation and invocation of the respective callbacks has happened at least
-     * once.
+     * once. Do not call from within callbacks.
      */
     void waitUntilCalculated();
 
@@ -131,7 +129,11 @@
     void onPose(int64_t timestamp, int32_t sensor, const media::Pose3f& pose,
                 const std::optional<media::Twist3f>& twist) override;
 
-    void calculate_l();
+    /**
+     * Calculates the new outputs and updates internal state. Must be called with the lock held.
+     * Returns values that should be passed to the respective callbacks.
+     */
+    std::tuple<media::Pose3f, std::optional<media::HeadTrackingMode>> calculate_l();
 };
 
 }  // namespace android