Commit Graph

2953 Commits

Author SHA1 Message Date
Avi Halachmi (:avih) 007c728ad2 command: cycle: respect the prefix "repeatable"
The "cycle" command _declaration_ enables repeatability by default,
however, the command handler applies additional logic to augment it,
based on the property which is being cycled - using some guesswork.

Specifically, properties with discrete values are not repeatable
(like sub or osd-level), while continuous properties are repeatable
(like volume).

Previously, the "repeatable" prefix could not override this additional
logic.

This commit changes the behavior so that the logic affects only the
default repeatability (still based on the property like before),
however, the "repeatable" prefix is now allowed to override it.
2021-08-19 15:39:19 +03:00
Stefan de Konink 0c9e1e34fd stats.lua: typo lavfi-complex
Fix typo lavi-complex to lavfi-complex.
2021-08-15 12:27:40 +03:00
Guido Cella d8e5f6ff3a sub: show subs without duration on vid change
When changing video track with subtitles with unknown duration, they
aren't shown until you seek, cycle sub back and forth, or apply a video
filter. This is caused by reinit_video_chain_src() calling
reset_subtitle_state() -> sub/sd_ass.c:reset() -> ass_flush_events()
when ctx->duration_unknown is true.

The ass_flush_events() call was added in a714f8e so subs with unknown
duration wouldn't multiply on seek, i.e. when reset_subtitle_state() is
called from reset_playback_state(). So keep calling it from there, and
in reinit_video_chain_src() use just term_osd_set_subs(mpctx, NULL)
instead to clear any subtitles printed to the terminal. The
reset_subtitle_state() call was added in c1ac97b to "reset the state
correctly when switching between video/no-video", but with it removed I
no longer notice any issue doing that.
2021-08-13 17:16:43 +00:00
Guido Cella b6ebd1a15e sub: align ytdl-hook secondary subs to the top
29e15e6248 prefixed youtube-dl's subs url with an edl prefix to not
download them until they're selected, which is useful when there are
many sub languages. But this prefix broke the alignment of secondary
subs, which would overlap the primary subs instead of always being
placed at the top. This can be tested with
--sub-file='edl://!no_clip;!delay_open,media_type=sub;secondary_sub.srt'

When a sub is added, sub.c:reinit_sub() is called. This calls in
init_subdec() -> dec_sub.c:sub_create() -> init_decoder() ->
sd_ass:init(). Then reinit_sub() calls
sub_control(track->d_sub, SD_CTRL_SET_TOP, &(bool){!!order}) which sets
sd_ass_priv.on_top = true for secondary subs.

But for EDL subs the real sub is initialized again when in
dec_sub.c:sub_read_packets() is_new_segment() returns true and
update_segment() is called, or when sub_get_bitmaps() calls
update_segment(). update_segment() then calls init_decoder(), which
calls sd_ass:init(), so sd_ass_priv is reinitialized, and its on_top
property is left false. This commit sets it to true again.

For URLs that need to be downloaded it seems that the update_segment()
call that reinitializes sd_ass_priv is always the one in
sub_read_packets(), but with local subs sub_get_bitmaps() is usually
called earlier (though there shouldn't be a reason to use the EDL URL
for local subs), so I added the order parameter to sub_create(), rather
than adding it to all of update_segment(), sub_read_packets() and
sub_get_bitmaps().

Also removes the cast to bool in the other sub_control call, since
sub/sd_ass.c:control already casts arg to bool when cmd is
SD_CTRL_SET_TOP.
2021-08-11 18:15:35 +00:00
Avi Halachmi (:avih) 8a597a484b lua: read_options: quote values at error messages
This makes it easier to understand the error in cases of incorrect
syntax or formatting at .conf files. (js already has this quoting).

