1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-26 09:02:38 +00:00
Commit Graph

91 Commits

Author SHA1 Message Date
wm4
739cd61024 input: fix accidental NULL pointer dereference
This could happen if the input queue was full, and an unmapped key was
used, or something like this.

Possibly fixes github issue #224.
2013-09-11 18:32:36 +02:00
Stefano Pigozzi
763f33424e input: convert to new msg API 2013-09-10 21:31:02 +02:00
Stefano Pigozzi
9f01797eac mplayer: remove duplicated mouse autohide check 2013-09-10 21:24:22 +02:00
wm4
fc18c1ba6e mplayer: print libquvi results in verbose mode
Helpful for debugging.
2013-09-10 17:21:59 +02:00
wm4
6a850b0264 quvi: restore playback position when switching formats
This simply issues a seek after reloading.
2013-09-10 16:50:19 +02:00
wm4
cf0e852fcd quvi: coerce libquvi 0.4 support into allowing format switching
libquvi 0.4 doesn't allow us listing the formats supported by a
streaming site without doing additional network accesses, so switching
formats was not supported with it. (It's different with libquvi 0.9.)

But the most important case is switching between SD and HD. Usually,
--quvi-format=default will get SD, while --quvi-format=best gives HD.
Use this, and pretend that an URL supported by libquvi 0.4 supports both
of these. "cycle quvi-format" will switch between these. If the user
specifies something else via --quvi-format, this is included in the list
of switchable formats additionally to "default" and "best".
2013-09-10 16:38:34 +02:00
wm4
328b951019 command: make title property unavailable if there's no support
Instead of returning 0 if the stream doesn't have title info, make the
property unavailable.
2013-09-10 15:39:05 +02:00
wm4
bf71e28d6b mplayer: mentioned --list-options in --help output
It's annoying for users if you can't get a list of options with --help,
but on the other hand, printing all options would be overkill. So just
mentioned --list-options.
2013-09-10 15:19:37 +02:00
wm4
35fd083828 demux: retrieve per-chapter metadata
Retrieve per-chapter metadata, but don't do much with it. We just make
the metadata of the _current_ chapter available as chapter-metadata
property. Returning the full chapter list with metadata would be no
problem, except that the property interface isn't really good with
structured data, so it's not available for now.

Not sure if it's worth it, but it was requested via github issue #201.
2013-09-08 07:43:23 +02:00
wm4
ba07000b88 demux: refactor tag handling
Make the code somewhat reuseable, instead of bound to a single demuxer
instance. The plan is to add support for per-chapter tags later.
2013-09-08 06:32:48 +02:00
wm4
1aae5981a7 core: remove a minor memory leak 2013-09-08 05:17:05 +02:00
wm4
9ec9bff4c1 mplayer: cosmetics: split some code off of run_playloop()
run_playloop() is already stuffed enough. This function is still quite
big, but all the other code shares various variables, so it's not as
easy to split.
2013-09-08 03:04:21 +02:00
wm4
cecbd8864e mplayer: add --cursor-autohide-fs-only option
This option makes the cursor always visible in windowed mode.
Apparently, this is what (some?) Windows and OSX users expect. It's
disabled by default for now.

Restructure the cursor hide logic a bit for this purpose.
2013-09-08 03:03:58 +02:00
wm4
68e331851a options: remove --(no-)mouseinput option
I have no idea why it exists, as it's redundant to --(no-)mouse-movements.
2013-09-08 03:03:58 +02:00
wm4
0509532d70 options: cosmetics: move cursor_autohide_delay definition
No functional changes.
2013-09-08 03:03:58 +02:00
wm4
f1b5198b35 input: rearrange code
Let all key events go through mp_input_feed_key() internally, and also
do double click and MP_INPUT_RELEASE_ALL handling there. Move
check_autorepeat() to where it's actually used.
2013-09-08 01:50:14 +02:00
wm4
ac927e39bf input: don't deliver mouse events if mouse area is not set
This caused the OSC to be always visible at startup on X11:
- EnterNotify event send a mouse event to input.c
- OSC has not completely initialized yet, and no mouse area is set
- mouse event is dispatched to "showhide" OSC section
- OSC becomes visible, regardless of mouse position

Fix this by treating the mouse area as empty if it's not set, instead of
infinite as it was before this commit. This means an input section must
set a mouse area to receive mouse events at all. We also have to change
the default section to receive mouse events with the new behavior.

Also, if MOUSE_MOVE is unmapped (or mapped to something that doesn't
parse), and produces no command, the mouse position wouldn't be updated
(because the mouse position is bound to input commands), so we have to
generate a dummy command in this case.

(This matters only for the OSC, On Screen Controller, which isn't merged
yet, so these changes shouldn't have much effect right now.)
2013-09-08 01:50:14 +02:00
wm4
0a9919fa2e input: merge consecutive mouse move events
Might give better behavior on load.
2013-09-08 01:49:59 +02:00
wm4
681e829793 input: split queue_add() function
Split it into queue_add_head() and queue_add_tail(). Gets rid of the
weird, rarely used boolean parameter.
2013-09-08 01:49:59 +02:00
wm4
6c19067362 input: redo what input events can be dropped
Until now, any command was dropped as soon as the input queue was full,
and the command was not an abort command (i.e. a command that exits the
player or goes to the next file).

This could cause issues with key down events (especially mouse buttons)
not being released.

Change it so that key up events can never be dropped. This is a bit
involved, because we know whether a key maps to an abort command only
after interpreting it, and interpreting it changes global state, which
in turn requires undoing the event if the input is dropped. Refactor
the code a bit to move more functionality into interpret_key() to make
this easier.
2013-09-08 01:49:59 +02:00
wm4
5f00c3cf20 input: remove separation between key and control queue
This is actually quite useless. It also allows the control queue to
starve the key queue, because the control queue is always checked first.
2013-09-08 01:49:57 +02:00
wm4
c7ab8ea513 mplayer: don't auto-load explicitly loaded subtitle files
Even if a subtitle was explicitly loaded with -sub, it was still auto-
loaded (if auto-loading applied to that file). Fix this by explicitly
checking whether a file is already loaded.

The check is maximal naive and just compares the filenames as strings.
The change in find_subfiles.c is so that "-sub something.ass" happens to
work (auto-loading prepended a "./" to it, so the naive filename
comparison check didn't work).
2013-09-07 20:34:49 +02:00
wm4
082ea0de12 mp_core: fix a comment
track.demuxer is never NULL (anymore).
2013-09-07 20:34:49 +02:00
wm4
c4b935adf7 mplayer: remove unused mp_add_subtitles() parameter 2013-09-07 20:34:49 +02:00
wm4
8894a4b0d2 command: make options writeable in idle mode
Until now, options could be accessed as properties via "options/name",
but the access was read-only. Change it so that write access is possible
in --idle mode. (All options have to support setting options at that
time, simply because of the way MPlayer designed per-file options.
During playback, normal properties take care of changing things,
including things backed by options.)

This is work in progress. There are some issues: at least setting the
"vf" and "af" options won't work for strange reasons.
2013-09-07 20:34:49 +02:00
wm4
d77a924434 command: remove some unneeded code
chapter_display_name() always returns something.

The "chapter < -1" check is not needed, because this is done at the
start of the function.
2013-09-07 20:34:49 +02:00
wm4
ae64f29930 options: fix --volume option range, add some explanations to manpage
The --volume option accepted values up to 10000, but internally, the
value is always clipped to 0-100 range. What makes this even worse is
that --softvol-max suggests that it extends the range of --volume, which
is not the case. (And passing a volume larger than 100 to --volume
didn't even print a warning.)
2013-09-07 08:54:12 +02:00
wm4
db79db8444 input: don't print warning if certain internal keys are not bound
This affects MOUSE_MOVE and MOUSE_LEAVE. Both are needed internally
(such as for the OSC), but not really useful for input.conf. Since the
warning has the purpose of notifying the user that a key is unmapped and
what key name to use for setting up a binding in input.conf, the warning
is rather useless in this case. It's also annoying in combination with
the
--no-input-default-bindings option, since that removes the default
bindings to "ignore" for these keys.
2013-09-06 00:45:03 +02:00
wm4
2d369a39dd mplayer: try to resume playback only if a resume file actually exists
Well, this was dumb. The resume message was printed for every file,
whether a resume config file existed or not.
2013-09-05 18:00:30 +02:00
Martin Herkt
5de277e423 mpvcore/input: Fix build without pthreads 2013-09-05 13:04:40 +02:00
wm4
88503a12c2 mplayer: print informative message when resuming playback
In particular, this informs the user how to disable this.
2013-09-04 18:16:47 +02:00
wm4
62ab8441a6 mplayer: make --save-position-on-quit save only on quit
When enabling --save-position-on-quit, playback position stored not only
on quit, but in any case playback of a file was stopped. This includes
going to the next file with playlist navigation commands.

After some discussion on IRC, it turned out that nobody thought this was
good behavior. Disable it, and really make it save only on quit.

Maybe the option is useless now, as the user could remap the CLOSE_WIN
key binding. On the other hand, CLOSE_WIN sounds and _is_ a bit obscure.
2013-09-04 18:12:11 +02:00
wm4
b8d498da15 mplayer: always write playback resume info, even at start/end of file
Before this commit, the player didn't write resume info if the playback
position was within the first or last percent of the file.

This was sometimes annoying, and with playlist resume can lead to
unintuitive behavior. (It wouldn't resume the playlist if the currently
played file was at 0-1% or 99-100%, even if you were in the middle of a
playlist.)

Moreover, the "percent > 99" check is a bit bogus anyway, because 100
(in integer) is rarely reached.

Drop the check, and make sure using --save-position-on-quit won't write
resume info when reaching EOF. The latter check is needed to make sure
playback of the file starts at beginning when playing it again after
EOF.
2013-09-04 17:08:52 +02:00
wm4
191ac00af2 path: better check for mp_is_url()
The previous check just searched for a "://" substring. This was quite
bad, because "://" can be a valid part of a path. Later, I added
special handling for filenames starting with "." and "/", so that you
could reliably pass arbitrary filenames to mpv, no matter how messed
up they were.

Even though it doesn't really matter in practise anymore, this is still
crap, so add a more reliable check instead.
2013-09-04 16:28:02 +02:00
wm4
3bb217d5e9 mplayer: allow resuming from playlist
This includes the case of passing multiple files to command line
(internally this is the same as loading a playlist).

Resuming works by finding the first playlist entry that can be resumed.

Alternative implementations would be possible, such as hashing the
playlist contents. But this implementation is simpler, and doesn't have
the disadvantage that changes to the playlist (like appending entries)
will throw away the resume point.

This makes loading large playlists a bit slower, because it has to look
into ~/.mpv/watch_later/ for every entry. Loading a 15000 entries
playlist now increases from 150ms to 400ms. Considering you rarely load
playlists this big with mpv (because it's impractical considering the
terminal and non-GUI nature of the player), this is probably ok.
2013-09-04 16:15:09 +02:00
wm4
b0f8e03f17 command: unescape URLs for ${filename} and ${media-title}
Undo URL percent encoding if the filename appears to be an URL. This
will fix display of the actual filename in some cases.

We don't put any effort into checking whether the URL is really percent
encoded, because we don't really know how the protocol handler is going
to interpret the URL. For stream_lavf, we probably can't know. Still,
from the perspective of this commit, it seems to make sense to assume
they are percent encoded.
2013-09-04 16:15:09 +02:00
wm4
efc5ac17bf path: add a common mp_is_url() function
Remove the duplicated code.
2013-09-04 16:15:08 +02:00
wm4
ed3187b41a mplayer: handle --reset-on-next-file=""
The option list contains an empty string member with this option value,
so ignore that. I'm not sure whether the option list should maybe be
empty in this case, but it could be the wrong thing in case of other
options.
2013-09-04 00:43:14 +02:00
wm4
7af15f2d6e mplayer: don't let playback resume force options that are file local
This happens by default with pausing: if a file was paused when doing
quit_watch_later, then resume and unpause, then the file played after
that would start in paused mode. This is because the pause option is
backed up at thr wrong place, so it backs up the state from resuming,
instead of whatever it was set to before that.
2013-09-04 00:31:14 +02:00
Stefano Pigozzi
71335183ec mplayer: fix race condition on uninit with Cocoa
NULL out Cocoa's reference to mplayer's input context before deallocating it
2013-09-01 23:03:51 +02:00
Stefano Pigozzi
3e1115569e input: unlock playloop thread during select
This allows other threads to use mp_input_put_key without blocking if the
playloop is doing the 500ms select call (i.e.: during pause).
Makes Cocoa GUI responsive again (regression since 2d363c3).
2013-09-01 22:48:09 +02:00
Stefano Pigozzi
134c3e148c osx: use MP_KEY_* instead of MK_* for media keys
In 213ad5d6c I added `MK_*` key bindings overlooking the fact that mpv already
has `MP_KEY_*` for media keys.
2013-09-01 20:57:40 +02:00
wm4
6a55fa6793 input: allow window dragging even if mouse is in a mouse area
If the input section is enabled with MP_INPUT_ALLOW_VO_DRAGGING, then
the  VO will be allowed to drag the window with mouse button down +
mouse move even if the mouse is inside the section's mouse area.
2013-09-01 20:17:51 +02:00
wm4
0c7978cf9c input: deal with spurious X11 LeaveNotify events
If the mpv window is unfocus, clicking on the OSC should focus the
window (done by the window manager) and allow interaction with the OSC.
But somehow X sends a spurious LeaveNotify event, immediately followed
by an EnterNotify event. This happens at least with IceWM. The result is
that the OSC will disappear (due to receiving MOUSE_LEAVE). The OSC will
stay invisible, because EnterNotify isn't handled, and there's nothing
that could make the OSC appear again.

Solve this by handling EnterNotify. We cause a redundant MOUSE_MOVE
event to be sent, which triggers the code to make the OSC visible. We
have to remove the code from input.c, which ignores redundant mouse move
events.

Since the code ignoring redundant mouse move events is still needed on
Windows, move that code to w32_common.c. The need for this is documented
in the code, also see commit 03fd2fe. (The original idea was to save
some code by having this code in the core, but now it turns out that
this didn't quite work out.)
2013-09-01 20:17:51 +02:00
wm4
11d2f723d5 input: print more debug infos, raise loglevel 2013-09-01 20:17:51 +02:00
wm4
42fa7cbbf9 input: stay in current input section if mouse button is down
Normally, moving the mouse outside of the mouse area of an input section
will send mouse events somewhere else (because input section mouse areas
are similar to windows/widgets in real GUI toolkits). This was done even
if a mouse button was held down. This is quite different from how GUI
toolkits behave.

Change the code so that if a mouse button is down, the mouse area of the
current input section can't be left. Releasing the mouse button (while
the mouse pointer is outside of the mouse area) will actually leave the
mouse area.

As a side-effect, this commit also tests more often whether the current
mouse input section is valid. This is needed to make releasing a mouse
button trigger the mouse input section change.
2013-09-01 20:17:51 +02:00
wm4
61ba810752 input: add some more X11 multimedia/internet keys
These keys can be found on various "multimedia" and "internet" keyboard.
X defines many keycodes, so I'm not adding all, just what I found on my
own keyboard.

Other key codes can be added on request.
2013-09-01 20:17:51 +02:00
wm4
e366c1a9c6 keycodes: cosmetics: align indentation 2013-09-01 20:17:51 +02:00
wm4
ead525e17a input: comment all default bindings in input.conf
I suspect most users will just copy etc/input.conf when they want to
remap some default bindings. But usually this means the user even copies
bindings he doesn't care about, and it's better if the user maps only
the bindings in his input.conf the user intends to remap.

Comment all bindings in etc/input.conf. Since this file also defines the
builtin defaults and is baked into the mpv binary, we have to do
something to get them anyway, even though they are commented. Do this by
having input.c "uncomment" the bindings in the baked in input.conf. (Of
course this is done only for the builtin config, not configs loaded from
disk.)
2013-09-01 20:17:50 +02:00
Stefano Pigozzi
2d363c39b9 input: lock for accessing struct input_ctx
The previous code was locking only the input queue. That was too weak since it
didn't protect the input_ctx data structure. So remove the locking on the queue
and lock all the public functions that interact with the input_ctx.

The private functions and public functions that do not act on the input_ctx
(there are quite some functions doing mp_cmd manipulations for instance) are
not locked.

Some changes by wm4. Use a recursive mutex, and restructure some code to be
less annoying with locks, such as converting code to single return, or
making use of the recursive mutex.
2013-09-01 18:02:45 +02:00