1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef AUDIO_HEAD_TRACKER_H 17 #define AUDIO_HEAD_TRACKER_H 18 19 #include <cstdint> 20 #include <mutex> 21 22 #ifdef SENSOR_ENABLE 23 #include "sensor_agent.h" 24 #endif 25 26 namespace OHOS { 27 namespace AudioStandard { 28 29 #ifdef SENSOR_ENABLE 30 const uint32_t NONE_SPATIALIZER_ENGINE = 0; 31 const uint32_t ARM_SPATIALIZER_ENGINE = 1; 32 const uint32_t DSP_SPATIALIZER_ENGINE = 2; 33 34 class HeadTracker { 35 public: 36 HeadTracker(); 37 ~HeadTracker(); 38 int32_t SensorInit(); 39 int32_t SensorSetConfig(int32_t spatializerEngineState); 40 int32_t SensorActive(); 41 int32_t SensorDeactive(); 42 int32_t SensorUnsubscribe(); 43 HeadPostureData GetHeadPostureData(); 44 void SetHeadPostureData(HeadPostureData headPostureData); 45 private: 46 static void HeadPostureDataProcCb(SensorEvent *event); 47 static HeadPostureData headPostureData_; 48 SensorUser sensorUser_ = {}; 49 int64_t sensorSamplingInterval_ = 30000000; // 30000000 ns = 30 ms 50 static std::mutex headTrackerMutex_; 51 }; 52 #endif 53 } // namespace AudioStandard 54 } // namespace OHOS 55 #endif // AUDIO_HEAD_TRACKER_H 56