Fixes #9105
2021-08-10 11:00:18 +03:00
Dudemanguy 02323a184f command: check for monitor par in window-scale
When performing the scaling calculations, the window scale properties do
not bother checking for potential monitor par. The vo keeps track of
this via vo->monitor_par. Simply multiply/divide the video's width or
height depending on the value of monitor_par. We also clamp the values
to avoid the values running away to infinity in extreme cases.
2021-08-09 16:33:39 +00:00
Dudemanguy 9dc0857b3d command: check for rotation in window-scale
The vo currently handles rotations in 90 degree steps and some VOs set
this via VO_CAP_ROTATE90. When the rotation exactly hits either 90 or
270 degrees, this causes the values of dwidth and dheight to perfectly
swap like one would expect. However, the mp_image_params_get_dsize
function call in both of the window scale functions do not take this
special case into account. So the width/height values returned will be
incorrectly flipped in the 90 and 270 degree cases if the vo driver does
implement VO_CAP_ROTATE90 (like vo=gpu). Fortunately, the
mp_image_params struct keeps track of the rotation for us. So all we
need to do is check if the image is rotated at 90 or 270 degrees and
check that the current vo driver supports VO_CAP_ROTATE90. If so, then
swap vid_w and vid_h to their true, correct values.
2021-08-09 16:33:39 +00:00
Dudemanguy 77f2fd97f8 command: merge window-scale code together
Based on a small patch originally written by @avih. Instead of
duplicating the window-scale logic in update_window_scale, just call the
mp_property_current_window_scale function with the M_PROPERTY_SET action
and a NULL property.
2021-08-09 16:33:39 +00:00
Dudemanguy a0441ddb5e command: make current-window-scale writeable, 2nd attempt
The window-scale property mirrors the respective option (not the
effective scale derived from the current window size), and as such
setting its value to the same value it had before has no effect.
Specifically - the window will not resize.

This is consistent as far as property-option bridge behavior goes,
but we do end up with an issue that we can't set an arbitrary scale
and expect the window to always resize accordingly.

We do also have a current-window-scale property which does reflect
the actual window size, however, it's been read-only till now.

This commit makes current-window-scale RW so that it's now always
possible to set an arbitrary scale and expect the window to resize
accordingly (without affecting window-scale - like manual resize).

Also, mention window-scale no-effect-if-not-changed at the docs.

Based on code by @Dudemanguy from commit 873ae0d, with same effect.
2021-08-07 17:30:19 +03:00
Avi Halachmi (:avih) 2667dd6643 Revert "command: make current-window-scale writeable"
This reverts commit 873ae0de2a.

The next commit will restore this functionality, with the
following differences from the reverted commit:
- Smaller and simpler code change.
- On bad scale: use "Invalid value" (compared to "no such property").
- Doesn't combine the docs for window-scale and current-window-scale.
- Doesn't remove the docs for window-scale behavior prior to 0.31.0.
2021-08-07 17:30:19 +03:00
Guido Cella 7eb34d2376 stats.lua: page 4 (keys): group current-window-scale under window
This groups "set current-window-scale ..." under the "window" group
instead of "current" in the list of keybindings.
2021-08-06 10:29:28 +03:00
Dudemanguy 873ae0de2a command: make current-window-scale writeable
Somewhat confusingly, mpv has both a window-scale option and a
current-window-scale property. The documentation lists window-scale
under properties (and it is technically is one), but at its core it is
actually an option which means it behaves subtly different. Options in
mpv are runtime-configurable, but they only change anything if the value
of the option itself changes. window-scale is an option and not meant to
keep track of the actual scale of the window (intended behavior
introduced by d07b7f0). This causes window-scale to do nothing in
certain cases (ex: the window is manually resized and window-scale is
set to 1.00 again). This is logical and consistent with the behavior of
the rest of the mpv options, but it also makes it a poor candidate for
setting the mpv window scale dynamically.

As a remedy, we can just make current-window-scale writeable instead.
current-window-scale is intended to always report the actual scale of
the window and keep track of any window size changes made by the user.
By making this property also writeable, it allows the user to have more
intuitive behavior (i.e. setting current-window-scale to 1.00 always
sets the window to a scale of 1). Additionally, the default input.conf
is changed to use current-window-scale instead of window-scale. The
window-scale documentation under property list is removed since it is
already documented under options and users should probably set the
current-window-scale property instead in most cases.
2021-08-05 19:13:10 +00:00
Avi Halachmi (:avih) 416668d3c8 stats.lua: page 4 (keys): better alignment of non-ascii keys
Previously we assumed the key-name string occupies strlen(name) cells,
now we count codepoints instead.

