Skip to content

Commit

Permalink
added mutex locks around lastRenderInfo read/writes.
Browse files Browse the repository at this point in the history
  • Loading branch information
DuFF14 committed Feb 20, 2017
1 parent 126519a commit aa1ead0
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions OsvrRenderingPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,13 @@ void UNITY_INTERFACE_API UnityPluginUnload() {
}

inline void UpdateRenderInfo() {
std::lock_guard<std::mutex> lock(m_mutex);
s_renderInfo = s_render->GetRenderInfo(s_renderParams);
m_mutex.lock();
s_renderInfo = s_render->GetRenderInfo(s_renderParams);
if (s_renderInfo.size() > 0)
{
s_lastRenderInfo = s_renderInfo;
}
m_mutex.unlock();
}

#if 0
Expand Down Expand Up @@ -687,19 +688,25 @@ void UNITY_INTERFACE_API SetIPD(double ipdMeters) {

osvr::renderkit::OSVR_ViewportDescription UNITY_INTERFACE_API
GetViewport(int eye) {
std::lock_guard<std::mutex> lock(m_mutex);
return s_lastRenderInfo[eye].viewport;
m_mutex.lock();
osvr::renderkit::OSVR_ViewportDescription viewport = s_lastRenderInfo[eye].viewport;
m_mutex.unlock();
return viewport;
}

osvr::renderkit::OSVR_ProjectionMatrix UNITY_INTERFACE_API
GetProjectionMatrix(int eye) {
std::lock_guard<std::mutex> lock(m_mutex);
return s_lastRenderInfo[eye].projection;
m_mutex.lock();
osvr::renderkit::OSVR_ProjectionMatrix proj = s_lastRenderInfo[eye].projection;
m_mutex.unlock();
return proj;
}

OSVR_Pose3 UNITY_INTERFACE_API GetEyePose(int eye) {
std::lock_guard<std::mutex> lock(m_mutex);
return s_lastRenderInfo[eye].pose;
m_mutex.lock();
OSVR_PoseState pose = s_lastRenderInfo[eye].pose;
m_mutex.unlock();
return pose;
}

// --------------------------------------------------------------------------
Expand Down

0 comments on commit aa1ead0

Please sign in to comment.