Skip to content

Commit 847a147

Browse files
RipleyTomelad335
authored andcommitted
Improve usb timing accuracy
1 parent df6a3d0 commit 847a147

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

rpcs3/Emu/Cell/lv2/sys_usbd.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,8 @@ void usb_handler_thread::operator()()
636636
// Process asynchronous requests that are pending
637637
libusb_handle_events_timeout_completed(ctx, &lusb_tv, nullptr);
638638

639+
u64 delay = 1'000;
640+
639641
// Process fake transfers
640642
if (!fake_transfers.empty())
641643
{
@@ -650,6 +652,13 @@ void usb_handler_thread::operator()()
650652

651653
if (transfer->expected_time > timestamp)
652654
{
655+
const u64 diff_time = transfer->expected_time - timestamp;
656+
657+
if (diff_time < delay)
658+
{
659+
delay = diff_time;
660+
}
661+
653662
++it;
654663
continue;
655664
}
@@ -668,7 +677,7 @@ void usb_handler_thread::operator()()
668677
if (handled_devices.empty())
669678
thread_ctrl::wait_for(500'000);
670679
else
671-
thread_ctrl::wait_for(1'000);
680+
thread_ctrl::wait_for(delay);
672681
}
673682
}
674683

0 commit comments

Comments
 (0)