This improves alignment of non-english key names. Still not perfect
because we don't know if the key name is single or double width, but
wcwidth not available to scripts, notoriously unreliable (depends on
locale, correct and updated tables, etc), and also not always
available (Windows).

Still, better than nothing, and we err by at most one cell - vs up to
three before this commit (4 bytes keyname codepoint).

In the future we could do the alignment using libass tags, however,
this both complicates the ass-output generation, and also not available
when we output for the terminal, so for now only count codepoints.

Also, if the key name was in a right-to-left language, then previously
the name/command were swapped visually. Now we inject a left-to-right
marker before the name to ensure direction. This works also when
harfbuzz is disabled for libass (--sub-ass-shaper=simple).
2021-07-31 11:00:07 +03:00
Dudemanguy 6857600c47 player: eac3 to the whitelist of audio extensions
ffmpeg plays these just fine. Fixes #9065.
2021-07-30 08:20:22 -05:00
Avi Halachmi (:avih) 8b1930fbd6 stats.lua: page 4 (keys): detect single-quotes 2021-07-30 09:52:34 +03:00
Guido Cella 3f0e8bd506 options: audio-display determines cover priority
Let audio-display determine whether embedded images or external cover
art tracks should be selected when both are present.

Attached pictures are given priority by default as requested in #8539.

Also updates references to attached pictures in the log and manpage to
refer to cover art as well.

Closes #8539.
2021-07-29 13:38:28 +00:00
Guido Cella bcf6077b28 command: handle changes to image-display-duration
When changing image-display-duration at runtime, make the new value take
effect immediately, rather than from the next playlist-position change.
This allows toggling the slideshow mode while viewing images (without
hacks like executing playlist-play-index current afterwards).

All the conditions are just to be safe since even if you set time_frame
while playing a video, it's immediately overwritten by the next value.
2021-07-25 15:32:41 +00:00
Avi Halachmi (:avih) 955736b7b7 stats.lua: fix ass-escape while persistent_overlay=yes
mpv has two methods to display output from text input:
- show-text (scripting: mp.osd_message) has ass disabled by default
  (escaped), and the property osd-ass-cc can control escaping.
- osd-overlay (scripting: mp.set_osd_ass or mp.create_osd_overlay)
  has ass enabled (unescaped), and osd-ass-cc is NOT supported.

By default, stats.lua uses mp.osd_message which does support escaping.
That's persistent_overlay=no.

When using persistent_overlay=yes then mp.set_osd_ass is used.

Due to this, the no_ASS(..) function - which is supposed to escape
ass, simply returned its input unmodified when persistent_overlay
is enabled.

This is not a new issue, and the filters on page 1 use no_ASS() to no
avail in persistent mode, however, this content (filter name and value
strings) rarely actually needs escaping, and users didn't notice.

However, the new page 4 (keys) does break visibly when no_ASS doesn't
work, because it tries to escape arbitrary key-names and command
strings, and at the very least the key '{' is bound by default, which
is displayed incorrectly if escaping doesn't work.

Fix this by rolling our own escaping when using mp.set_osd_ass,
similar to how the mpv code does it for mp.osd_message (substrings
replacements).

However, this means that the set_ASS(..) function can no longer
behave correctly because escaping requires going through the whole
content string rather than only inserting a marker.

Luckily, other than at no_ASS, set_ASS was only used at one place
(text_style), which is only called from two places:
- generate_graph() only needs to restore styles - not to enable ass.
- add_header() is only used at the begining of page output, and
  uses set_ASS to enable ass initially when using mp.osd_message.

So remove the set_ASS function, and instead enable ass directly at
print_page using osd-ass-cc when mp.osd_message is used.

