Improve usb timing accuracy
This commit is contained in:
@@ -636,6 +636,8 @@ void usb_handler_thread::operator()()
|
|||||||
// Process asynchronous requests that are pending
|
// Process asynchronous requests that are pending
|
||||||
libusb_handle_events_timeout_completed(ctx, &lusb_tv, nullptr);
|
libusb_handle_events_timeout_completed(ctx, &lusb_tv, nullptr);
|
||||||
|
|
||||||
|
u64 delay = 1'000;
|
||||||
|
|
||||||
// Process fake transfers
|
// Process fake transfers
|
||||||
if (!fake_transfers.empty())
|
if (!fake_transfers.empty())
|
||||||
{
|
{
|
||||||
@@ -650,6 +652,13 @@ void usb_handler_thread::operator()()
|
|||||||
|
|
||||||
if (transfer->expected_time > timestamp)
|
if (transfer->expected_time > timestamp)
|
||||||
{
|
{
|
||||||
|
const u64 diff_time = transfer->expected_time - timestamp;
|
||||||
|
|
||||||
|
if (diff_time < delay)
|
||||||
|
{
|
||||||
|
delay = diff_time;
|
||||||
|
}
|
||||||
|
|
||||||
++it;
|
++it;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -668,7 +677,7 @@ void usb_handler_thread::operator()()
|
|||||||
if (handled_devices.empty())
|
if (handled_devices.empty())
|
||||||
thread_ctrl::wait_for(500'000);
|
thread_ctrl::wait_for(500'000);
|
||||||
else
|
else
|
||||||
thread_ctrl::wait_for(1'000);
|
thread_ctrl::wait_for(delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user