summaryrefslogtreecommitdiffstats
path: root/misc
Commit message (Collapse)AuthorAgeFilesLines
* bstr: use memchr and memrchr for bstrchr and bstrrchrKacper Michajłow13 days1-4/+11
| | | | May be faster to use optimized variants instead of simple loop.
* misc/thread_tools: fix incorrect win32 checkKacper Michajłow14 days1-3/+3
|
* misc/language: move mp_guess_lang_from_filename() hereGuido Cella2024-05-102-1/+57
|
* misc/language: store string length instead of null terminatorKacper Michajłow2024-05-091-208/+211
| | | | | Allows to construct bstr directly without strlen, while keeping language table the same size.
* player/loadfile: match language and subcodesKacper Michajłow2024-05-092-0/+297
|
* Revert "misc: add language-matching utilities"Kacper Michajłow2024-05-092-367/+0
| | | | This reverts commit 8c8d97c26c8b6bef9b8d763db2091e186205ab98.
* various: fix indentationnanahi2024-05-071-1/+1
|
* win32: fix platform checksKacper Michajłow2024-05-061-2/+2
|
* io_utils: use mp_mkostemps instead of mkstempKacper Michajłow2024-05-061-1/+1
|
* various: move strings.h inclusion to common.hKacper Michajłow2024-05-063-3/+1
|
* various: move unistd.h inclusion to common.hKacper Michajłow2024-05-063-3/+2
|
* misc/path_utils: normalize win32 pathsKacper Michajłow2024-05-051-1/+33
|
* player: normalize paths for resuming playbackGuido Cella2024-05-051-1/+52
| | | | | | | | Paths like foo.mkv, ./foo.mkv .//foo.mkv, ../"$(basename "$PWD")"/foo.mkv, and C:\foo.mkv and C:/foo.mkv on Windows, use different config files for resuming playback, so if you quit-watch-later and later play the same file with a different path, mpv does not resume playback. This commit normalizes the paths on Unix to fix this.
* bstr: change bstr0_s to bstr0_lit, restrict it only for string literalsKacper Michajłow2024-04-081-2/+2
| | | | | | | | | Allows to avoid non-portable strlen usage. Also avoid "initializer element is not constant" warnings on older GCC that doesn't like explicit type specification in aggregate initialization. Co-authored-by: NRK <nrk@disroot.org> Co-authored-by: nanahi <130121847+na-na-hi@users.noreply.github.com>
* misc/bstr: add bstr0_s for static initializationKacper Michajłow2024-04-071-1/+3
|
* misc/bstr: add bstr_to_wchar for win32Kacper Michajłow2024-03-192-0/+26
| | | | Convenience to avoid strlen above other things.
* misc/jni: reduce duplication in mapping structsfan52024-02-282-6/+6
| | | | | 'name' was in fact unused when reading fields or methods, so it can be merged with 'method'. Also changed the type of 'mandatory' to bool.
* misc/jni: introduce macros for deleting referencessfan52024-02-282-20/+20
|
* misc/jni: general code cleanup and refactorsfan52024-02-281-155/+119
| | | | Make it align with mpv's coding conventions in general and avoid unecessary Lavu use.
* options/path: move path utility functions to misc/path_utilsnanahi2024-02-232-0/+283
| | | | | These utility functions have nothing to do with user and config dir/file. Move them to a separate file.
* osdep/io: move I/O utility functions to misc/io_utilsnanahi2024-02-232-0/+112
| | | | | | | The purpose of osdep/io is to provide a wrapper for POSIX I/O functions on Windows. The last 2 functions are utility functions which don't serve this purpose. Move them to a separate file.
* various: replace dead links in commentsnanahi2024-02-111-1/+1
| | | | | Replace various dead links with live replacements or archives. Less friction for anyone who wants to look up these references.
* timer: remove unnecesary time conversionsKacper Michajłow2023-11-051-1/+1
|
* mp_thread: prefer tracking threads with idKacper Michajłow2023-11-052-9/+11
| | | | | | | | | | | | | | This change essentially removes mp_thread_self() and instead add mp_thread_id to track threads and have ability to query current thread id during runtime. This will be useful for upcoming win32 implementation, where accessing thread handle is different than on pthreads. Greatly reduces complexity. Otherweis locked map of tid <-> handle is required which is completely unnecessary for all mpv use-cases. Note that this is the mp_thread_id, not to confuse with system tid. For example on threads-posix implementation it is simply pthread_t.
* ALL: use new mp_thread abstractionKacper Michajłow2023-11-057-144/+143
|
* various: sort some standard headersNRK2023-10-201-2/+2
| | | | | | | | | | | | since i was going to fix the include order of stdatomic, might as well sort the surrouding includes in accordance with the project's coding style. some headers can sometime require specific include order. standard library headers usually don't. but mpv might "hack into" the standard headers (e.g pthreads) so that complicates things a bit more. hopefully nothing breaks. if it does, the style guide is to blame.
* various: remove ATOMIC_VAR_INITNRK2023-10-201-1/+1
| | | | | | | | | | | the fallback needed it due to the struct wrapper. but the fallback is now removed so it's no longer needed. as for standard atomics, it was never really needed either, was useless and then made obsolete in C17 and removed in C23. ref: https://gustedt.wordpress.com/2018/08/06/c17-obsoletes-atomic_var_init/ ref: https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT
* osdep: remove atomic.hNRK2023-10-201-1/+1
| | | | | | | replace it with <stdatomic.h> and replace the mp_atomic_* typedefs with explicit _Atomic qualified types. also add missing config.h includes on some files.
* thread_tools: suppress -Wstringop-overflow false-positiveKacper Michajłow2023-10-191-0/+7
|
* charset_conv: suppress unused-label warningKacper Michajłow2023-10-191-1/+2
|
* dispatch: change mp_dispatch_queue_process timer to nanosecondsDudemanguy2023-10-161-2/+2
| | | | | The playloop is the only thing that adjusts the timeout with a value other than 0, so nothing else needs to be changed.
* demux: change the default of metadata-codepage to autoDudemanguy2023-10-071-1/+2
| | | | | | | There's really no reason not to do this especially since sub-codepage already defaults to auto. Also change logging in charset_conv since telling us that the data is UTF-8 if the passed codepage value is "auto" or "utf-8" is really not useful information (that's the expectation).
* charset_conv: remove ancient warning about deprecated syntaxDudemanguy2023-10-071-12/+0
| | | | | wm4 removed this in 4adfde5dd1e67775228a345cea00ea03ba6bc68f and left a warning. Nobody needs to know that enca:pl used to work.
* 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
|
* various: add missing include in header fllesllyyr2023-09-211-0/+1
| | | | Mostly cosmetic
* meson: include our local copy of libavutil uuid if ffmpeg is too oldPhilip Langdale2023-09-041-2/+2
| | | | | | | | | In the previous change, I added the uuid files. In this change, we check the libavutil version and if it's too old, we compile in our local copy. We have to change the include paths of the uuid code to find some other libavutil headers, but nothing beyond that.
* misc: add copy of uuid from ffmpegPhilip Langdale2023-09-042-0/+287
| | | | | | | | | | | To avoid taking a dependency on ffmpeg 5.1 before we're ready (we need a newer Ubuntu LTS release to drop ffmpeg 4.x support), ut not force us to wait to add support for picking Vulkan devices by UUID, I'm copying the uuid code from ffmpeg into mpv. It's one file with no private dependencies, so it's easier to copy than to reimplement in any other way. Licence is LGPL so matches us.
* json: unify json_parse depth to MAX_JSON_DEPTH=50cvzi2023-07-081-0/+2
|
* osdep: add mp_get_user_langsrcombs2023-06-251-0/+2
|
* misc: add language-matching utilitiesrcombs2023-06-252-0/+391
|
* charset_conv: fix memory corruption in mp_iconv_to_utf8low-batt2023-04-291-0/+3
| | | | | | | | | | | | | | | If mp_iconv_to_utf8 was given an empty string to convert in the buf parameter it would corrupt memory when writing a null into outbuf before returning it to the caller. This happened when streaming from a URL that ends in a slash. For such a URL the method mp_basename returns an empty string. The method append_dir_subtitles passes the result returned from mp_basename to mp_iconv_to_utf8 which then corrupts memory. This was detected using Guard Malloc. The fix changes mp_iconv_to_utf8 check up front if buf is empty and if it is return buf as the result in compliance with the documented behavior of the method when no conversion is needed. Fixes #11626
* various: fix various typos in the code baseAlexander Seiler2023-03-281-1/+1
| | | | Signed-off-by: Alexander Seiler <seileralex@gmail.com>
* misc/node: add bstr-based variants for map_get() and map_add()rcombs2023-01-282-2/+16
|
* misc/json: don't wrap top-level pretty strings/infs in quotesrcombs2023-01-281-2/+5
| | | | This makes pretty-printing nodes substantially more friendly.
* various: replace abort() with MP_ASSERT_UNREACHABLE() where appropriatesfan52023-01-121-1/+1
| | | | | | | | In debug mode the macro causes an assertion failure. In release mode it works differently and tells the compiler that it can assume the codepath will never execute. For this reason I was conversative in replacing it, e.g. in mpv-internal code that exhausts all valid values of an enum or when a condition is clear from directly preceding code.
* misc/random: add xoshiro random number implementationLeo Izen2022-08-172-0/+116
| | | | | | | 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.
* osdep: rename MP_UNREACHABLENiklas Haas2021-11-031-1/+1
| | | | | 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-1/+1
| | | | | | | | | 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.
* ring: remove thiswm42020-08-292-239/+0
| | | | | The code is OK, and it could be restored if it's needed again. But it is unused now, so remove it.
* dispatch: add strange mechanism for making worker threads responsivewm42020-03-052-2/+26
| | | | | This is probably a sin for the sake of user experience. See a following commit that wires up f_decoder_wrapper with it.
* bstr: remove unused bstr_splitlines() functionwm42019-12-232-23/+0
|
* misc: add jni helpersAman Gupta2019-11-192-0/+590
|
* Use mp_log2() instead of av_log2()wm42019-10-311-3/+1
|
* Replace uses of FFMIN/MAX with MPMIN/MAXwm42019-10-312-12/+13
| | | | And remove libavutil includes where possible.
* json: write NaN/Infinity float values as stringswm42019-10-251-2/+4
| | | | | | | | | | | | | JSON doesn't support these for some god-awful reason. (JSON would have been so much better if it weren't based on JavaScript, the plague of this world.) We don't really care whether these specific values "round trip", so we might as well write them in a standard-compliant way. Untested. I was too lazy to even run this, but it probably works. See #6691.
* demux: sort filenames naturally when playing a directory / archivePhilip Sequeira2019-09-292-0/+90
|
* rendezvous: fix a typowm42018-08-311-1/+1
|
* player: some further cleanup of the mp_cancel crapwm42018-05-242-30/+23
| | | | | | | | | | Alway give each demuxer its own mp_cancel instance. This makes management of the mp_cancel things much easier. Also, instead of having add/remove functions for mp_cancel slaves, replace them with a simpler to use set_parent function. Remove cancel_and_free_demuxer(), which had mpctx as parameter only to check an assumption. With this commit, demuxers have their own mp_cancel, so add demux_cancel_and_free() which makes use of it.
* thread_pool: add a helper functionwm42018-05-242-10/+30
| | | | | The behavior of mp_thread_pool_queue() doesn't or shouldn't change, but the new helper function requires touching its logic.
* thread_pool: move comments to .h filewm42018-05-242-17/+17
|
* thread_tools: unify mp_cancel POSIX/win32 paths, add featureswm42018-05-242-52/+153
| | | | | | | | | | | | | | | The OS specifics are merged because the resulting ifdeffery is not much worse than the old ifdeffery, but the logic that is now shared is becoming more complex. Create all objects lazily. The intention is to make mp_cancel instances cheaper. POSIX pipes and win32 Events are pretty heavy weight, and are only needed in special situations. Add a mechanism to "chain" mp_cancel instances. Needed by the later commits for whatever reasons. Untested on win32.
* misc: add linked list helperswm42018-05-241-0/+107
| | | | | | | | | | | | | | | | This provides macros for managing intrusive doubly linked lists. There are many ways how to do those in a "generic" way in C. For example Solaris style lists are pretty nice: https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/sys/list.h https://github.com/illumos/illumos-gate/blob/master/usr/src/common/list/list.c I even have an independent implementation of this, which could be ISC licensed. But I think it's easier to vomit ~100 lines of preprocessor garbage, which has a lower footprint, and I think it wins slightly on the side of type safety, simplicity, and ease of use, even if it doesn't look as magically nice.
* thread_tools: minor simplificationwm42018-05-241-3/+1
|
* misc: move mp_cancel from stream.c to thread_tools.cwm42018-05-242-0/+158
| | | | | | | | | | | | It seems a bit inappropriate to have dumped this into stream.c, even if it's roughly speaking its main user. At least it made its way somewhat unfortunately to other components not related to the stream or demuxer layer at all. I'm too greedy to give this weird helper its own file, so dump it into thread_tools.c. Probably a somewhat pointless change.
* json: add some non-standard extensionswm42018-05-241-3/+33
| | | | | Also clarify this and previously existing differences to standard JSON in ipc.rst.
* json: format slightly nicer escape sequenceswm42018-05-241-5/+18
| | | | | | Make use the escape sequences allowed by JSON. Also update the linked RFC to the newest one.
* misc: move some helper code from client.cwm42018-05-242-0/+54
| | | | | (Slightly oddly function names, because I want to avoid starting them with mpv_*, which is reserved for public API.)
* node: move a mpv_node helper from ipc.c to shared codewm42018-05-242-0/+14
| | | | This particular one is needed in a following commit.
* thread_pool: set thread namewm42018-05-241-0/+3
|
* thread_pool: make it slightly less dumbwm42018-05-242-42/+141
| | | | | | | | | | | | The existing thread pool code is the most primitive thread pool possible. That's fine, but one annoying thing was that it used a static number of threads. Make it dynamic, so we don't need to "waste" idle threads. This tries to add threads as needed. If threads are idle for some time, destroy them again until a minimum number of threads is reached. Also change the license to ISC.
* misc: add a synchronization helperwm42018-05-242-0/+101
| | | | | | | | | | | | | | | | | This is almost like rendezvous(), except it allows async wakeup, and does not require global state. It will be used by a later commit. struct mp_waiter is intended to be allocated on the stack, and uses an initializer including PTHREAD_MUTEX_INITIALIZER. This is the first case in mpv that it uses PTHREAD_MUTEX_INITIALIZER for stack-allocated mutexes. It seems POSIX still does not allow this formally, but since POSIX is worth less than used toilet paper, I don't really care. Modern OSes use futexes, which means you can make _every_ memory location a lock, and this code tries to make use of it, without using OS specific code. The name of the source file is rather generic, because I intend to dump further small helpers there (or maybe move mp_rendezvous() to it).
* dispatch: add an assert()wm42018-05-241-0/+1
|
* player: remove in_dispatch fieldwm42018-04-182-8/+30
| | | | (Not sure if worth the trouble, but it does seem less awkward.)
* dispatch: simplify, disallow recursive invocationwm42018-04-181-75/+60
| | | | | | | | | Recursive invocation was needed up until the previous commit. Drop this feature, and simplify the code. It's more logical, and easier to detect miuses of the API. This partially reverts commit 3878a59e. The original reason for it was removed.
* command: use mpv_node helpers instead of duplicated codewm42018-03-261-1/+4
| | | | | | They didn't exist yet when this code was added. Completely untested.
* m_option: pretty print mpv_node for OSDwm42017-10-302-6/+30
| | | | | | Somewhat useful for debugging. Unfortunately libass (or something else) strips leading whitespace, making it look slightly more ugly than necessary. Still an improvement.
* command: change demuxer-cache-state property to return multiple rangeswm42017-10-262-0/+18
| | | | | | | | | | | | | | | | |