Fixes #9022
2021-07-25 15:08:44 +03:00
Avi Halachmi (:avih) 5ed0338eea js: fix tiny leaks if js_try throws(!)
As it turns out, js_try can throw if it runs out of try-stack
(without/before entering either the try part or the catch part).

If it happens, then C code which does allocation -> try will leak.

In mpv there were two places which do alloc and then try, one of
them as part of the autofree system. On both cases the leak is the
smallest possible (zero allocation) - talloc_new(NULL);

It's very unlikely to trigger - an autofree mpv API should be called
when the try-stack is exactly full, and our next try will throw
(and guaranteed to get caught at an outer level, but with a leak).

Fix that by doing the allocation inside the try block, so that if
try throws before it's entered then nothing got allocated/leaked.

Mujs internal code also has/had similar leaks, which are getting
fixed around this time (July 2021, post mujs 1.1.3).

[1] exhaust the try-stack or call-stack, whichever comes first:
      function kaboom() { try { kaboom() } catch(e) {} }
2021-07-23 17:50:24 +03:00
Avi Halachmi (:avih) 7f4841ff39 js: key bindings: ensure priorities for same-key bindings
Previously, if a script bound the same key more than once to different
functions (without removing the older bindings first), then pressing
the key triggered any of the bound functions arbitrarily[1].

Now the newest binding for the same key is always the active one.

If the newest binding is then removed - the second-newest will become
active, etc. (same mechanism as before, except that the active key
was not always the newest).

[1] The order was implementation-defined, however `for (name in obj)'
    happens to iterate. With mujs that's currently alhabetic order,
    and name is from mp.add_[forced_]key_binding(key, name...)
    or generated internally if name is not provided. So a binding with
    higher alphabetic `name' value had priority over lower name value.
2021-07-21 17:29:11 +03:00
Guido Cella 1d1d1fbff9 options: add watch-later-options
This allows configuring which options are saved by quit-watch-later.

Fixes #4126, #4641 and #5567.

Toggling a video or audio filter twice would treat the option as changed
because the backup value is NULL, and the current value of vf/af is a
list with one empty item, so obj_settings_list_equal had to be changed.
2021-07-21 13:19:28 +00:00
Guido Cella ccb87ad637 stats.lua: remove script-opts for the main keys (i/I)
Unlike the page switching/scrolling keys which are bound at runtime
and therefore we need to know which (configured) keys to bind, the
main keys (i/I by default) are static and can be bound via input.conf.
And indeed, the builtin bindings at etc/input.conf have them already.
2021-07-21 13:55:58 +03:00
Avi Halachmi (:avih) 70c9d8d5d7 stats.lua: page 4 (keys): fix "excluding stats keys" - attempt 2
Page 4 bindings listing wants to exclude the interactive keys of the
stats script itself - so that they don't hide the normal keys which
are bound when stats is not interactive.

It did so by testing that the bound command includes stats/__key
which is how it usually looks when a script binds keys.

However, if a script uses a name for the binding - like stats.lua does
for the interative keys (because it later removes them by name when
interactive mode ends), then the command has stats/name rather than
stats/__key...

To fix this, we change the names of the forced interactive bindings
to start with __forced_, and that's now also what the page-4 listing
excludes.
2021-07-20 01:00:03 +03:00
Avi Halachmi (:avih) 1e1b5a6e14 Revert "stats.lua: page 4 (keys): fix "excluding stats keys""
This reverts commit 0f1654811bda0dfdd337734ec33c59b67522234a.

It was an incorrect fix, because the key names do get used - to remove
the forced bindings once stats exits the interactive mode.

And without names - the interactive keys remained active even after
stats exited interactive mode.
2021-07-20 01:00:03 +03:00
Avi Halachmi (:avih) fab25ac004 stats.lua: page 4 (keys): fix "excluding stats keys"
The page 4 keybinding list tries to skip the interactive bindings of
stats itself (because they would hide the normal bindings of these
keys when stats is not visible), and to do that it excludes commands
containing "script-binding stats/__key" - which is how script-added
bindings usually look like.

However, keys which are added with a "name" bind stats/name rather
than stats/__key... - and that's what stats.lua did till now with its
interactive force-bindings.

