Loading libs/vr/libdisplay/include/private/dvr/shared_buffer_helpers.h +7 −2 Original line number Diff line number Diff line Loading @@ -103,9 +103,14 @@ class CPUMappedBroadcastRing : public CPUMappedBuffer { // Try obtaining the ring. If the named buffer has not been created yet, it // will return nullptr. RingType* Ring() { // No ring created yet? if (ring_ == nullptr) { // Not mapped the memory yet? if (IsMapped() == false) { TryMapping(); } // If have the memory mapped, allocate the ring. if (IsMapped()) { switch (usage_mode_) { case CPUUsageMode::READ_OFTEN: Loading libs/vr/libvrsensor/pose_client.cpp +20 −7 Original line number Diff line number Diff line Loading @@ -22,6 +22,11 @@ using android::pdx::Transaction; namespace android { namespace dvr { namespace { typedef CPUMappedBroadcastRing<DvrPoseRing> SensorPoseRing; } // namespace // PoseClient is a remote interface to the pose service in sensord. class PoseClient : public pdx::ClientBase<PoseClient> { Loading @@ -36,16 +41,21 @@ class PoseClient : public pdx::ClientBase<PoseClient> { // Polls the pose service for the current state and stores it in *state. // Returns zero on success, a negative error code otherwise. int Poll(DvrPose* state) { const auto vsync_buffer = GetVsyncBuffer(); if (vsync_buffer) { // Allocate the helper class to access the sensor pose buffer. if (sensor_pose_buffer_ == nullptr) { sensor_pose_buffer_ = std::make_unique<SensorPoseRing>( DvrGlobalBuffers::kSensorPoseBuffer, CPUUsageMode::READ_RARELY); } if (state) { // Fill the state *state = vsync_buffer->current_pose; if (sensor_pose_buffer_->GetNewest(state)) { return 0; } else { return -EAGAIN; } return -EINVAL; } return -EAGAIN; return -EINVAL; } int GetPose(uint32_t vsync_count, DvrPoseAsync* out_pose) { Loading Loading @@ -235,6 +245,9 @@ class PoseClient : public pdx::ClientBase<PoseClient> { // The vsync pose buffer if already mapped. std::unique_ptr<CPUMappedBuffer> vsync_pose_buffer_; // The direct sensor pose buffer. std::unique_ptr<SensorPoseRing> sensor_pose_buffer_; const DvrVsyncPoseBuffer* mapped_vsync_pose_buffer_ = nullptr; struct ControllerClientState { Loading Loading
libs/vr/libdisplay/include/private/dvr/shared_buffer_helpers.h +7 −2 Original line number Diff line number Diff line Loading @@ -103,9 +103,14 @@ class CPUMappedBroadcastRing : public CPUMappedBuffer { // Try obtaining the ring. If the named buffer has not been created yet, it // will return nullptr. RingType* Ring() { // No ring created yet? if (ring_ == nullptr) { // Not mapped the memory yet? if (IsMapped() == false) { TryMapping(); } // If have the memory mapped, allocate the ring. if (IsMapped()) { switch (usage_mode_) { case CPUUsageMode::READ_OFTEN: Loading
libs/vr/libvrsensor/pose_client.cpp +20 −7 Original line number Diff line number Diff line Loading @@ -22,6 +22,11 @@ using android::pdx::Transaction; namespace android { namespace dvr { namespace { typedef CPUMappedBroadcastRing<DvrPoseRing> SensorPoseRing; } // namespace // PoseClient is a remote interface to the pose service in sensord. class PoseClient : public pdx::ClientBase<PoseClient> { Loading @@ -36,16 +41,21 @@ class PoseClient : public pdx::ClientBase<PoseClient> { // Polls the pose service for the current state and stores it in *state. // Returns zero on success, a negative error code otherwise. int Poll(DvrPose* state) { const auto vsync_buffer = GetVsyncBuffer(); if (vsync_buffer) { // Allocate the helper class to access the sensor pose buffer. if (sensor_pose_buffer_ == nullptr) { sensor_pose_buffer_ = std::make_unique<SensorPoseRing>( DvrGlobalBuffers::kSensorPoseBuffer, CPUUsageMode::READ_RARELY); } if (state) { // Fill the state *state = vsync_buffer->current_pose; if (sensor_pose_buffer_->GetNewest(state)) { return 0; } else { return -EAGAIN; } return -EINVAL; } return -EAGAIN; return -EINVAL; } int GetPose(uint32_t vsync_count, DvrPoseAsync* out_pose) { Loading Loading @@ -235,6 +245,9 @@ class PoseClient : public pdx::ClientBase<PoseClient> { // The vsync pose buffer if already mapped. std::unique_ptr<CPUMappedBuffer> vsync_pose_buffer_; // The direct sensor pose buffer. std::unique_ptr<SensorPoseRing> sensor_pose_buffer_; const DvrVsyncPoseBuffer* mapped_vsync_pose_buffer_ = nullptr; struct ControllerClientState { Loading