0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 20:03:10 +02:00
Commit Graph

147 Commits

Author SHA1 Message Date
Guido Cella
20b8fe05bf misc/language: move mp_guess_lang_from_filename() here 2024-05-10 01:22:31 +02:00
Kacper Michajłow
4fe67933c2 misc/language: store string length instead of null terminator
Allows to construct bstr directly without strlen, while keeping language
table the same size.
2024-05-09 17:12:55 +02:00
Kacper Michajłow
5009e13431 player/loadfile: match language and subcodes 2024-05-09 17:12:55 +02:00
Kacper Michajłow
40ba63405f Revert "misc: add language-matching utilities"
This reverts commit 8c8d97c26c.
2024-05-09 17:12:55 +02:00
nanahi
9f5edd4eed various: fix indentation 2024-05-07 11:23:08 +02:00
Kacper Michajłow
86abbb89a7 win32: fix platform checks 2024-05-06 22:01:17 +02:00
Kacper Michajłow
5c2918b4f3 io_utils: use mp_mkostemps instead of mkstemp 2024-05-06 22:01:17 +02:00
Kacper Michajłow
fffe723fc4 various: move strings.h inclusion to common.h 2024-05-06 22:01:17 +02:00
Kacper Michajłow
18ef834ef4 various: move unistd.h inclusion to common.h 2024-05-06 22:01:17 +02:00
Kacper Michajłow
053d971507 misc/path_utils: normalize win32 paths 2024-05-05 19:37:57 +02:00
Guido Cella
1d640c9887 player: normalize paths for resuming playback
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.
2024-05-05 19:37:57 +02:00
Kacper Michajłow
d3941f235a bstr: change bstr0_s to bstr0_lit, restrict it only for string literals
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>
2024-04-08 02:06:06 +02:00
Kacper Michajłow
fbc5e47e00 misc/bstr: add bstr0_s for static initialization 2024-04-07 20:23:04 +02:00
Kacper Michajłow
2ee0db4c5d misc/bstr: add bstr_to_wchar for win32
Convenience to avoid strlen above other things.
2024-03-19 19:58:09 +01:00
sfan5
d955dfab29 misc/jni: reduce duplication in mapping struct
'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.
2024-02-28 16:11:54 +01:00
sfan5
5b1eaf3ff1 misc/jni: introduce macros for deleting references 2024-02-28 16:11:54 +01:00
sfan5
75ae44472b misc/jni: general code cleanup and refactor
Make it align with mpv's coding conventions in general and avoid unecessary Lavu use.
2024-02-28 16:11:54 +01:00
nanahi
4e73602ae5 options/path: move path utility functions to misc/path_utils
These utility functions have nothing to do with user and config dir/file.
Move them to a separate file.
2024-02-23 21:35:57 +01:00
nanahi
84015959cc osdep/io: move I/O utility functions to misc/io_utils
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.
2024-02-23 21:35:57 +01:00
nanahi
71598ca07e various: replace dead links in comments
Replace various dead links with live replacements or archives.
Less friction for anyone who wants to look up these references.
2024-02-11 04:01:24 +00:00
Kacper Michajłow
076be24853 timer: remove unnecesary time conversions 2023-11-05 17:36:17 +00:00
Kacper Michajłow
55ed50ba90 mp_thread: prefer tracking threads with id
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.
2023-11-05 17:36:17 +00:00
Kacper Michajłow
174df99ffa ALL: use new mp_thread abstraction 2023-11-05 17:36:17 +00:00
NRK
d05ef7fdc4 various: sort some standard headers
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.
2023-10-20 21:31:09 +02:00
NRK
450a69b1d6 various: remove ATOMIC_VAR_INIT
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
2023-10-20 21:31:09 +02:00
NRK
2070331f64 osdep: remove atomic.h
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.
2023-10-20 21:31:09 +02:00
Kacper Michajłow
500eb3940d thread_tools: suppress -Wstringop-overflow false-positive 2023-10-19 14:03:23 +00:00
Kacper Michajłow
f0b2854e93 charset_conv: suppress unused-label warning 2023-10-19 14:03:23 +00:00
Dudemanguy
9ac0085031 dispatch: change mp_dispatch_queue_process timer to nanoseconds
The playloop is the only thing that adjusts the timeout with a value
other than 0, so nothing else needs to be changed.
2023-10-16 15:38:59 +00:00
Dudemanguy
da4f11803f demux: change the default of metadata-codepage to auto
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).
2023-10-07 02:41:27 +00:00
Dudemanguy
a96dd2f5e7 charset_conv: remove ancient warning about deprecated syntax
wm4 removed this in 4adfde5dd1 and left a
warning. Nobody needs to know that enca:pl used to work.
2023-10-07 02:41:27 +00:00
Kacper Michajłow
40e0fea6eb timer: rename mp_add_timeout to reflect what it actually does 2023-09-29 20:48:58 +00:00
Kacper Michajłow
da4c4d2ebd timer: rename mp_time_us_to_timespec to reflect what it actually does 2023-09-29 20:48:58 +00:00
llyyr
27f0a35c53 various: add missing include in header flles
Mostly cosmetic
2023-09-21 14:40:11 +00:00
Philip Langdale
fb5273985c meson: include our local copy of libavutil uuid if ffmpeg is too old
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.
2023-09-04 15:22:20 -07:00
Philip Langdale
64bb9c092a misc: add copy of uuid from ffmpeg
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.
2023-09-04 15:22:20 -07:00
cvzi
f5eb7ea1a9 json: unify json_parse depth to MAX_JSON_DEPTH=50 2023-07-08 11:36:15 +02:00
rcombs
57dae8f42c osdep: add mp_get_user_langs 2023-06-25 11:01:58 +02:00
rcombs
8c8d97c26c misc: add language-matching utilities 2023-06-25 11:01:58 +02:00
low-batt
6d208d38d2 charset_conv: fix memory corruption in mp_iconv_to_utf8
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
2023-04-29 01:37:41 +00:00
Alexander Seiler
bdf7b5c3b8 various: fix various typos in the code base
Signed-off-by: Alexander Seiler <seileralex@gmail.com>
2023-03-28 19:29:44 +00:00
rcombs
3b2b47e32a misc/node: add bstr-based variants for map_get() and map_add() 2023-01-28 14:20:20 -06:00
rcombs
fa7202d9f2 misc/json: don't wrap top-level pretty strings/infs in quotes
This makes pretty-printing nodes substantially more friendly.
2023-01-28 14:20:20 -06:00
sfan5
1201d59f0b various: replace abort() with MP_ASSERT_UNREACHABLE() where appropriate
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.
2023-01-12 22:02:07 +01:00
Leo Izen
52e7269ea6 misc/random: add xoshiro random number implementation
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.
2022-08-17 10:21:55 -04:00
Niklas Haas
8bd0dee531 osdep: rename MP_UNREACHABLE
It was pointed out on IRC that the name is misleading, since the actual
semantics of the macro is to assert first.
2021-11-03 15:15:20 +01:00
Niklas Haas
c704824b45 osdep: add MP_UNREACHABLE
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.
2021-11-03 14:09:27 +01:00
wm4
654eef9b82 ring: remove this
The code is OK, and it could be restored if it's needed again. But it is
unused now, so remove it.
2020-08-29 13:12:32 +02:00
wm4
50177aaa3b dispatch: add strange mechanism for making worker threads responsive
This is probably a sin for the sake of user experience. See a following
commit that wires up f_decoder_wrapper with it.
2020-03-05 22:00:50 +01:00
wm4
ba45b67370 bstr: remove unused bstr_splitlines() function 2019-12-23 11:01:56 +01:00