Now the interactive forced bindings are added without a name, and so
they do end up using the automatic stats/__key... and get excluded.
2021-07-20 00:13:35 +03:00
Avi Halachmi (:avih) 2335ee5514 stats.lua: page 4 (keys): support help-like terminal printout
While --input-test is useful, and so is page 4 of stats, until now
there was no way to simply print the list in a help-like fashion.

This commit adds such printout, invoked by the script opt
stats-bindlist=yes, which uses the existing page 4 code. This prints
the list on startup and quits immediately - like any help page.

It's awkward to invoke compared to other help pages, and it does
require the stats page to be enabled (it is by default), however
it is a script-generated output, and currently there's no other
method to print a help page generated by a script.

The printout itself is performed using lua's io.write. While reliable,
it's not the standard way for mpv to print to the terminal.

Other possible printout methods are mp.msg.info - which also prints
"[stats]" prefix on each line (ugly), or forcing term-osd and setting
an osd-message which mpv will then print at the terminal - however
that's printed to stderr, and could also be subject to timing concerns
since we quit right afterwards.

In the future we can consider changing/integrating the invocation so
that mpv itself could print a help page generated by a script, thus
solving both the awkward invocation and printout-method issues.
2021-07-19 22:06:50 +03:00
Avi Halachmi (:avih) 9fb200b641 stats.lua: add page 4: active key-bindings list
This is a scrollable page which also works nicely with the terminal
OSD. Typically there are more than 100 bound keys.

It groups the binding using fuzzy property/command/script name after
simple analysis of the command string, and then further sorts the
binding in each group according to the "complexity" of the key itself
(plain keys -> keys with modifiers, alphabetically, etc).

The alignment/grouping style is heavily inspired by @medhefgo's #8924
but otherwise it's an independent implementation.
2021-07-19 22:06:50 +03:00
Avi Halachmi (:avih) 59c10274b4 stats.lua: scroll: allow throttling page-rebuild (no-op)
Typically the current page is rebuilt and rendered once per second,
howeve, scrolling can invoke the rebuild function very frequently,
even at a rate which is too fast for the rebuild function to keep
up. This can result in high CPU usage and input lag.

This commit adds an argument to the page-rebuild function, letting it
know whether or not it's called following a scroll keypress, thus
allowing it to cache intermediate data so that it doesn't have to
re-calculate the whole page from scratch.

This additional argument is unused currently, but it could be useful
for the internal performance page - which can be relatively heavy.
2021-07-19 22:06:50 +03:00
Avi Halachmi (:avih) 50280197e2 stats.lua: move internal performance from page 4 to page 0
This allows adding more pages without the internal performance page
getting stuck at the middle of the list.
2021-07-19 22:06:50 +03:00
sfan5 3e28c8e983 player: fix missed pause state update during reset in some cases
When playing a new file, if paused_for_cache was true before being reset
the AO would never be unpaused because that state was thrown away, leaving it stuck.
Fix this by updating the pause state before resetting that variable. Note that this
does not make the second update_internal_pause_state() call redundant.
This fixes the same bug fb5d976cb0 was supposed to.
2021-07-18 12:22:55 +02:00
Shreesh Adiga be81470f54 audio: check ao driver init failure to avoid use after free
reinit_audio_filters_and_output function will free mpctx->ao_chain
when there is a failure during audio initialization. So modify it
to return -1 in case of init failure. The return value is checked
to avoid use after free. Reported by Address Sanitizer when manually
specifying --ao which triggers "Failed to initialize audio driver" error.
2021-07-13 15:16:59 +00:00
Avi Halachmi (:avih) d828652f24 lua: fix timers comment (no-op)
process_timers() doesn't return an absolute time. It returned delta>0
or nil before f73814b1 , and since f73814b1 it can also return 0.
2021-07-13 13:11:34 +03:00
Ripose c4f982637f command: adds support for secondary subs to sub-seek and sub-step
Modifies the sub-seek and sub-step commands with a second <flags>
argument to specify whether to seek/step on the primary or secondary
subtitles. The flag is used to index into the current_track array in
cmd_sub_step_seek.
2021-07-12 21:07:37 +00:00
Ripose 34cfe9d89b command: add secondary-sub-start and secondary-sub-end properties
Adds secondary-sub-start and secondary-sub-end properties by setting
the current_track index in the m_property's priv variable which later
gets accessed in get_times. Also adds a test of the secondary subtitle
time properties in tests/subtimes.js bound to 'T'.
2021-07-12 21:07:37 +00:00
TheAMM 4d3df1c842 recorder: add support for attachments (fonts)
Though, only when the output format is matroska, to avoid muxing errors.
This is quite useful when the input has ASS subtitles, as they tend to
rely on embedded fonts.
2021-07-08 12:44:06 +03:00
Guido Cella b3fccf0803 player: add append-play flag to loadlist
Closes #5664.
2021-07-06 15:46:45 +00:00
Avi Halachmi (:avih) d2dd4cacb8 osc: expose osc-visibility via shared-script-properties
osc-visibility can already be changed at runtime via script-message
or other means, but until now there was no way to tell what the
current state is.

