Commit Graph

421 Commits

Author SHA1 Message Date
Kacper Michajłow 4c19df1ded msg: print format string on format errors 2024-09-29 16:06:25 +02:00
Kacper Michajłow 4de6390d25 msg: don't use bold colors and instead use bright ones
Also avoid regular white/black, because it is often the terminal
background and invisible as foreground color.

Change debug messages to blue while at it to differentiate them from
trace ones.
2024-09-14 17:11:07 +02:00
llyyr 92f052c14e playlist: fix setting current item with autocreate-playlist
when the current directory isn't the playlist directory.
2024-08-23 00:56:17 +02:00
Kacper Michajłow e3f426aa4a common/playlist: add missing playlist_dir clear
Fixes: https://github.com/mpv-player/mpv/pull/14555#issuecomment-2282759582
2024-08-11 21:06:13 +02:00
Kacper Michajłow ff1f8baecd common/playlist: add playlist_set_current() 2024-08-10 23:27:40 +02:00
Kacper Michajłow 4f1e9e34c3 demux_playlist: add --directory-filter-types 2024-08-10 23:27:40 +02:00
Kacper Michajłow c54ad6933b demux_playlist: add --autocreate-playlist-{video,audio,image}-exts 2024-08-10 23:27:40 +02:00
Kacper Michajłow 7fb7e1dd73 various: add more format specifiers checks 2024-06-25 05:29:46 +02:00
Dudemanguy 0db6abadd4 playlist: let playlist-next go to first item if player is idle
Similar to the previous commit but the other way around. If you start
mpv as idle, load up a playlist without immediately hitting play and
then try to go to the next item, nothing happens. Naturally, you would
expect this to go to the first item. Fix this detecting if the playlist
has not started yet, the direction, and going to the first item in the
list.
2024-06-25 02:19:08 +00:00
Dudemanguy 0f76848e5f playlist: let playlist-prev go to last item in playlist
Previously, playlist-prev didn't work if you played a playlist to
completion using --idle and tried to go back. Naturally, one would
expect this to bring up the last item in the playlist, but nothing
happens. This is just because playlist_get_next is stupid and doesn't
take this into account since pl->current is NULL and thus returns NULL.
Fix this by considering the direction, checking if the playlist was
played to completion and grabbing the last entry in the index.
2024-06-25 02:19:08 +00:00
Kacper Michajłow 5534e0e1d9 common: validate parsed unicode codepoints value
Fixes UB when converting out of expected range values.

Found by OSS-Fuzz.
2024-06-23 02:33:04 +02:00
Kacper Michajłow e5d85704a3 av_log: sort library version print and add missing libavdevice
Incidentally sorted list put more important libs to the top.
2024-06-22 16:12:14 +02:00
Kacper Michajłow 3c5a79300c various: remove av channel layout check 2024-06-22 16:12:14 +02:00
Kacper Michajłow 00cfe1e1fd common: clang supports __builtin_clz also in non-GNU modes 2024-06-05 19:16:35 +02:00
Dudemanguy f921b64ed7 stream: implement get_protocols method for stream_lavf
Previously, all stream protocols were a static list in mpv. This is okay
for own builtin stuff, but for protocols that depend on ffmpeg it's not
so great. Support for certain protocols may or may not be enabled in a
user's ffmpeg and the protocol list that mpv generates should ideally
match this. Fix this by implementing a get_protocols method for
stream_lavf that will have different results depending on the ffmpeg mpv
is built against. We keep the safe and unsafe protocols separation. The
former is essentially a whitelist. Any protocol that is found in ffmpeg
but is not in the safe whitelist is considered unsafe. In the stream
list, ffmpeg is moved to the bottom so any possible protocols that are
added in the future don't automatically take precedence over any builtin
mpv ones.
2024-05-22 20:10:52 +00:00
Dudemanguy 406301f23d av_common: parent mp_get_lavf_demuxer contents to the list
The only usage of this function is freed in mpv's generic property code,
so no other changes are needed.
2024-05-22 20:10:52 +00:00
Kacper Michajłow a16f653eb5 msg: clear status line only if needed 2024-05-19 19:10:58 +02:00
Kacper Michajłow 895dd9e4e2 msg: split mp_msg_flush_status_line into private and public variant 2024-05-19 19:10:58 +02:00
Kacper Michajłow 243c1d6d91 msg: check target stream before printing
After f18ce7eca0 status is not always
printed to stderr.
2024-05-19 19:10:58 +02:00
Kacper Michajłow 1f7c223749 av_common: fix integer overflow when adjusting timebase
Found by OSS-Fuzz.
2024-05-15 01:25:18 +02:00
Kacper Michajłow f18ce7eca0 msg: print all messages to one stream
This reverts commit 4939570e17 and makes
it more strict about the output stream. Status message is also on the
same stream now.
2024-05-06 22:21:46 +02:00
Kacper Michajłow 414c47d1d8 player/main: select msg output stream early
This avoids printing any stray messages in encode output stream.

--o is already pre-parse cli option which is designed to be parsed
before anything else is printed to output. So we can use that to force
stderr output if needed for encode mode.
2024-05-06 22:21:46 +02:00
Kacper Michajłow 9fc2343512 osdep/mpv.rc: fix encoding of MPVCOPYRIGHT
llvm-rc doesn't allow multi-byte codes in narrow utf-8.
2024-05-06 22:01:17 +02:00
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