OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LowLatency.cpp
Go to the documentation of this file.
1 
11 // Copyright 2016 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 // Internal Includes
26 #include <osvr/Common/LowLatency.h>
27 
28 #ifdef _WIN32
29 #define NO_MINMAX
30 #include <windows.h>
31 #endif
32 
33 namespace osvr {
34 namespace common {
35 
36 #ifdef _WIN32
37 #define OSVR_HAVE_LOWLATENCY_CODE
38  static const UINT TIMER_PERIOD = 1;
40  struct LowLatency::Impl {
41  bool beginSucceeded = false;
42  };
43 
47 #if 0
48  LowLatency::LowLatency() : m_impl(new Impl) {
49  auto result = timeBeginPeriod(TIMER_PERIOD);
50  if (TIMERR_NOERROR == result) {
51  m_impl->beginSucceeded = true;
52  }
53  }
54 #endif
55 
56  LowLatency::LowLatency() { timeBeginPeriod(TIMER_PERIOD); }
57  LowLatency::~LowLatency() {
60  timeEndPeriod(TIMER_PERIOD);
61  }
62 #endif
63 
64 #ifndef OSVR_HAVE_LOWLATENCY_CODE
65  // Fallback no-op implementations
66  struct LowLatency::Impl {};
67  LowLatency::LowLatency() {}
68  LowLatency::~LowLatency() {}
69 #endif
70 
71 } // namespace common
72 } // namespace osvr
Header for an RAII object defining platform-specific actions to take to enter/exit a "low-latency" sy...