Now shared-script-properties/osc-visibility reflects this state.
It's output-only by the osc - changing it does not affect the osc.

Useful if a script wants to change osc-visibility temporarily, and
later restore to its original state.

There's no way to coordinate if more than one script wants to change
it, but that would be a hard problem to solve anyway, even if the
osc itself tried to coordinate such requests from different sources.
2021-07-06 16:12:36 +03:00
rcombs 0c1544e66c sub: fix subs/lyrics on music files with sub-past-video-end=no
Regressed in 11423acf3
2021-06-27 21:02:39 -04:00
Dudemanguy 76a53f9de3 stats.lua: add scaled resolution
Calculate the actual scaled size of the video from osd-dimensions and
display it on the stats page.
2021-06-25 17:54:36 +00:00
Guido Cella 5e23e81485 player: fix property name
Commits 4d1ffec and 6e481d0 renamed sub-ass-style-override to
sub-ass-override. But in commit bd603c2, when renaming it in
quit-watch-later's backup_properties, which determines which properties
are saved by quit-watch-later/write-watch-later-config, it was
incorrectly renamed to sub-style-override instead, and thus never got
saved even if modified at runtime. Instead mpv attempted to save the
non-existing property "sub-style-override", but since no error is raised
when saving non-existing properties with quit-watch-later, no one
noticed it. This commit renames the saved property to the correct new
name "sub-ass-override" so that it does get saved.
2021-06-24 12:01:22 +03:00
Avi Halachmi (:avih) 5b40db385a lua: idle observers: ensure timers are up-to-date
This fixes two issues, both of which resulted from the timers-wait
period not being re-calculated after idle-observers were executed:

- If timers were added from an idle observer then they could fire long
  after they were due (only when/if the next mpv event arrives).

- Idle observers don't execute in zero time, and the wait period for
  the next timer was implicitly extended by the idle observers
  execution time (because it was calculated before the idle observers).

This commit ensures that if idle-observers were executed, then the
timers wait period is re-calculated, which solves both issues.
2021-06-23 23:47:08 +03:00
Avi Halachmi (:avih) f73814b180 lua: timers: don't block forever with slow callbacks
Previously, process_timers() kept going as long as there were due
timers, which could be for extended periods of time or even forever
if there were slow timer callbacks with either periodic timers or if
timers were added repeatedly.

This prevented dequeuing mpv events, and subsequently, among others,
prevented mpv from quitting until process_timers() completed.

For instance, this caused process_timers() to never return:

  function render() <longer than 1/60 s on a slow system> end
  mp.add_periodic_timer(1/60, render)

Similarly, it never returned if a timer callback always added a new
one-shot which was already due by the time the callback completed.

This commit ensures that process_timers() only executes callbacks which
were due when it started, so that timers which are added (or repeated)
during process_timers() will wait for the next iteration - after mpv
events are dequeued.

This has no performance impact under normal conditions (when callbacks
complete before the next timer is due).

