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

398 Commits

Author SHA1 Message Date
Kacper Michajłow
ed7fe505b4 common: define some bits for Windows SDK 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
a569c3ce0c player/command: add track-list/N/decoder 2024-04-18 01:20:32 +02:00
Kacper Michajłow
e720159f72 player/command: add video-codec-info and audio-codec-info
Adds support for extracting codec profile. Old properties are redirected
to new one and removed from docs. Likely will stay like that forever as
there is no reason to remove them.

As a effect of unification of properties between audio and video,
video-codec will now print codec (format) descriptive name, not decoder
long name as it were before. In practice this change fixes what docs
says. If you really need decoder name, use the `track-list/N/decoder-desc`.
2024-04-15 19:34:40 +02:00
Kacper Michajłow
9030e6a7ad msg: use fwrite
No need to recalc string length.
2024-04-13 18:23:16 +02:00
Kacper Michajłow
f53e941ba0 msg: use defines for hide/restore cursor code 2024-04-13 18:23:16 +02:00
Kacper Michajłow
247ef82a76 msg: don't keep status line in partial
Noticed while looking at this code, we shouldn't append status line to
partial when !print_term.
2024-04-13 13:37:21 +02:00
Kacper Michajłow
8708f4dc91 m_property: add > for fixed precision floating-point expansion
This enhancement makes it easier to create constant width property
expansions, useful for the `--term-status-msg`. Additionally, it changes
to `%f` printing with manual zero trimming, which is easier to control
than `%g`. With this method, we can directly specify precision, not just
significant numbers. This approach also avoids overly high precision for
values less than 1, which is not necessary for a generic floating-point
print function.

A new print helper function is added, which can be used with adjusted
precision for specific cases where a different default is needed. This
also unifies the code slightly.
2024-03-21 03:50:11 +01:00
Kacper Michajłow
0deefd80bf msg: clear buffered status_line on flush
It shouldn't be used after flush anymore.
2024-03-21 01:47:15 +01:00
Kacper Michajłow
17a0756ed3 msg: simplify the line_skip calculation
Make it more straightforward by always calculating top offset first
instead of having two branches, that tries to calc it directly.

This also fixes missing negative check before `\033[%dA` which was in
practice only problem on macOS which was handling negative values, while
in fact it shouldn't.

Fixes: #13484
2024-03-21 01:47:15 +01:00
nanahi
18bd03d31a common/msg: fix warning: void function should not return void expression 2024-03-19 08:58:18 +01:00
nanahi
98ab8d87a1 common/msg: fix warning: use of non-standard escape character '\e' 2024-03-19 08:58:18 +01:00
David Vaughan
c678033c1d input/player: add loadfile/loadlist insert-at command 2024-02-26 02:03:21 +00:00
David Vaughan
da753196af player: change insert_next to insert_at
Change the `playlist_insert_next` function to `playlist_insert_at` (ie,
insert at the location of an entry, rather than after it, and rename to
be clearer that it doesn't have anything to do with the
currently-playing entry).

Also, replace calls to `playlist_add` with calls to
`playlist_insert_at`, since the former has become redundant.
2024-02-26 02:03:21 +00:00
David Vaughan
9e162d2604 player: add loadfile insert-next commands
This commit adds two new commands (`insert-next` and `insert-next-play`)
which mirror the existing commands, `append` and `append-play` in
functionality, with the difference that they insert directly after the
current playlist entry, rather than at the end of the playlist.

This change gives MPV a piece of functionality already found in (for
example) Spotify's media player: "play next". Additionally, using the
new `insert-next` command, users can trivially write a script to play a
new piece of media immediately without otherwise clearing or altering
the remainder of the playlist.
2024-02-26 02:03:21 +00:00
llyyr
4a563a6390 encode_lavc: don't use deprecated avcodec_close
Deprecated upstream 1cc24d7495
2024-02-19 18:09:58 +01:00
sfan5
dcf8adf289 common: don't force terminal log buffer to small size
Using the 'terminal-default' log level a client can request
to get all messages that would normally appear on the terminal.

8c2d73f112 changed the size of the
relevant buffer to 100 lines, which was prone to quickly overflowing
once you enable verbose or debug output.
This size is kept for the early terminal buffer but now enlarged
once a client actually requests this log level. This fixes the overflow
risk while not consuming more resources if this feature is unused.
2024-01-27 10:04:16 +01:00
nanahi
c08e626578 version.h.in: bump copyright year 2024-01-27 10:00:36 +01:00
Guido Cella
25bef997ce msg: reset status_lines when setting --really-quiet
This prevents mp_msg_flush_status_line() from printing an unnecessary
newline when changing file after setting --really-quiet at runtime. If
mpv is backgrounded, this newline garbles the output of TUI programs.

