summaryrefslogtreecommitdiffstats
path: root/osdep
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* vo_gpu/vo_gpu_next: add vulkan support for macOSder richter2023-10-144-2/+166
| | | | | | | | add support for vulkan through metal and a translation layer like MoltenVK. also add the possibility to use different render timing modes for testing. i still consider this experimental atm.
* terminal-unix: make stop/cont sighandlers pipe basedNRK2023-10-131-16/+37
| | | | | | | | | there are currently some silly data-races in the stop/cont sighandler due to the fact that the signal handler might get invoked in a different thread. this changes those sighandlers to a pipe-based approach similar to the existing "quit" sighandler.
* terminal-unix: avoid data race + simplifyNRK2023-10-131-13/+4
| | | | | | | | | | | | tio_orig and tio_orig_set are being touched inside of signal handler which might be invoked from another thread - which makes this a data race. there's no real reason to set tio_orig inside of do_activate_getch2() which is registered as a signal handler. just set it once, in terminal_init(), before any signal handlers come in play. this also allows removing the tio_orig_set variable completely.
* terminal-unix: avoid data-race on do_deactivate_getch2NRK2023-10-131-2/+3
| | | | | | | | | | | | | do_deactivate_getch2() touches some global variables which *might have* been fine if the terminal thread was the one that received the signal but AFAIK which thread will handle the signal is not well defined. in my case, when quitting mpv with CTRL+C the main thread receives the signal rather than the terminal thread and touches those globals without synchronization. caught by ThreadSanitizer. the solution is to move the do_deactivate_getch2() call outside of the signal handler.
* terminal-unix: don't spoil errno in signal handlerNRK2023-10-131-1/+6
| | | | | | | otherwise the resuming code might end up seeing a spoiled errno and end up taking unintended branches based on it. caught via ThreadSanitizer
* osdep/timer-win2: use Waitable Timer for sleepingKacper Michajłow2023-10-101-7/+31
| | | | | | | Allows higher resolution sleeps than Sleep which has milliseconds resolution. In practice Windows kernel does not really go below 0.5ms, but we don't have to limit ourselves on API side of things and do the best we can.
* timer: change mp_sleep_us to mp_sleep_nsDudemanguy2023-10-104-16/+15
| | | | | | | | | | | 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.
* vo: use mp_poll wrapper in wait_events when applicableDudemanguy2023-10-102-0/+16
| | | | | | | | | | On linux, several platforms poll for events over a fd. This has ms accuracy, but mpv's timer is in ns now so lots of precision is lost. We can use an mp_poll wrapper to use ppoll instead which takes a timespec directly with nanosecond precision. On systems without ppoll this falls back to old poll behavior. On wayland, we don't actually use this because ppoll completely messes up the event loop for some unknown reason.
* osdep: rename polldev to poll_wrapperDudemanguy2023-10-103-5/+6
| | | | | | | Originally, this was added as purely a shim for macOS. However since we want to do high resolution polling which is not neccesarily available on all platforms, making this a generic wrapper for poll functions is useful so rename it.
* 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).
* win32/pthread: define _POSIX_TIMERS to notify they are not supportedKacper Michajłow2023-09-291-0/+2
|
* win32/pthread: don't convert time through unrelated timerKacper Michajłow2023-09-292-18/+16
| | | | Just keep it directly as mp_time for internal implementation.
* timer: teach it about nanosecondsKacper Michajłow2023-09-295-35/+56
| | | | | 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-292-3/+3
|
* timer: remove dead codeKacper Michajłow2023-09-291-35/+0
| | | | This is not a proper way to do unit tests or whatever that was.
* timer: simplify mp_time_us_to_realtimeKacper Michajłow2023-09-291-21/+20
|
* timer: rename mp_time_us_to_timespec to reflect what it actually doesKacper Michajłow2023-09-292-4/+4
|
* options: remove ancient option fallbacks/deprecationDudemanguy2023-09-211-2/+0
| | | | | | | | | | | | | We've got an ungodly amount of OPT_REPLACED and OPT_REMOVED sitting around in the code. This is harmless, but the vast majority of these are ancient. 26f4f18c0629998a9b91e94722d166866d8b80a3 is the last commit that touched the majority of these and of course that only changed how options were declared so all of this stuff was deprecated even before that. No use in keeping these, so just delete them all. As an aside, there was actually a cocoa_opts but it had only a single option which was replaced by something else and empty otherwise. So that entire thing was just simply removed. OPT_REPLACED/OPT_REMOVED declarations that were added in 0.35 or later were kept as is.
* osdep/io: provide dlopen, etc. abstraction wrappers for windowschuck-2023-09-202-0/+79
|
* path-{darwin,unix}: save cache to subdir when using non-XDG pathDudemanguy2023-09-072-4/+12
| | | | | | | | | | mpv saves cache by default nowadays, but vo_gpu is pretty spammy and saves a bunch of files per shader. If someone is using the non-XDG config directory, this all gets dumped directly into ~/.mpv which isn't so nice. Save it to a sub directory called "cache" instead (or alternatively submit to your XDG overlords). For unfortunate reasons, macOS uses XDG_CONFIG_HOME and has the same legacy fallback mechanism, so this applies to it too.
* win32: allow heap cache optimization and memory decommitKacper Michajłow2023-09-011-0/+19
|
* win32: add BASE_SEARCH_PATH_PERMANENT to SetSearchPathModeKacper Michajłow2023-09-011-1/+2
|
* win32: don't load dynamically always available functionsKacper Michajłow2023-09-011-6/+1
| | | | They are all available on Windows 7 and newer.
* player/command: remove video-aspect propertyKacper Michajłow2023-08-311-5/+5
| | | | 4 years is enough of deprecation period.
* input: add missing windows multimedia keysChristoph Heinrich2023-08-271-1/+10
| | | | | | | | x11 and wayland had a lot of multimedia keys mapped that were missing on windows. Now the only ones they map that windows doesn't are `MP_KEY_WWW`, `MP_KEY_ZOOMIN` and `MP_KEY_ZOOMOUT`, which apparently don't have any equivalent ones on windows.
* input: add missing keypad key definesChristoph Heinrich2023-08-251-4/+4
| | | | | | | | So far all the keypad keys except for `0` and `,` mapped to the same MP_KEY_* independent of numlock state, even though different key codes are received. Now all the alternative functions map to appropriate MP_KEY_* defines, with missing ones added.
* path-unix: abort on path truncationNRK2023-08-121-14/+22
| | | | instead of silently proceeding with a truncated path.
* build: remove outdated generated directoryDudemanguy2023-07-313-2/+59
| | | | | | | | | | | | | | | | This only existed as essentially a workaround for meson's behavior and to maintain compatibility with the waf build. Since waf put everything in a generated subdirectory, we had to put make a subdirectory called "generated" in the source for meson so stuff could go to the right place. Well now we don't need to do that anymore. Move the meson.build files around so they go in the appropriate place in the subdirectory of the source tree and change the paths of the headers accordingly. A couple of important things to note. 1. mpv.com now gets made in build/player/mpv.com (necessary because of a meson limitation) 2. The macos icon generation path is shortened to TOOLS/osxbundle/icon.icns.inc.
* path-win: move state directory to %LOCALAPPDATA%Kacper Michajłow2023-07-291-0/+2
| | | | %LOCALAPPDATA% is where the local application state belongs.
* path-win: add subdirectory for cacheKacper Michajłow2023-07-291-1/+1
| | | | To not polute %LOCALAPPDATA%/mpv as it may be used for other things too.
* language-posix: as a fallback, treat "C" as "en"rcombs2023-07-251-0/+11
| | | | | If we see "C" in one of the language vars we check, don't treat it as a language tag. Once we've checked everything, if we don't have any languages, but saw "C" anywhere, fall back on "en".
* terminal-unix: fix not listening on input after being foregroundedNRK2023-07-211-2/+13
| | | | | | | | | | fixes regression caused by 2e7fcc5a2 where it wouldn't receive terminal input if the process was foregrounded later on like this: $ mpv something.mp4 & $ fg ref: https://github.com/mpv-player/mpv/issues/11795
* player: set default cache dir on macOSm154k12023-07-151-3/+10
| | | | Use ~/Library/Caches/io.mpv for caches instead of ~~home.
* path-win: implement cache directoriesDudemanguy2023-07-151-0/+9
| | | | | | | | | | | | 4502522a7aee093c923e79a65e4684ea2634af30 implemented cache directories but only on linux which meant other OSes continued to save this stuff in their config directory. Since we turned on cache by default, people are getting cache files in there which is understandably causing some confusion. Let's go ahead and implement a separate cache directory for windows since there seems to be some established conventions for this already. For people using the portable_path, the cache is saved in a subdirectory within the portable_path since the idea is for that to be completely self contained.
* terminal-unix: better error detection logicNRK2023-07-081-1/+1
| | | | | | | | | | | | | | | | the reason for checking `EBADF|EINVAL` specifically is unknown. but it's clearly not working as intended since it can cause issues like #11795. instead of checking for "bad errors" check for known "good errors" where we might not want to break out. this includes: * EINTR: which can happen if read() is interrupted by some signal. * EAGAIN: which happens if a non-blocking fd would block. `tty_in` is _not_ non-blocking, so EAGAIN should never occur here. but it's added just in case that changes in the future. Fixes: https://github.com/mpv-player/mpv/issues/11795 Closes: https://github.com/mpv-player/mpv/pull/11805
* osdep: remove erroneous POLLERR emulationNRK2023-06-292-10/+3
| | | | | | | | | | | | first of all, POLLERR is supposed to be ignored in `.events` and only returned in `.revents`. secondly select()'s exceptfds does not have a 1:1 correspondence with POLLERR. thankfully, the only caller of this function (in terminal-unix) never set the POLLERR flag so the errorfds were unused anyways. so go ahead and remove it entirely instead of pretending we can emulate something that's not possible.
* osdep: add mp_get_user_langsrcombs2023-06-253-0/+171
|
* osdep: move cfstr<->cstr conversions to a new apple_utils.c filercombs2023-06-252-0/+67
|
* player: use XDG_CACHE_HOME by defaultDudemanguy2023-05-092-0/+12
| | | | | | | | | | | | This adds cache as a possible path for mpv to internally pick (~/.cache/mpv for non-darwin unix-like systems, the usual config directory for everyone else). For gpu shader cache and icc cache, controlling whether or not to write such files is done with the new --gpu-shader-cache and --icc-cache options respectively. Additionally, --cache-on-disk no longer requires explicitly setting the --cache-dir option. The old options, --cache-dir, --gpu-shader-cache-dir, and --icc-cache-dir simply set an override for the directory to save cache files. If unset, then the cache is saved in XDG_CACHE_HOME.
* player: use XDG_STATE_HOME for watch_laterDudemanguy2023-05-092-4/+21
| | | | | | | | | | | | | | | | | | A pain point for some users is the fact that watch_later is stored in the ~/.config directory when it's really not configuration data. Roughly 2 years ago, XDG_STATE_DIR was added to the XDG Base Directory Specification[0] and its description, user-specific state data, actually perfectly matches what watch_later data is for. Let's go ahead and use this directory as the default for watch_later. This change only affects non-darwin unix-like systems (i.e. Linux, BSDs, etc.). The directory doesn't move for anyone else. Internally, quite a few things change with regards to the path selection. If the platform in question does not have a statedir concept, then the path selection will simply return "home" instead (old behavior). Fixes #9147. [0]: https://gitlab.freedesktop.org/xdg/xdg-specs/-/commit/4f2884e16db35f2962d9b64312917c81be5cb54b
* osdep: separate out macos paths from path-unix.cDudemanguy2023-05-092-0/+67
| | | | | | | | | | | macOS really has completely different path conventions that mpv doesn't take into account and it treats it just like any other old unix-like system. This means mpv enforces certain conventions on it (like all the XDG stuff) that doesn't really apply. Since we'd like to use more of this but at the same time not distrupt mac users even more, let's just copy and paste the current code to a new file, update the build and call it a day. This way, the paths of these two platforms can more freely diverge.
* options: transition options from OPT_FLAG to OPT_BOOLChristoph Heinrich2023-02-213-7/+7
| | | | | | c78482045444c488bb7948305d583a55d17cd236 introduced a bool option type as a replacement for the flag type, but didn't actually transition and remove the flag type because it would have been too much mundane work.
* various: drop unused #include "config.h"Thomas Weißschuh2023-02-206-9/+0
| | | | | | Most sources don't need config.h. The inclusion only leads to lots of unneeded recompilation if the configuration is changed.
* osdep/io: add void to mp_penvironKacper Michajłow2023-02-021-1/+1
|
* osdep: add MP_FALLTHROUGHKacper Michajłow2023-02-021-0/+2
|
* osdep/terminal.h: Rename screen buffer controlsMia Herkt2022-12-201-2/+2
| | | | SAVE/RESTORE were a bit misleading.
* osdep/terminal: Move common esc codes to terminal.hMia Herkt2022-12-191-0/+8
|
* w32: fix typo in F23 mappingThomas Weißschuh2022-09-031-1/+1
|
* macos: add support for F13-F20 keysThomas Weißschuh2022-09-021-0/+3
|
* w32: add support for F13-F24 keysThomas Weißschuh2022-09-021-0/+4
| | | | Fixes #10595
* misc/random: add xoshiro random number implementationLeo Izen2022-08-172-2/+4
| | | | | | | Add xoshiro as a PRNG implementation instead of relying on srand() and rand() from the C standard library. This, in particular, lets us avoid platform-defined behavior with respect to threading.
* various: fix typosCœur2022-04-252-3/+3
|
* osdep/atomic: add mp_atomic_doubleAman Karmani2022-04-021-0/+2
| | | | Signed-off-by: Aman Karmani <aman@tmm1.net>
* subprocess: unblock/reset signals before running child processsfan52021-12-191-0/+21
| | | | | | | During execve() ignored and blocked signals carry over to the child process, though apparently for SIGCHLD (which the bug report was about) this is implementation-defined. fixes #9613
* libmpv: remove opengl_cb API and other deprecated symbolssfan52021-12-151-2/+1
| | | | | | Not all deprecated symbols were removed. Only three events were removed for now since these are not used internally. This bumps the library version to 2.0.
* build: add meson build supportDudemanguy2021-11-141-0/+1
| | | | | | Adds support for the meson build system as well as a bit of documentation. Compatibility with the existing waf build is maintained.
* osdep: rename MP_UNREACHABLENiklas Haas2021-11-031-2/+2
| | | | | It was pointed out on IRC that the name is misleading, since the actual semantics of the macro is to assert first.
* osdep: add MP_UNREACHABLENiklas Haas2021-11-031-0/+6
| | | | | | | | | This seems to work on gcc, clang and mingw as-is, but I made it conditional on __GNUC__ just in case, even though I can't figure out which compilers we care about that don't export this define. Also replace all instances of assert(0) in the code by MP_UNREACHABLE(), which is a strict improvement.
* win32: Windows 10: timeBeginPeriod on demandAvi Halachmi (:avih)2021-09-213-1/+72
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* terminal-unix: identify and ignore unknown CSI sequencesAvi Halachmi (:avih)2021-08-191-0/+11
| | | | | | | | | | | | | | | If an unknown ESC sequence is detected where an ASCII char <X> follows the ESC, mpv interprets it as ALT+<X>, which is the traditional terminal encoding of ALT+letter. However, if <X> is '[' then it's a CSI sequence which continues after the '[', and has its own termination rules (can be many chars). Previously, mpv interpreted unknown CSI sequences as (incorrect) ALT+[ followed by (incorrect) "keys" from the rest of the sequence. In this commit, if a unknown CSI sequence is detected, mpv ignores exactly the complete sequence.
* terminal-unix: fix ^Z identificationMartin Tournoij2021-07-131-1/+2
| | | | | | | | | | | | | | When using "stty susp ''" to disable sending the TSTP signal with ^Z, mpv didn't recognize ^Z correctly in the terminal: [input] No key binding found for key 'Ctrl+2'. Because ASCII 26 (^Z) and above were incorrectly considered ^<NUMBER>. This commit moves the cutoff between letters/numbers from 25 to 26 so that ^Z is now detected correctly as ^<LETTER>. Additionally, it rephrases the ^<NUMBER> formula for clarity.
* mac: add ability to toggle visibility on all workspaces from menubarEvgeny Zinoviev2021-02-211-0/+7
|
* mac: only update touch bar items when necessaryder richter2021-02-132-87/+150
| | | | | | | | | | | | | | | | the slider on the touch bar was always updated when any of the related properties changed their value. this is partially dependent on the refresh rate of the video, in the case of time-pos. too many updates to touch bar impact the render performance. to prevent this we only update the slider when necessary, when the touch bar or the touch bar item is visible. the touch bar items only need a granularity of seconds without any decimals, but the time-pos property provides a granularity with decimals. we floor those values and only update the touch bar items when we have at least a 1 second difference. we also check for the visibility of the touch bar and its items. Fixes #8477
*