Commit Graph

167 Commits

Author SHA1 Message Date
Kacper Michajłow 4b11f66eb1 various: use avcodec_get_supported_config() to resolve deprecation warn
See: 3305767560
2024-11-20 20:42:33 +01:00
Kacper Michajłow 0c4c2caabf misc/codepoint_width: assume tabstop width to be 8
It has been hardcoded to the same value in stats.lua so keep the current
behaviour. Can be made configurable if requested in the future.
2024-10-21 20:06:48 +02:00
Kacper Michajłow 5fed98e0ee various: use mp_tprintf_buf wrapper to work around mingw garbage
Look it up if you really care but basically z as a format specifier
often doesn't work in mingw because reasons. Our CI was working by
accident because of meson previously ignoring the CFLAGS variable. Use
our wrapper instead for these places.
2024-10-18 14:02:51 +00:00
Kacper Michajłow bf025cd289 msg: allow to truncate the message to terminal width 2024-10-11 15:16:33 +02:00
Kacper Michajłow 95f0046309 misc/codepoint_width: add unicode width detection support
Add 4 stage trie to lookup unicode codepoint width and grapheme join
rules.

Generated by GraphemeTableGen from Microsoft Terminal (MIT Licence):
a7e47b711a/src/tools/GraphemeTableGen/Program.cs

With minor adjustment to use it in C codebase.
- Replaced constexpr with static
- Replaced auto with explicit types

Generated from Unicode 16.0.0:
ucd.nounihan.grouped.xml: sha256(b11c2d23673bae660fff8ddcd3c1de4d54bdf6c60188a07696b010282f515fcf)
2024-10-11 15:06:14 +02:00
Kacper Michajłow 216abbc121 bstr: add missing function docs 2024-10-04 00:45:30 +02:00
Kacper Michajłow 96006fa97b bstr: don't abort on format error in bstr_xappend_vasprintf
Most of the time it is recoverable error, and it makes no sense to
abort here.
2024-09-29 16:06:25 +02:00
Kacper Michajłow 2c2755992d bstr: use vsnprintf with a proper size of 0 instead of a 1-sized buffer
There is no need for that, use of 0 size is well defined.
2024-09-29 16:06:25 +02:00
Andreas Klauer c365e2f7b1 misc/random: seed using libavutil/random_seed
When starting multiple processes of `mpv --shuffle` in parallel,
sometimes the random seed happens to be identical, so files are
played in the same random order.

mp_rand_seed(0) now uses a random seed provided by libavutil,
and only falls back to time in case of failure.
2024-09-28 14:11:56 +02:00
Kacper Michajłow 7746942a55 win32: remove pathcch compatibility code
No longer needed after 9f8b4b38c9.
2024-09-24 00:21:19 +02:00
Kacper Michajłow ad7976c33e input: fix use of bstr like null terminated one
It has been changed in one of the iterations of the patch during review,
but bstr doesn't have to be null terminated. Fix it by adding dedicated
node_map helper.

Fixes: 1a27f3c
2024-09-04 03:52:09 +02:00
Kacper Michajłow 5fed12e025 win32: add Media Control support
Add support for SystemMediaTransportControls interface. This allows to
control mpv from Windows media control ui.
2024-07-29 21:38:19 +02:00
Kacper Michajłow 607ad8943b player/command: don't return ill-formed node if there is no default val
option-info/<name>/default-value would be initialized with zeroed
object, which is not valid for string typed options, as the would be set
to NULL.

Found by OSS-Fuzz.
2024-07-16 22:59:23 +02:00
nanahi ea03451d1e misc/natural_sort: avoid implementation-defined behavior in comparison
Before a7158ceec0, string comparision was
done with strcmp, which does unsigned comparison. The natural sort
implementation instead compares on char values.
This causes implementation-defined behavior in comparison, depending on
the signedness of char type.

Fix this by using unsigned comparison instead.
2024-06-27 19:45:21 +03:00
Kacper Michajłow 22fc2e6af3 bstr: change memcpy to memmove to allow aliased copies
mp_property_expand_escaped_string() needs this.

Found by OSS-Fuzz.
2024-06-26 01:28:55 +02:00
Kacper Michajłow 7fb7e1dd73 various: add more format specifiers checks 2024-06-25 05:29:46 +02:00
Kacper Michajłow a949e0c2d5 misc/random: set constant seed for fuzzing
Fuzzing expect deterministic behavior. While we don't use this random
generator for anything significant, still good to set the seed, in case
of future usage.
2024-06-24 03:05:09 +02:00
Kacper Michajłow 0d8f74231f misc/uuid: remove no longer needed vendored implementation 2024-06-22 16:12:14 +02:00
Kacper Michajłow a8d95fd51a bstr: use memchr and memrchr for bstrchr and bstrrchr
May be faster to use optimized variants instead of simple loop.
2024-06-06 21:42:58 +02:00
Kacper Michajłow 7258ca3247 misc/thread_tools: fix incorrect win32 check 2024-06-05 19:16:35 +02:00
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