With this change the cursor is not re-enabled after setting
--really-quiet at runtime and quitting with mpv in the foreground, so
enable it on uninit.
2024-01-21 17:54:21 +00:00
llyyr
8fe2af09f1 common: stream: don't mention Libav in errors/warnings 2024-01-20 16:10:20 +00:00
Kacper Michajłow
13ed292ab0 terminal: don't print escape sequence if not tty 2024-01-15 10:39:42 +01:00
Kacper Michajłow
485221ba22 msg: return zero length if bstr_split_utf8 fails
In theory bstr_split_utf8 should skip invalid sequence and move further,
but it doesn't do that currently, so just the string if unsuported code if
found.

Fixes infinite loop on code.len == 0 condition.

Fixes: 5864b72d1a
2024-01-10 00:31:57 +01:00
Kacper Michajłow
5864b72d1a msg: improve term_disp_width to support unicode
All characters are assumed to be single-width. This is consistent with
the rest of the code and documentation.

Fixes: #13150
2024-01-04 13:41:06 +00:00
Kacper Michajłow
1306ea9854 msg: reduce nesting in mp_msg_flush_status_line
Cosmetic change only.
2023-12-27 20:59:22 +00:00
Kacper Michajłow
cadb68487e msg: keep status line on the end of file
Apparently found useful by some users.

Fixes: #13092
2023-12-27 20:59:22 +00:00
Kacper Michajłow
a44f0e574d common/av_log: do not assume AVClass.item_name is always set
After recent change in FFmpeg it is not longer safe to call item_name.

Ref: 0c6203c97a
2023-12-24 12:50:24 +01:00
Dudemanguy
6d1383383b playlist: correctly populate playlist-path with the --playlist option
When using the --playlist option on the commandline, it would mark all
entries on the command as having the playlist-path of the value of that
passed option, not just the ones that were expanded from it. Fix this by
moving the playlist_populate_playlist_path to the same place where the
playlist file gets expanded.

Ref https://github.com/mpv-player/mpv/issues/13075#issuecomment-1852179164
2023-12-13 15:25:14 +00:00
Kacper Michajłow
2bcdf591fd common/av_log: use bstr for log callback
- don't use 4KiB stack array
- keep one bstr allocation for lifetime of the log
- avoid dummy strlen
2023-11-28 10:46:16 +01:00
Jan Palus
8efa6c3837 build: restrict git describe to top level source directory
fix version determination when building mpv from release tarball
extracted within another git repository
2023-11-27 15:22:22 +00:00
Kacper Michajłow
7d7276e384 common/msg: remove redundant check
It is already strcmp above, so cannot be NULL.
2023-11-18 23:55:28 +00:00
Kacper Michajłow
82451bdf04 msg: ensure status line is always visible
Restore last status line if it has been cleared by another message.
2023-11-08 21:55:08 +00:00
Kacper Michajłow
5c3faf71e8 msg: factor out print code
Will be useful for next commit.
2023-11-08 21:55:08 +00:00
Kacper Michajłow
773f72e6c6 msg: convert dump_stats to bstr 2023-11-08 21:55:08 +00:00
Kacper Michajłow
0853c719f1 msg: use bstr for partial msg 2023-11-08 21:55:08 +00:00
Kacper Michajłow
2fdb1d31ae msg: check isatty separately per each stream 2023-11-08 21:55:08 +00:00
Kacper Michajłow
24270b8587 msg: refactor how terminal messages are printed
- prepare string before printing
- reduce amount of fflush(), especially for multiline messages
- clear status line and keep it always at the bottom
- indent module name to the longest value
- disable cursor for status line
- properly support wrapped status line

Overall makes status line less flickering and remove stray status
instead of scrolling them up.
2023-11-08 21:55:08 +00:00
Kacper Michajłow
d0b8472e5a msg: don't mix partial log messages, with unrelated log levels 2023-11-08 21:55:08 +00:00
Kacper Michajłow
56d35da180 mp_thread: add win32 implementation 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
Kacper Michajłow
cb829879af mp_threads: rename threads for consistent naming across all of them
I'd like some names to be more descriptive, but to work with 15 chars
limit we have to make some sacrifice.

Also because of the limit, remove the `mpv/` prefix and prioritize
actuall thread name.
2023-10-27 23:18:56 +00:00
NRK
8bbcc87fee timer: remove MP_START_TIME
instead require mp_raw_time_ns() to not return 0, which all current
implementation already should follow.
2023-10-27 18:07:19 +00:00
Kacper Michajłow
29e677fea5 msg: make mp_msg_find_level case insensitive 2023-10-27 18:07:08 +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
Niklas Haas
50cd363c01 video/mp_image: handle non-power-of-two alignment
Needed for odd formats like rgb24.
2023-10-19 18:26:05 +02:00
Niklas Haas
d67b0022aa common: add mp_lcm helper 2023-10-19 18:26:05 +02:00
Claude Heiland-Allen
a6d1c9dd0f common/tags: add mp_tags_move_from_av_dictionary()
Abstracts a common pattern,
in which the av dictionary is cleared
immediately after copying to mp tags,
so that additional tags later in the stream
get appended to empty tags,
instead of being appended to existing tags
that were already copied.
2023-10-18 16:52:47 +02:00