Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_MEDIA_SPATIALIZER_H |
| 18 | #define ANDROID_MEDIA_SPATIALIZER_H |
| 19 | |
| 20 | #include <android/media/BnEffect.h> |
| 21 | #include <android/media/BnSpatializer.h> |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 22 | #include <android/media/SpatializationLevel.h> |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 23 | #include <android/media/SpatializationMode.h> |
| 24 | #include <android/media/SpatializerHeadTrackingMode.h> |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 25 | #include <media/audiohal/EffectHalInterface.h> |
Eric Laurent | 8a4259f | 2021-09-14 16:04:00 +0200 | [diff] [blame] | 26 | #include <media/stagefright/foundation/ALooper.h> |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 27 | #include <media/AudioEffect.h> |
Eric Laurent | 1c5e2e3 | 2021-08-18 18:50:28 +0200 | [diff] [blame] | 28 | #include <system/audio_effects/effect_spatializer.h> |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 29 | |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 30 | #include "SpatializerPoseController.h" |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 31 | |
| 32 | namespace android { |
| 33 | |
| 34 | |
| 35 | // ---------------------------------------------------------------------------- |
| 36 | |
| 37 | /** |
| 38 | * A callback interface from the Spatializer object or its parent AudioPolicyService. |
| 39 | * This is implemented by the audio policy service hosting the Spatializer to perform |
| 40 | * actions needed when a state change inside the Spatializer requires some audio system |
| 41 | * changes that cannot be performed by the Spatializer. For instance opening or closing a |
| 42 | * spatializer output stream when the spatializer is enabled or disabled |
| 43 | */ |
| 44 | class SpatializerPolicyCallback { |
| 45 | public: |
| 46 | /** Called when a stage change occurs that requires the parent audio policy service to take |
| 47 | * some action. |
| 48 | */ |
| 49 | virtual void onCheckSpatializer() = 0; |
| 50 | |
| 51 | virtual ~SpatializerPolicyCallback() = default; |
| 52 | }; |
| 53 | /** |
| 54 | * The Spatializer class implements all functional controlling the multichannel spatializer |
| 55 | * with head tracking implementation in the native audio service: audio policy and audio flinger. |
| 56 | * It presents an AIDL interface available to the java audio service to discover the availability |
| 57 | * of the feature and options, control its state and register an active head tracking sensor. |
| 58 | * It maintains the current state of the platform spatializer and applies the stored parameters |
| 59 | * when the spatializer engine is created and enabled. |
| 60 | * Based on the requested spatializer level, it will request the creation of a specialized output |
| 61 | * mixer to the audio policy service which will in turn notify the Spatializer of the output |
| 62 | * stream on which a spatializer engine should be created, configured and enabled. |
| 63 | * The spatializer also hosts the head tracking management logic. This logic receives the |
| 64 | * desired head tracking mode and selected head tracking sensor, registers a sensor event listener |
| 65 | * and derives the compounded head pose information to the spatializer engine. |
| 66 | * |
| 67 | * Workflow: |
| 68 | * - Initialization: when the audio policy service starts, it checks if a spatializer effect |
| 69 | * engine exists and if the audio policy manager reports a dedicated spatializer output profile. |
| 70 | * If both conditions are met, a Spatializer object is created |
| 71 | * - Capabilities discovery: AudioService will call AudioSystem::canBeSpatialized() and if true, |
| 72 | * acquire an ISpatializer interface with AudioSystem::getSpatializer(). This interface |
| 73 | * will be used to query the implementation capabilities and configure the spatializer. |
| 74 | * - Enabling: when ISpatializer::setLevel() sets a level different from NONE the spatializer |
| 75 | * is considered enabled. The audio policy callback onCheckSpatializer() is called. This |
| 76 | * triggers a request to audio policy manager to open a spatialization output stream and a |
| 77 | * spatializer mixer is created in audio flinger. When an output is returned by audio policy |
| 78 | * manager, Spatializer::attachOutput() is called which creates and enables the spatializer |
| 79 | * stage engine on the specified output. |
| 80 | * - Disabling: when the spatialization level is set to NONE, the spatializer is considered |
| 81 | * disabled. The audio policy callback onCheckSpatializer() is called. This triggers a call |
| 82 | * to Spatializer::detachOutput() and the spatializer engine is released. Then a request is |
| 83 | * made to audio policy manager to release and close the spatializer output stream and the |
| 84 | * spatializer mixer thread is destroyed. |
| 85 | */ |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 86 | class Spatializer : public media::BnSpatializer, |
Atneya Nair | 20e6cc8 | 2022-05-17 20:12:37 -0400 | [diff] [blame^] | 87 | public AudioEffect::IAudioEffectCallback, |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 88 | public IBinder::DeathRecipient, |
| 89 | private SpatializerPoseController::Listener { |
| 90 | public: |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 91 | static sp<Spatializer> create(SpatializerPolicyCallback *callback); |
| 92 | |
| 93 | ~Spatializer() override; |
| 94 | |
Eric Laurent | 8a4259f | 2021-09-14 16:04:00 +0200 | [diff] [blame] | 95 | /** RefBase */ |
| 96 | void onFirstRef(); |
| 97 | |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 98 | /** ISpatializer, see ISpatializer.aidl */ |
| 99 | binder::Status release() override; |
| 100 | binder::Status getSupportedLevels(std::vector<media::SpatializationLevel>* levels) override; |
| 101 | binder::Status setLevel(media::SpatializationLevel level) override; |
| 102 | binder::Status getLevel(media::SpatializationLevel *level) override; |
Eric Laurent | c87402b | 2021-09-17 16:49:42 +0200 | [diff] [blame] | 103 | binder::Status isHeadTrackingSupported(bool *supports); |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 104 | binder::Status getSupportedHeadTrackingModes( |
Ytai Ben-Tsvi | a16a9df | 2021-08-05 08:57:06 -0700 | [diff] [blame] | 105 | std::vector<media::SpatializerHeadTrackingMode>* modes) override; |
| 106 | binder::Status setDesiredHeadTrackingMode( |
| 107 | media::SpatializerHeadTrackingMode mode) override; |
| 108 | binder::Status getActualHeadTrackingMode( |
| 109 | media::SpatializerHeadTrackingMode* mode) override; |
| 110 | binder::Status recenterHeadTracker() override; |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 111 | binder::Status setGlobalTransform(const std::vector<float>& screenToStage) override; |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 112 | binder::Status setHeadSensor(int sensorHandle) override; |
| 113 | binder::Status setScreenSensor(int sensorHandle) override; |
| 114 | binder::Status setDisplayOrientation(float physicalToLogicalAngle) override; |
| 115 | binder::Status setHingeAngle(float hingeAngle) override; |
| 116 | binder::Status getSupportedModes(std::vector<media::SpatializationMode>* modes) override; |
Eric Laurent | 67816e3 | 2021-09-16 15:18:40 +0200 | [diff] [blame] | 117 | binder::Status registerHeadTrackingCallback( |
| 118 | const sp<media::ISpatializerHeadTrackingCallback>& callback) override; |
Eric Laurent | c87402b | 2021-09-17 16:49:42 +0200 | [diff] [blame] | 119 | binder::Status setParameter(int key, const std::vector<unsigned char>& value) override; |
| 120 | binder::Status getParameter(int key, std::vector<unsigned char> *value) override; |
| 121 | binder::Status getOutput(int *output); |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 122 | |
| 123 | /** IBinder::DeathRecipient. Listen to the death of the INativeSpatializerCallback. */ |
| 124 | virtual void binderDied(const wp<IBinder>& who); |
| 125 | |
| 126 | /** Registers a INativeSpatializerCallback when a client is attached to this Spatializer |
| 127 | * by audio policy service. |
| 128 | */ |
| 129 | status_t registerCallback(const sp<media::INativeSpatializerCallback>& callback); |
| 130 | |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 131 | status_t loadEngineConfiguration(sp<EffectHalInterface> effect); |
| 132 | |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 133 | /** Level getter for use by local classes. */ |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 134 | media::SpatializationLevel getLevel() const { std::lock_guard lock(mLock); return mLevel; } |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 135 | |
| 136 | /** Called by audio policy service when the special output mixer dedicated to spatialization |
| 137 | * is opened and the spatializer engine must be created. |
| 138 | */ |
Eric Laurent | 1590359 | 2022-02-24 20:44:36 +0100 | [diff] [blame] | 139 | status_t attachOutput(audio_io_handle_t output, size_t numActiveTracks); |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 140 | /** Called by audio policy service when the special output mixer dedicated to spatialization |
| 141 | * is closed and the spatializer engine must be release. |
| 142 | */ |
| 143 | audio_io_handle_t detachOutput(); |
| 144 | /** Returns the output stream the spatializer is attached to. */ |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 145 | audio_io_handle_t getOutput() const { std::lock_guard lock(mLock); return mOutput; } |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 146 | |
Eric Laurent | 1590359 | 2022-02-24 20:44:36 +0100 | [diff] [blame] | 147 | void updateActiveTracks(size_t numActiveTracks); |
| 148 | |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 149 | /** Gets the channel mask, sampling rate and format set for the spatializer input. */ |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 150 | audio_config_base_t getAudioInConfig() const; |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 151 | |
Eric Laurent | 8a4259f | 2021-09-14 16:04:00 +0200 | [diff] [blame] | 152 | void calculateHeadPose(); |
| 153 | |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 154 | private: |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 155 | Spatializer(effect_descriptor_t engineDescriptor, |
| 156 | SpatializerPolicyCallback *callback); |
| 157 | |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 158 | static void engineCallback(int32_t event, void* user, void *info); |
| 159 | |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 160 | // From VirtualizerStageController::Listener |
| 161 | void onHeadToStagePose(const media::Pose3f& headToStage) override; |
| 162 | void onActualModeChange(media::HeadTrackingMode mode) override; |
| 163 | |
Eric Laurent | 8a4259f | 2021-09-14 16:04:00 +0200 | [diff] [blame] | 164 | void onHeadToStagePoseMsg(const std::vector<float>& headToStage); |
| 165 | void onActualModeChangeMsg(media::HeadTrackingMode mode); |
| 166 | |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 167 | static constexpr int kMaxEffectParamValues = 10; |
| 168 | /** |
| 169 | * Get a parameter from spatializer engine by calling the effect HAL command method directly. |
| 170 | * To be used when the engine instance mEngine is not yet created in the effect framework. |
| 171 | * When MULTI_VALUES is false, the expected reply is only one value of type T. |
| 172 | * When MULTI_VALUES is true, the expected reply is made of a number (of type T) indicating |
| 173 | * how many values are returned, followed by this number for values of type T. |
| 174 | */ |
| 175 | template<bool MULTI_VALUES, typename T> |
| 176 | status_t getHalParameter(sp<EffectHalInterface> effect, uint32_t type, |
| 177 | std::vector<T> *values) { |
| 178 | static_assert(sizeof(T) <= sizeof(uint32_t), "The size of T must less than 32 bits"); |
| 179 | |
| 180 | uint32_t cmd[sizeof(effect_param_t) / sizeof(uint32_t) + 1]; |
| 181 | uint32_t reply[sizeof(effect_param_t) / sizeof(uint32_t) + 2 + kMaxEffectParamValues]; |
| 182 | |
| 183 | effect_param_t *p = (effect_param_t *)cmd; |
| 184 | p->psize = sizeof(uint32_t); |
| 185 | if (MULTI_VALUES) { |
| 186 | p->vsize = (kMaxEffectParamValues + 1) * sizeof(T); |
| 187 | } else { |
| 188 | p->vsize = sizeof(T); |
| 189 | } |
| 190 | *(uint32_t *)p->data = type; |
| 191 | uint32_t replySize = sizeof(effect_param_t) + p->psize + p->vsize; |
| 192 | |
| 193 | status_t status = effect->command(EFFECT_CMD_GET_PARAM, |
| 194 | sizeof(effect_param_t) + sizeof(uint32_t), cmd, |
| 195 | &replySize, reply); |
| 196 | if (status != NO_ERROR) { |
| 197 | return status; |
| 198 | } |
| 199 | if (p->status != NO_ERROR) { |
| 200 | return p->status; |
| 201 | } |
| 202 | if (replySize < |
| 203 | sizeof(effect_param_t) + sizeof(uint32_t) + (MULTI_VALUES ? 2 : 1) * sizeof(T)) { |
| 204 | return BAD_VALUE; |
| 205 | } |
| 206 | |
| 207 | T *params = (T *)((uint8_t *)reply + sizeof(effect_param_t) + sizeof(uint32_t)); |
| 208 | int numParams = 1; |
| 209 | if (MULTI_VALUES) { |
| 210 | numParams = (int)*params++; |
| 211 | } |
| 212 | if (numParams > kMaxEffectParamValues) { |
| 213 | return BAD_VALUE; |
| 214 | } |
Eric Laurent | c87402b | 2021-09-17 16:49:42 +0200 | [diff] [blame] | 215 | (*values).clear(); |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 216 | std::copy(¶ms[0], ¶ms[numParams], back_inserter(*values)); |
| 217 | return NO_ERROR; |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * Set a parameter to spatializer engine by calling setParameter on mEngine AudioEffect object. |
| 222 | * It is possible to pass more than one value of type T according to the parameter type |
| 223 | * according to values vector size. |
| 224 | */ |
| 225 | template<typename T> |
| 226 | status_t setEffectParameter_l(uint32_t type, const std::vector<T>& values) REQUIRES(mLock) { |
| 227 | static_assert(sizeof(T) <= sizeof(uint32_t), "The size of T must less than 32 bits"); |
| 228 | |
| 229 | uint32_t cmd[sizeof(effect_param_t) / sizeof(uint32_t) + 1 + values.size()]; |
| 230 | effect_param_t *p = (effect_param_t *)cmd; |
| 231 | p->psize = sizeof(uint32_t); |
| 232 | p->vsize = sizeof(T) * values.size(); |
| 233 | *(uint32_t *)p->data = type; |
| 234 | memcpy((uint32_t *)p->data + 1, values.data(), sizeof(T) * values.size()); |
| 235 | |
Eric Laurent | c87402b | 2021-09-17 16:49:42 +0200 | [diff] [blame] | 236 | status_t status = mEngine->setParameter(p); |
| 237 | if (status != NO_ERROR) { |
| 238 | return status; |
| 239 | } |
| 240 | if (p->status != NO_ERROR) { |
| 241 | return p->status; |
| 242 | } |
| 243 | return NO_ERROR; |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Get a parameter from spatializer engine by calling getParameter on AudioEffect object. |
| 248 | * It is possible to read more than one value of type T according to the parameter type |
| 249 | * by specifying values vector size. |
| 250 | */ |
| 251 | template<typename T> |
| 252 | status_t getEffectParameter_l(uint32_t type, std::vector<T> *values) REQUIRES(mLock) { |
| 253 | static_assert(sizeof(T) <= sizeof(uint32_t), "The size of T must less than 32 bits"); |
| 254 | |
| 255 | uint32_t cmd[sizeof(effect_param_t) / sizeof(uint32_t) + 1 + values->size()]; |
| 256 | effect_param_t *p = (effect_param_t *)cmd; |
| 257 | p->psize = sizeof(uint32_t); |
| 258 | p->vsize = sizeof(T) * values->size(); |
| 259 | *(uint32_t *)p->data = type; |
| 260 | |
| 261 | status_t status = mEngine->getParameter(p); |
| 262 | |
| 263 | if (status != NO_ERROR) { |
| 264 | return status; |
| 265 | } |
| 266 | if (p->status != NO_ERROR) { |
| 267 | return p->status; |
| 268 | } |
| 269 | |
| 270 | int numValues = std::min(p->vsize / sizeof(T), values->size()); |
| 271 | (*values).clear(); |
| 272 | T *retValues = (T *)((uint8_t *)p->data + sizeof(uint32_t)); |
| 273 | std::copy(&retValues[0], &retValues[numValues], back_inserter(*values)); |
| 274 | |
| 275 | return NO_ERROR; |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 276 | } |
| 277 | |
Atneya Nair | 20e6cc8 | 2022-05-17 20:12:37 -0400 | [diff] [blame^] | 278 | virtual void onFramesProcessed(int32_t framesProcessed) override; |
Eric Laurent | 8a4259f | 2021-09-14 16:04:00 +0200 | [diff] [blame] | 279 | |
Eric Laurent | 9249d34 | 2022-03-18 11:55:56 +0100 | [diff] [blame] | 280 | /** |
| 281 | * Checks if head and screen sensors must be actively monitored based on |
| 282 | * spatializer state and playback activity and configures the pose controller |
| 283 | * accordingly. |
| 284 | */ |
| 285 | void checkSensorsState_l() REQUIRES(mLock); |
Eric Laurent | 1590359 | 2022-02-24 20:44:36 +0100 | [diff] [blame] | 286 | |
Eric Laurent | 7ea0d1b | 2022-04-01 14:23:44 +0200 | [diff] [blame] | 287 | /** |
Eric Laurent | 1109417 | 2022-04-05 18:27:42 +0200 | [diff] [blame] | 288 | * Checks if the head pose controller should be created or destroyed according |
| 289 | * to desired head tracking mode. |
| 290 | */ |
| 291 | void checkPoseController_l() REQUIRES(mLock); |
| 292 | |
| 293 | /** |
Eric Laurent | 7ea0d1b | 2022-04-01 14:23:44 +0200 | [diff] [blame] | 294 | * Checks if the spatializer effect should be enabled based on |
| 295 | * playback activity and requested level. |
| 296 | */ |
| 297 | void checkEngineState_l() REQUIRES(mLock); |
| 298 | |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 299 | /** Effect engine descriptor */ |
| 300 | const effect_descriptor_t mEngineDescriptor; |
| 301 | /** Callback interface to parent audio policy service */ |
| 302 | SpatializerPolicyCallback* mPolicyCallback; |
| 303 | |
| 304 | /** Mutex protecting internal state */ |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 305 | mutable std::mutex mLock; |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 306 | |
| 307 | /** Client AudioEffect for the engine */ |
| 308 | sp<AudioEffect> mEngine GUARDED_BY(mLock); |
| 309 | /** Output stream the spatializer mixer thread is attached to */ |
| 310 | audio_io_handle_t mOutput GUARDED_BY(mLock) = AUDIO_IO_HANDLE_NONE; |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 311 | |
| 312 | /** Callback interface to the client (AudioService) controlling this`Spatializer */ |
| 313 | sp<media::INativeSpatializerCallback> mSpatializerCallback GUARDED_BY(mLock); |
| 314 | |
Eric Laurent | 67816e3 | 2021-09-16 15:18:40 +0200 | [diff] [blame] | 315 | /** Callback interface for head tracking */ |
| 316 | sp<media::ISpatializerHeadTrackingCallback> mHeadTrackingCallback GUARDED_BY(mLock); |
| 317 | |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 318 | /** Requested spatialization level */ |
| 319 | media::SpatializationLevel mLevel GUARDED_BY(mLock) = media::SpatializationLevel::NONE; |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 320 | |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 321 | /** Control logic for head-tracking, etc. */ |
| 322 | std::shared_ptr<SpatializerPoseController> mPoseController GUARDED_BY(mLock); |
| 323 | |
| 324 | /** Last requested head tracking mode */ |
| 325 | media::HeadTrackingMode mDesiredHeadTrackingMode GUARDED_BY(mLock) |
| 326 | = media::HeadTrackingMode::STATIC; |
| 327 | |
| 328 | /** Last-reported actual head-tracking mode. */ |
| 329 | media::SpatializerHeadTrackingMode mActualHeadTrackingMode GUARDED_BY(mLock) |
| 330 | = media::SpatializerHeadTrackingMode::DISABLED; |
| 331 | |
| 332 | /** Selected Head pose sensor */ |
Ytai Ben-Tsvi | 9f12f17 | 2021-09-23 16:47:25 -0700 | [diff] [blame] | 333 | int32_t mHeadSensor GUARDED_BY(mLock) = SpatializerPoseController::INVALID_SENSOR; |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 334 | |
| 335 | /** Selected Screen pose sensor */ |
Ytai Ben-Tsvi | 9f12f17 | 2021-09-23 16:47:25 -0700 | [diff] [blame] | 336 | int32_t mScreenSensor GUARDED_BY(mLock) = SpatializerPoseController::INVALID_SENSOR; |
Eric Laurent | 2be8b29 | 2021-08-23 09:44:33 -0700 | [diff] [blame] | 337 | |
| 338 | /** Last display orientation received */ |
| 339 | static constexpr float kDisplayOrientationInvalid = 1000; |
| 340 | float mDisplayOrientation GUARDED_BY(mLock) = kDisplayOrientationInvalid; |
| 341 | |
| 342 | std::vector<media::SpatializationLevel> mLevels; |
| 343 | std::vector<media::SpatializationMode> mSpatializationModes; |
| 344 | std::vector<audio_channel_mask_t> mChannelMasks; |
| 345 | bool mSupportsHeadTracking; |
Eric Laurent | 8a4259f | 2021-09-14 16:04:00 +0200 | [diff] [blame] | 346 | |
| 347 | // Looper thread for mEngine callbacks |
| 348 | class EngineCallbackHandler; |
| 349 | |
| 350 | sp<ALooper> mLooper; |
| 351 | sp<EngineCallbackHandler> mHandler; |
| 352 | |
Eric Laurent | 1590359 | 2022-02-24 20:44:36 +0100 | [diff] [blame] | 353 | size_t mNumActiveTracks GUARDED_BY(mLock) = 0; |
| 354 | |
Eric Laurent | 8a4259f | 2021-09-14 16:04:00 +0200 | [diff] [blame] | 355 | static const std::vector<const char *> sHeadPoseKeys; |
Eric Laurent | 6d60701 | 2021-07-05 11:54:40 +0200 | [diff] [blame] | 356 | }; |
| 357 | |
| 358 | |
| 359 | }; // namespace android |
| 360 | |
| 361 | #endif // ANDROID_MEDIA_SPATIALIZER_H |