wxwidgets: Hide dumper called "NULL"
[lsnes.git] / include / core / framerate.hpp
blob2fb2ddcc8220777d2d3d669f60a7042cbb065643
1 #ifndef _framerate__hpp__included__
2 #define _framerate__hpp__included__
4 #include <cstdint>
5 #include "library/threads.hpp"
6 #include "library/command.hpp"
8 #define FRAMERATE_HISTORY_FRAMES 10
10 /**
11 * Framerate regulator.
13 class framerate_regulator
15 public:
16 framerate_regulator(command::group& _cmd);
17 /**
18 * Set the target speed multiplier.
20 * Parameter multiplier: The multiplier target. May be INFINITE.
22 void set_speed_multiplier(double multiplier) throw();
24 /**
25 * Get the target speed multiplier.
27 * Returns: The multiplier. May be INFINITE.
29 double get_speed_multiplier() throw();
31 /**
32 * Sets the nominal frame rate. Framerate limiting tries to maintain the nominal framerate when there is no other
33 * explict framerate to maintain.
35 void set_nominal_framerate(double fps) throw();
37 /**
38 * Returns the current realized framerate multiplier.
40 * returns: The framerate multiplier the system is currently archiving.
42 double get_realized_multiplier() throw();
44 /**
45 * Freeze time.
47 * Parameter usec: Current time in microseconds.
49 void freeze_time(uint64_t usec);
51 /**
52 * Unfreeze time.
54 * Parameter usec: Current time in microseconds.
56 void unfreeze_time(uint64_t usec);
58 /**
59 * Acknowledge frame start for timing purposes. If time is frozen, it is automatically unfrozen.
61 * parameter usec: Current time (relative to some unknown epoch) in microseconds.
63 void ack_frame_tick(uint64_t usec) throw();
65 /**
66 * Computes the number of microseconds to wait for next frame.
68 * parameter usec: Current time (relative to some unknown epoch) in microseconds.
69 * returns: Number of more microseconds to wait.
71 uint64_t to_wait_frame(uint64_t usec) throw();
73 /**
74 * Return microsecond-resolution time since unix epoch.
76 static uint64_t get_utime();
78 /**
79 * Wait specified number of microseconds.
81 void wait_usec(uint64_t usec);
82 /**
83 * Turbo flag.
85 bool turboed;
86 private:
87 void set_speed_cmd(const std::string& args);
88 uint64_t get_time(uint64_t curtime, bool update);
89 double get_realized_fps();
90 void add_frame(uint64_t linear_time);
91 std::pair<bool, double> read_fps();
92 uint64_t last_time_update;
93 uint64_t time_at_last_update;
94 bool time_frozen;
95 uint64_t frame_number;
96 uint64_t frame_start_times[FRAMERATE_HISTORY_FRAMES];
97 //Framerate.
98 double nominal_framerate;
99 double multiplier_framerate;
100 threads::lock framerate_lock;
101 command::group& cmd;
102 command::_fnptr<> turbo_p;
103 command::_fnptr<> turbo_r;
104 command::_fnptr<> turbo_t;
105 command::_fnptr<const std::string&> setspeed_t;
108 #endif