summaryrefslogtreecommitdiffstats
path: root/osdep/timer.h
Commit message (Collapse)AuthorAgeFilesLines
* mac/vulkan: add support for frame timing via presentation feedbackder richter2024-04-101-0/+9
|
* win32: increase hires timer resolutionnanahi2024-03-191-3/+3
| | | | | | | | | | | timeBeginPeriod() only allows setting minimum timer resolution to 1 ms. However, modern x86 platforms support a minimum timer resolution of 0.5 ms. Use NtSetTimerResolution() instead for the increased resolution, which can be set with MPV_HRT_RES. Additionally, change the units of mp_start_hires_timers(), mp_end_hires_timer(), MPV_HRT_RES, and MPV_HRT_MAX to nanoseconds, in accordance with other functions used in timer.h.
* osdep/timer: update documentation and test for mp_time_nsKacper Michajłow2024-01-261-1/+1
| | | | No longer true after 8bbcc87feea7abf256a6c7f511244d09f5520c17.
* timer: remove unused codeKacper Michajłow2023-11-051-7/+0
|
* timer: remove MP_START_TIMENRK2023-10-271-2/+1
| | | | | instead require mp_raw_time_ns() to not return 0, which all current implementation already should follow.
* timer: remove microsecond timer functionsDudemanguy2023-10-161-10/+0
| | | | | | | | | With the previous series of commits, all internal usage has been replaced by the nanosecond functions. There's not really any point in keeping these around anymore plus there are macros for unit conversions now so we can just axe them. It's worth noting that mpv_get_time_us() obviously still needs to work for API reasons, but we can just divide mp_time_ns() by 1000 to get the same thing.
* demux: convert cache updates to nanosecondsDudemanguy2023-10-161-3/+0
| | | | As a bonus, we can remove the awkward and horribly named MP_SECOND_US.
* timer: add convenience time unit conversion macrosDudemanguy2023-10-161-0/+10
| | | | | | | There's a lot of wild 1e6, 1000, etc. lying around in the code. A macro is much easier to read and understand at a glance. Add some helpers for this. We don't need to convert everything now but there's some simple things that can be done so they are included in this commit.
* timer: change mp_sleep_us to mp_sleep_nsDudemanguy2023-10-101-3/+3
| | | | | | | | | | | Linux and macOS already use nanosecond resolution for their sleep functions. It was just being converted from microseconds before. Since we have mp_time_ns now, go ahead and bump the precision here. The timer for windows uses some timeBeginPeriod thing which I'm not sure what it does really but whatever just convert the units to ms like they were doing before. There's really no reason to keep the mp_sleep_us helper around. A multiplication by 1000 is trivial and underlying OS clocks have nanosecond precision.
* msg: use nanosecond precisionDudemanguy2023-09-291-1/+1
| | | | | | | | | | The timestamps when making a log file is actually dependent on MP_START_TIME. This is a 10 microsecond offset that was added to the timer as an offset. With the nanosecond change, this unit needs to be converted as well so the offset is the same as before. After doing that, we need to change the various mp_time_us calls in msg to mp_time_ns and do the right conversion. This fixes the logs timestamps (i.e. so they aren't negative anymore).
* timer: teach it about nanosecondsKacper Michajłow2023-09-291-1/+11
| | | | | Those changes will alow to change vsync base to more precise time base. In general there is no reason to truncate values returned by system.
* timer: rename mp_add_timeout to reflect what it actually doesKacper Michajłow2023-09-291-1/+1
|
* timer: rename mp_time_us_to_timespec to reflect what it actually doesKacper Michajłow2023-09-291-1/+1
|
* win32: Windows 10: timeBeginPeriod on demandAvi Halachmi (:avih)2021-09-211-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | Before this commit, timeBeginPeriod(1) was set once when mpv starts, and the timers remained hi-res till mpv exits. Now we do the same as before on Windows version < 10. On Windows 10+ we now use timeBeginPeriod if needed, per timeout. To force a mode regardless of Windows version, set env MPV_HRT: - "always": the old behavior - hires timers as long as mpv runs. - "perwait": sets 1ms timer resolution if timeout <= 50ms. - "never": don't use timeBeginPeriod at all. It was observed that on Windows 10 we lose about 0.5ms accuracy of timeouts with "perwait" mode (acceptable), but otherwise it works well for continuous timeouts (one after the other) and random ones. On Windows 7 with "perwait": continous timeouts are accurate, but random timeouts (after some time without timeouts) have bad accuracy - roughly 16ms resolution instead of the requested 1ms. Windows 8 was not tested, so to err on the side of caution, we keep the legacy behavior "always" by default.
* demux, stream: readd cache-speed in some other formwm42018-12-061-0/+3
| | | | it's more like an input speed rather than a cache speed, but who cares.
* timer: remove an unused helper functionwm42018-05-241-6/+0
| | | | It's also dumb.
* osdep/timer*: change license to LGPLwm42017-05-051-7/+7
| | | | | | | | | | | | | | All authors have agreed, with the following exceptions: e68d7f6858: wight wasn't asked (I think...), but even if he modified the patch he applied, all code added by it was removed again later. cb7768f9bb: nick could not be reached, but the declarations he added as well as the full timer.c file were deleted again in cff81fe498 and f800a42e45 (did it really take 6 years to remove unused declarations?). ffaf4af230: it looks like this person wasn't contacted, but the code added was removed again in f544bcf105.
* threads: use utility+POSIX functions instead of weird wrapperswm42015-05-111-0/+4
| | | | | | | There is not much of a reason to have these wrappers around. Use POSIX standard functions directly, and use a separate utility function to take care of the timespec calculations. (Course POSIX for using this weird format for time values.)
* Update license headersMarcin Kurczewski2015-04-131-5/+4
| | | | Signed-off-by: wm4 <wm4@nowhere>
* msg: add --log-file optionwm42015-01-261-0/+2
| | | | | | | | | This allows getting the log at all with --no-terminal and without having to retrieve log messages manually with the client API. The log level is hardcoded to -v. A higher log level would lead to too much log output (huge file sizes and latency issues due to waiting on the disk), and isn't too useful in general anyway. For debugging, the terminal can be used instead.
* threads: use mpv time for mpthread_cond_timedwait wrapperwm42014-05-181-0/+7
| | | | | | Use the time as returned by mp_time_us() for mpthread_cond_timedwait(), instead of calculating the struct timespec value based on a timeout. This (probably) makes it easier to wait for a specific deadline.
* timer: add utility function to get relative timewm42014-02-281-0/+6
|
* Replace calls to usec_sleep()wm42013-05-261-3/+0
| | | | | | This is just dumb sed replacement to mp_sleep_us(). Also remove the now unused usec_sleep() wrapper.
* Replace all calls to GetTimer()/GetTimerMS()wm42013-05-261-2/+0
| | | | | | | | | | | | | | | | | | | | | | GetTimer() is generally replaced with mp_time_us(). Both calls return microseconds, but the latter uses int64_t, us defined to never wrap, and never returns 0 or negative values. GetTimerMS() has no direct replacement. Instead the other functions are used. For some code, switch to mp_time_sec(), which returns the time as double float value in seconds. The returned time is offset to program start time, so there is enough precision left to deliver microsecond resolution for at least 100 years. Unless it's casted to a float (or the CPU reduces precision), which is why we still use mp_time_us() out of paranoia in places where precision is clearly needed. Always switch to the correct time. The whole point of the new timer calls is that they don't wrap, and storing microseconds in unsigned int variables would negate this. In some cases, remove wrap-around handling for time values.
* timer: refactor, add 64 bit timer functionwm42013-05-261-3/+21
| | | | | | | | | | | | | | Make OS specific timer code export a mp_raw_time_us() function, and add generic implementations of GetTimer()/GetTimerMS() using this function. New mpv code is supposed to call mp_time_us() in situations where precision is absolutely needed, or mp_time_s() otherwise. Make it so that mp_time_us() will return a value near program start. We don't set it to 0 though to avoid confusion with relative vs. absolute time. Instead, pick an arbitrary offset. Move the test program in timer-darwin.c to timer.c, and modify it to work with the generic timer functions.
* timer: remove timer_namewm42012-09-071-2/+0
| | | | This was unreferenced and useless.
* Merge svn changes up to r28862Uoti Urpala2009-03-071-0/+18
|\
| * Add standard license headers to files.diego2009-03-011-0/+18
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28779 b3059339-0415-0410-9bf9-f77b7e298cf2
| * Get rid of pointless 'extern' keywords.diego2008-12-031-2/+2
| | | | | | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28085 b3059339-0415-0410-9bf9-f77b7e298cf2
* | osdep: Remove cruftUoti Urpala2008-04-281-6/+0
| | | | | | | | Delete some commented out or otherwise unused lines.
* | timers: Remove GetRelativeTime()Uoti Urpala2008-04-281-1/+0
| | | | | | | | | | | | | | | | | | | | Move the code calculating time delta since last query out of the platform-specific drivers and into mplayer.c. The platform-specific drivers now return absolute values only. The way the code in timer-darwin.c uses doubles in wrapping arithmetic looks questionable and this change might make problems in it more visible.
* | osdep: Change timer_name to a saner typeUoti Urpala2008-04-281-1/+1
|/ | | | | timer_name was a (non-const) pointer to a const char array. Make the symbol the array itself.
* Identifiers starting with underscores are reserved.diego2007-07-311-3/+3
| | | | git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23954 b3059339-0415-0410-9bf9-f77b7e298cf2
* Patch by Stefan Huehner / stefan % huehner ! org \rathann2006-02-091-4/+4
| | | | | | | | | | | | | | | | | | | | | | patch replaces '()' for the correct '(void)' in function declarations/prototypes which have no parameters. The '()' syntax tell thats there is a variable list of arguments, so that the compiler cannot check this. The extra CFLAG '-Wstrict-declarations' shows those cases. Comments about a similar patch applied to ffmpeg: That in C++ these mean the same, but in ANSI C the semantics are different; function() is an (obsolete) K&R C style forward declaration, it basically means that the function can have any number and any types of parameters, effectively completely preventing the compiler from doing any sort of type checking. -- Erik Slagter Defining functions with unspecified arguments is allowed but bad. With arguments unspecified the compiler can't report an error/warning if the function is called with incorrect arguments. -- Måns Rullgård git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17567 b3059339-0415-0410-9bf9-f77b7e298cf2
* Native darwin timer update.wight2004-08-041-0/+2
| | | | | | | Patch by Dan Christiansen <danchr@daimi.au.dk> git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12955 b3059339-0415-0410-9bf9-f77b7e298cf2
* linux->osdeparpi2003-02-091-0/+17
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9381 b3059339-0415-0410-9bf9-f77b7e298cf2