Additionally, previously idle-observers were executed unconditionally
after the timers because indeed there was nothing due when (if...)
process_timers() completed. However, now process_timers() can return
even if there are due timers, so skip idle-observers on such case.
2021-06-23 23:47:08 +03:00
rcombs 11423acf30 sub: by default, don't render timestamps after video EOF
This fixes a long-standing apparent issue where mpv would display the last
frame with no subtitles at EOF. This is caused by sub rendering switching from
video timestamps to audio timestamps when the video ends, and audio streams
often running past the timestamp of the last video frame. However, authoring
tools (most notably Aegisub) don't tend to provide easy ways to add meaningful
subtitles after the end of the video, so this is rarely actually useful.
2021-06-23 16:10:29 -04:00
Guido Cella cb56c2f888 player: change cover-art-auto behavior
This makes cover-art-auto behave more like sub-auto and audio-file-auto:

- load cover art with a language, e.g. if playing foo.mp3, foo.en.jpg
will be loaded with lang=en
- load cover art containing the media filename with fuzzy and all, e.g.
'foo (large).jpg'
- make all/2 load all images in the directory, and make fuzzy/1 the
default

These are all uncommon use cases, but synchronizing the behavior of the
external file options simplifies the code.
2021-06-23 16:23:50 +00:00
Avi Halachmi (:avih) 0427fe97e1 js: idle-observers: minor performance improvement
The idle-observers block has at least 3 function calls, and it was
entered every time the script went into idle, however, we can save these
calls by checking first that there are indeed such observers.
2021-06-22 18:17:11 +03:00
Avi Halachmi (:avih) 76b1ac57a4 osc: seekbar hover/drag: display target chapter at the title
Fixes #8925
2021-06-22 18:12:29 +03:00
Guido Cella 9eb126a798 player: remove unnecessary check
Remove the check that the external filename is not the same as the
currently playing one, which prevents mpv from loading images again as
external cover art, but this isn't necessary because cover art is only
added when playing standalone audio. I had only added this check because
I would otherwise get a segfault only when compiling with gcc 10.2 with
optimize and changing position within a playlist of multiple images (and
this couldn't even be reproduced by Dudemanguy on the same gcc version),
but this was caused by the uninitialized lang variable which is now
fixed.
2021-06-21 15:36:30 +00:00
Guido Cella f70995cc9b player: fix segfault
Commit 029ff10 added a goto statement which skipped initializing the
`lang' variable. This could crash depending on compiler optimizations
and other factors: if the lang bstr pointer happened to end up NULL
(which is apparently the case with most compilers) then it's validly
empty, but if it pointed to a random and incorrect memory address then
it crashed.

The crash was observed when mpv was compiled using gcc 10.2 with
optimizations enabled, and affected some third party Windows builds.

This commit ensures the goto doesn't skip the initialization.

Thanks to votemp for figuring this out.

Fixes #8922.
2021-06-21 15:36:30 +00:00
Avi Halachmi (:avih) 48f3a26746 osc: ensure tick after any mouse-event
Previously tick() was ensured unconditionally only after mouse-move,
but there are other mouse-events which need re-rendering (tick), like
mouse-down (icons may get grayed-out) or mouse-up (icons may change).

For instance: mpv --pause --myclip.mkv

then move the mouse over the volume/mute OSC button, then - without
moving the mouse - press and release the left mouse button.

The osc was not re-rendered because it's paused and the mouse didn't
move, so the volume icon didn't get grayed-out when held down, and the
icon doesn't change on mouse-up (to reflect the new mute state).

Now both these changes are rendered correctly.
2021-06-20 17:37:47 +03:00
Avi Halachmi (:avih) 89efe820a8 osc: don't initialize while mouse-down over an element
This is not a new issue, however, until the last commit - 96b246d
init probably didn't happen much (or at all) between mouse-down and
mouse-up, but after this commit, if there are chapters in a live-stream
then osc_init() is used to re-render the markers at the adjusted
position - which breaks the OSC buttons functionality if init happened
between mouse-down and mouse-up.
2021-06-20 17:37:47 +03:00