Configurable headset margin time
This commit is contained in:
@@ -18,11 +18,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pacer.h"
|
#include "pacer.h"
|
||||||
|
|
||||||
#include "driver/clock_offset.h"
|
#include "driver/clock_offset.h"
|
||||||
#include "os/os_time.h"
|
|
||||||
|
#include "util/u_var.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
#include "os/os_time.h"
|
||||||
|
#include "util/u_debug.h"
|
||||||
|
|
||||||
|
DEBUG_GET_ONCE_FLOAT_OPTION(client_margin_ms, "WIVRN_CLIENT_MARGIN_MS", 1.f)
|
||||||
|
|
||||||
namespace wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -31,6 +38,12 @@ static const int64_t slop_ns = 500'000;
|
|||||||
|
|
||||||
pacer::pacer(uint64_t frame_duration) :
|
pacer::pacer(uint64_t frame_duration) :
|
||||||
frame_duration_ns(frame_duration),
|
frame_duration_ns(frame_duration),
|
||||||
|
client_margin_ms{
|
||||||
|
.val = debug_get_float_option_client_margin_ms(),
|
||||||
|
.step = 0.1,
|
||||||
|
.min = 0,
|
||||||
|
.max = 20,
|
||||||
|
},
|
||||||
frame_times(5000),
|
frame_times(5000),
|
||||||
frame_times_compute(frame_times),
|
frame_times_compute(frame_times),
|
||||||
worker([this](std::stop_token t) {
|
worker([this](std::stop_token t) {
|
||||||
@@ -53,13 +66,17 @@ pacer::pacer(uint64_t frame_duration) :
|
|||||||
std::ranges::nth_element(samples, it);
|
std::ranges::nth_element(samples, it);
|
||||||
|
|
||||||
std::unique_lock lock(mutex);
|
std::unique_lock lock(mutex);
|
||||||
safe_present_to_decoded_ns = *it + 1'000'000;
|
safe_present_to_decoded_ns = *it + client_margin_ms.val * U_TIME_1MS_IN_NS;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
{}
|
{
|
||||||
|
u_var_add_root(this, "Pacer", false);
|
||||||
|
u_var_add_draggable_f32(this, &client_margin_ms, "headset margin (ms)");
|
||||||
|
}
|
||||||
|
|
||||||
pacer::~pacer()
|
pacer::~pacer()
|
||||||
{
|
{
|
||||||
|
u_var_remove_root(this);
|
||||||
worker.request_stop();
|
worker.request_stop();
|
||||||
compute_cv.notify_all();
|
compute_cv.notify_all();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,11 +23,13 @@
|
|||||||
|
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <main/comp_target.h>
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "main/comp_target.h"
|
||||||
|
#include "util/u_var.h"
|
||||||
|
|
||||||
namespace wivrn
|
namespace wivrn
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -55,6 +57,8 @@ private:
|
|||||||
|
|
||||||
int64_t last_wake_up_ns = 0;
|
int64_t last_wake_up_ns = 0;
|
||||||
|
|
||||||
|
u_var_draggable_f32 client_margin_ms;
|
||||||
|
|
||||||
struct frame_time
|
struct frame_time
|
||||||
{
|
{
|
||||||
int64_t frame_id = -1;
|
int64_t frame_id = -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user