mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
core/core_timing: Make callback parameters consistent
In some cases, our callbacks were using s64 as a parameter, and in other cases, they were using an int, which is inconsistent. To make all callbacks consistent, we can just use an s64 as the type for late cycles, given it gets rid of the need to cast internally. While we're at it, also resolve some signed/unsigned conversions that were occurring related to the callback registration.
This commit is contained in:
parent
3f74518e19
commit
c5d41fd812
|
@ -38,7 +38,7 @@ Stream::Stream(Core::Timing::CoreTiming& core_timing, u32 sample_rate, Format fo
|
||||||
sink_stream{sink_stream}, core_timing{core_timing}, name{std::move(name_)} {
|
sink_stream{sink_stream}, core_timing{core_timing}, name{std::move(name_)} {
|
||||||
|
|
||||||
release_event = core_timing.RegisterEvent(
|
release_event = core_timing.RegisterEvent(
|
||||||
name, [this](u64 userdata, int cycles_late) { ReleaseActiveBuffer(); });
|
name, [this](u64 userdata, s64 cycles_late) { ReleaseActiveBuffer(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stream::Play() {
|
void Stream::Play() {
|
||||||
|
|
|
@ -186,7 +186,7 @@ void CoreTiming::Advance() {
|
||||||
Event evt = std::move(event_queue.front());
|
Event evt = std::move(event_queue.front());
|
||||||
std::pop_heap(event_queue.begin(), event_queue.end(), std::greater<>());
|
std::pop_heap(event_queue.begin(), event_queue.end(), std::greater<>());
|
||||||
event_queue.pop_back();
|
event_queue.pop_back();
|
||||||
evt.type->callback(evt.userdata, static_cast<int>(global_timer - evt.time));
|
evt.type->callback(evt.userdata, global_timer - evt.time);
|
||||||
}
|
}
|
||||||
|
|
||||||
is_global_timer_sane = false;
|
is_global_timer_sane = false;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
namespace Core::Timing {
|
namespace Core::Timing {
|
||||||
|
|
||||||
/// A callback that may be scheduled for a particular core timing event.
|
/// A callback that may be scheduled for a particular core timing event.
|
||||||
using TimedCallback = std::function<void(u64 userdata, int cycles_late)>;
|
using TimedCallback = std::function<void(u64 userdata, s64 cycles_late)>;
|
||||||
|
|
||||||
/// Contains the characteristics of a particular event.
|
/// Contains the characteristics of a particular event.
|
||||||
struct EventType {
|
struct EventType {
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace Kernel {
|
||||||
* @param thread_handle The handle of the thread that's been awoken
|
* @param thread_handle The handle of the thread that's been awoken
|
||||||
* @param cycles_late The number of CPU cycles that have passed since the desired wakeup time
|
* @param cycles_late The number of CPU cycles that have passed since the desired wakeup time
|
||||||
*/
|
*/
|
||||||
static void ThreadWakeupCallback(u64 thread_handle, [[maybe_unused]] int cycles_late) {
|
static void ThreadWakeupCallback(u64 thread_handle, [[maybe_unused]] s64 cycles_late) {
|
||||||
const auto proper_handle = static_cast<Handle>(thread_handle);
|
const auto proper_handle = static_cast<Handle>(thread_handle);
|
||||||
const auto& system = Core::System::GetInstance();
|
const auto& system = Core::System::GetInstance();
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,9 @@ namespace Service::HID {
|
||||||
|
|
||||||
// Updating period for each HID device.
|
// Updating period for each HID device.
|
||||||
// TODO(ogniK): Find actual polling rate of hid
|
// TODO(ogniK): Find actual polling rate of hid
|
||||||
constexpr u64 pad_update_ticks = Core::Timing::BASE_CLOCK_RATE / 66;
|
constexpr s64 pad_update_ticks = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 66);
|
||||||
constexpr u64 accelerometer_update_ticks = Core::Timing::BASE_CLOCK_RATE / 100;
|
constexpr s64 accelerometer_update_ticks = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 100);
|
||||||
constexpr u64 gyroscope_update_ticks = Core::Timing::BASE_CLOCK_RATE / 100;
|
constexpr s64 gyroscope_update_ticks = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / 100);
|
||||||
constexpr std::size_t SHARED_MEMORY_SIZE = 0x40000;
|
constexpr std::size_t SHARED_MEMORY_SIZE = 0x40000;
|
||||||
|
|
||||||
IAppletResource::IAppletResource() : ServiceFramework("IAppletResource") {
|
IAppletResource::IAppletResource() : ServiceFramework("IAppletResource") {
|
||||||
|
@ -75,7 +75,7 @@ IAppletResource::IAppletResource() : ServiceFramework("IAppletResource") {
|
||||||
// Register update callbacks
|
// Register update callbacks
|
||||||
auto& core_timing = Core::System::GetInstance().CoreTiming();
|
auto& core_timing = Core::System::GetInstance().CoreTiming();
|
||||||
pad_update_event =
|
pad_update_event =
|
||||||
core_timing.RegisterEvent("HID::UpdatePadCallback", [this](u64 userdata, int cycles_late) {
|
core_timing.RegisterEvent("HID::UpdatePadCallback", [this](u64 userdata, s64 cycles_late) {
|
||||||
UpdateControllers(userdata, cycles_late);
|
UpdateControllers(userdata, cycles_late);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ void IAppletResource::GetSharedMemoryHandle(Kernel::HLERequestContext& ctx) {
|
||||||
rb.PushCopyObjects(shared_mem);
|
rb.PushCopyObjects(shared_mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IAppletResource::UpdateControllers(u64 userdata, int cycles_late) {
|
void IAppletResource::UpdateControllers(u64 userdata, s64 cycles_late) {
|
||||||
auto& core_timing = Core::System::GetInstance().CoreTiming();
|
auto& core_timing = Core::System::GetInstance().CoreTiming();
|
||||||
|
|
||||||
const bool should_reload = Settings::values.is_device_reload_pending.exchange(false);
|
const bool should_reload = Settings::values.is_device_reload_pending.exchange(false);
|
||||||
|
|
|
@ -65,7 +65,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetSharedMemoryHandle(Kernel::HLERequestContext& ctx);
|
void GetSharedMemoryHandle(Kernel::HLERequestContext& ctx);
|
||||||
void UpdateControllers(u64 userdata, int cycles_late);
|
void UpdateControllers(u64 userdata, s64 cycles_late);
|
||||||
|
|
||||||
Kernel::SharedPtr<Kernel::SharedMemory> shared_mem;
|
Kernel::SharedPtr<Kernel::SharedMemory> shared_mem;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
namespace Service::NVFlinger {
|
namespace Service::NVFlinger {
|
||||||
|
|
||||||
constexpr std::size_t SCREEN_REFRESH_RATE = 60;
|
constexpr std::size_t SCREEN_REFRESH_RATE = 60;
|
||||||
constexpr u64 frame_ticks = static_cast<u64>(Core::Timing::BASE_CLOCK_RATE / SCREEN_REFRESH_RATE);
|
constexpr s64 frame_ticks = static_cast<s64>(Core::Timing::BASE_CLOCK_RATE / SCREEN_REFRESH_RATE);
|
||||||
|
|
||||||
NVFlinger::NVFlinger(Core::Timing::CoreTiming& core_timing) : core_timing{core_timing} {
|
NVFlinger::NVFlinger(Core::Timing::CoreTiming& core_timing) : core_timing{core_timing} {
|
||||||
displays.emplace_back(0, "Default");
|
displays.emplace_back(0, "Default");
|
||||||
|
@ -37,7 +37,7 @@ NVFlinger::NVFlinger(Core::Timing::CoreTiming& core_timing) : core_timing{core_t
|
||||||
|
|
||||||
// Schedule the screen composition events
|
// Schedule the screen composition events
|
||||||
composition_event =
|
composition_event =
|
||||||
core_timing.RegisterEvent("ScreenComposition", [this](u64 userdata, int cycles_late) {
|
core_timing.RegisterEvent("ScreenComposition", [this](u64 userdata, s64 cycles_late) {
|
||||||
Compose();
|
Compose();
|
||||||
this->core_timing.ScheduleEvent(frame_ticks - cycles_late, composition_event);
|
this->core_timing.ScheduleEvent(frame_ticks - cycles_late, composition_event);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue