Commit Graph

625 Commits

Author SHA1 Message Date
wm4 0a78a61d89 input: add a prefix to make any binding act on key repeat
The fact that it's a generic command prefix that is parsed even when
using the client API is a bit unclean (because this flag makes sense
for actual key-bindings only), but it's less code this way.
2014-11-20 23:41:01 +01:00
wm4 2d039e691f command: add drop_buffers
This command was actually requested on IRC ages ago, but I forgot about
it.

The main purpose is that the decoding state can be reset without issuing
a seek, in particular in situations where you can't seek.

This restarts decoding from the middle of the packet stream; since it
discards the packet buffer intentionally, and the decoder will typically
not output "incomplete" frames until it has recovered, it can skip a
large amount of data.

It doesn't clear the byte stream cache - I'm not sure if it should.
2014-11-20 22:41:50 +01:00
wm4 534b08e6ba command: add an ab_loop command
As suggested in #1241; to make using the feature easier.

Also add better OSD-formatting for the ab-loop-a/b properties.
2014-11-18 21:34:57 +01:00
wm4 c920a3920e ipc: make sure --input-file=/dev/stdin always works
It's not necessarily available on Unix systems other than Linux (sigh).
2014-11-07 09:50:29 +01:00
wm4 dbc41ea3bb ipc: make it possible to receive log messages
The receiving part was implemented, but since no messages are enabled
by default, it couldn't be used.
2014-11-01 15:45:41 +01:00
wm4 de59b87609 ipc: add a command to retrieve API version 2014-11-01 15:45:41 +01:00
wm4 a1e7daf942 ipc: verify resume/suspend commands
Calling mpv_resume() too often is considered an API usage violation,
and will trigger an internal assertion somewhere.
2014-11-01 15:45:40 +01:00
wm4 75afef6463 command: don't require whitespace before ';' or '#'
This change is probably too simplistic, but most things appear to work,
so I don't care about that now.

Fixes #1232.
2014-10-31 23:56:17 +01:00
wm4 fb4d26e769 input: cascade-load input.conf
If there are several input.confs in the set of valid config paths, load
them all.
2014-10-29 22:54:03 +01:00
wm4 d5b081152a audio: add command/function to reload audio output
Anticipated use: simple solution for dealing with audio APIs which
request configuration changes via events.
2014-10-27 11:52:42 +01:00
wm4 b330f16fed input: resolve ~ and similar for --input-file
Because why not.
2014-10-24 21:28:07 +02:00
wm4 986d15ea9c command: fix debug output
It was a bit ugly/annoying.
2014-10-24 13:42:02 +02:00
wm4 dd77f0d37e command: print executed commands with -v 2014-10-23 15:13:05 +02:00
wm4 7e27663b7b command: add a "cached" mode to sub_add
This avoids reloading a subtitle if it was already added. In all cases,
the subtitle is selected.
2014-10-23 13:13:23 +02:00
wm4 0e4658c99c command: make trailing sub_add actually optional
This was always intended. Also fixes subtitle-file drag & drop.
2014-10-22 07:58:38 +02:00
wm4 131633b4e5 command: extend sub_add command 2014-10-21 00:15:04 +02:00
wm4 9ba6641879 Set thread name for debugging
Especially with other components (libavcodec, OSX stuff), the thread
list can get quite populated. Setting the thread name helps when
debugging.

Since this is not portable, we check the OS variants in waf configure.
old-configure just gets a special-case for glibc, since doing a full
check here would probably be a waste of effort.
2014-10-19 23:48:40 +02:00
wm4 d089772b69 ipc: skip empty and commented lines 2014-10-19 22:34:37 +02:00
wm4 cf627fd3de ipc: accept both JSON and "old" commands
Minimizes the differences between --input-file and --input-unix-socket.
2014-10-19 22:34:37 +02:00
wm4 f8f0098560 ipc: fix minor error cleanup issues
The ipc_thread can exit any time, and will free the mp_ipc_ctx when
doing this, leaving a dangling pointer. This was somewhat handled in the
original commit by setting mpctx->ipc_ctx to NULL when the thread
exited, but that was still a race condition.

Handle it by freeing most things after joining the ipc_thread. This
means some resources will not be freed until player exit, but that
should be ok (it's an exceptional error situation).

Also, actually close the pipe FDs in mp_init_ipc() on another error
path.
2014-10-19 21:04:38 +02:00
wm4 f4c589418c ipc: decouple from MPContext
Just a minor refactor to keep unneeded dependencies on the core low.
2014-10-19 20:44:29 +02:00
wm4 70cc42655d ipc: fix a small memory leak 2014-10-17 22:31:14 +02:00
Alessandro Ghedini 3deb6c3d4f input: implement --input-file on unix using the IPC support 2014-10-17 20:47:43 +02:00
Alessandro Ghedini 13039414f5 input: implement JSON-based IPC protocol 2014-10-17 20:46:31 +02:00
wm4 0a7a70f198 input: don't add weird padding when formatting keycode
No idea what this was for. It has no purpose and looks weird.
2014-10-17 00:53:55 +02:00
wm4 8e4fa5fcd1 command: add a mechanism to allow scripts to intercept file loads
A vague idea to get something similar what libquvi did.

Undocumented because it might change a lot, or even be removed. To give
an idea what it does, a Lua script could do the following:

--                      type       ID priority
mp.commandv("hook_add", "on_load", 0, 0)
mp.register_script_message("hook_run", function(param, param2)
    -- param is "0", the user-chosen ID from the hook_add command
    -- param2 is the magic value that has to be passed to finish
    -- the hook
    mp.resume_all()
    -- do something, maybe set options that are reset on end:
    mp.set_property("file-local-options/name", "value")
    -- or change the URL that's being opened:
    local url = mp.get_property("stream-open-filename")
    mp.set_property("stream-open-filename", url .. ".png")
    -- let the player (or the next script) continue
    mp.commandv("hook_ack", param2)
end)
2014-10-16 01:00:22 +02:00
wm4 e970113932 input: remove some unneeded code 2014-10-10 23:05:33 +02:00
wm4 d0f77b5615 input: cosmetics: move code 2014-10-10 23:01:00 +02:00
wm4 c9f45ea93e input: use mpv_node parser for char** command parsers
Minor simplification, also drops some useless stuff.
2014-10-10 22:58:28 +02:00
wm4 63903c27bd input: add a function to parse mpv_node as command
For future client API enhancements.
2014-10-10 22:37:11 +02:00
Stefano Pigozzi dba2b90d9a libmpv/cocoa: don't start the event monitor
The event monitor is used to get keyboard events when there is no window, but
since it is a global monitor to the current process, we don't want it in a
library setting.
2014-10-09 22:14:41 +02:00
wm4 e294656cb1 client API: rename --input-x11-keyboard to --input-vo-keyboard
Apparently we need this for Cocoa too. (The option was X11 specific in
the hope that only X11 would need this hack.)
2014-10-09 18:28:37 +02:00
wm4 3273db1ef7 client API, X11: change default keyboard input handling again
Commit 64b7811c tried to do the "right thing" with respect to whether
keyboard input should be enabled or not. It turns out that X11 does
something stupid by design. All modern toolkits work around this native
X11 behavior, but embedding breaks these workarounds.

The only way to handle this correctly is the XEmbed protocol. It needs
to be supported by the toolkit, and probably also some mpv support. But
Qt has inconsistent support for it. In Qt 4, a X11 specific embedding
widget was needed. Qt 5.0 doesn't support it at all. Qt 5.1 apparently
supports it via QWindow, but if it really does, I couldn't get it to
work.

So add a hack instead. The new --input-x11-keyboard option controls
whether mpv should enable keyboard input on the X11 window or not. In
the command line player, it's enabled by default, but in libmpv it's
disabled.

This hack has the same problem as all previous embedding had: move the
mouse outside of the window, and you don't get keyboard input anymore.
Likewise, mpv will steal all keyboard input from the parent application
as long as the mouse is inside of the mpv window.

Also see issue #1090.
2014-09-28 20:11:00 +02:00
wm4 cbf7180c90 input: copy options automatically
Originally, all options were copied to ensure that input_ctx remins
thread-safe, even if options are changed asynchronously. But this got
a bit inconsistent. Copy them automatically and reduce some weirdness.
2014-09-27 16:25:29 +02:00
wm4 b4d1494336 input: separate creation and loading of config
Until now, creating the input_ctx was delayed until the command line
and config files were parsed. Separate creation and loading so that
input_ctx is available from start.

This should make it possible to simplify some things. For example,
some complications with Cocoa were apparently only because input_ctx
was available only "later". (Although I'm not sure if this is still
relevant, or if the Cocoa code should even be organized this way.)
2014-09-27 16:01:55 +02:00
wm4 5e6c9963d8 input: explain why we use semaphores
Also switch function names for better self-documentation.
2014-09-20 04:22:37 +02:00
Alexander Preisinger 30175538fe input: add locking for repeat info 2014-09-19 17:48:06 +02:00
Alexander Preisinger be516022b6 input: add function for setting repeat info
Let us set a different rate and delay.

Needed for the following commit where we set rate and delay reported by weston.
But only if the option native-keyrepeat is set.
2014-09-19 17:36:37 +02:00
wm4 e0b4daf3ad input: use libwaio for pipe input on Windows
Use libwaio to read from pipes (stdin or named pipes) on Windows. This
liberates us from nasty issues, such as pipes (as created by most
programs) not being possible to read in a non-blocking or event-driven
way. Although it would be possible to do that in a somewhat sane way
on Vista+, it's still not easy, and on XP it's especially hard. libwaio
handles these things for us.

Move pipe.c to pipe-unix.c, and remove Windows specific things. Also
adjust the input.c code to make this work cleanly.
2014-09-14 16:24:01 +02:00
wm4 08116feec7 input: fix nested commands
Regression from today.
2014-09-13 18:41:34 +02:00
wm4 893f4a0fee input: distinguish playlist navigation and quit commands for abort
Refine the ugly hack from the previous commit, and let the "quit"
command and some others abort playback immediately. For
playlist_next/playlist_prev, still use the old hack, because we can't
know if they would stop playback or not.
2014-09-13 16:47:30 +02:00
wm4 2e91d44e20 stream: redo playback abort handling
This mechanism originates from MPlayer's way of dealing with blocking
network, but it's still useful. On opening and closing, mpv waits for
network synchronously, and also some obscure commands and use-cases can
lead to such blocking. In these situations, the stream is asynchronously
forced to stop by "interrupting" it.

The old design interrupting I/O was a bit broken: polling with a
callback, instead of actively interrupting it. Change the direction of
this. There is no callback anymore, and the player calls
mp_cancel_trigger() to force the stream to return.

libavformat (via stream_lavf.c) has the old broken design, and fixing it
would require fixing libavformat, which won't happen so quickly. So we
have to keep that part. But everything above the stream layer is
prepared for a better design, and more sophisticated methods than
mp_cancel_test() could be easily introduced.

There's still one problem: commands are still run in the central
playback loop, which we assume can block on I/O in the worst case.
That's not a problem yet, because we simply mark some commands as being
able to stop playback of the current file ("quit" etc.), so input.c
could abort playback as soon as such a command is queued. But there are
also commands abort playback only conditionally, and the logic for that
is in the playback core and thus "unreachable". For example,
"playlist_next" aborts playback only if there's a next file. We don't
want it to always abort playback.

As a quite ugly hack, abort playback only if at least 2 abort commands
are queued - this pretty much happens only if the core is frozen and
doesn't react to input.
2014-09-13 16:09:51 +02:00
wm4 2dd819705d input: "quit_watch_later" and "stop" are abort commands
This means they get special handling for asynchronously aborting
playback, even if the player is "stuck".

Also document "stop". It seems somewhat useful for client API users
(although that will be implemented properly only in the following
commits.)
2014-09-13 14:10:10 +02:00
wm4 b0a3d38b4c input: don't autorepeat cycle_values command
Not sure why this was originally added as autorepeated. It makes no
sense, because switching between choices should never autorepeat. (For
the normal "add"/"cycle" commands, autorepeat is usually enabled, but
command.c tries to disable it specifically for choice properties.)
2014-09-13 01:14:07 +02:00
wm4 a3b393d68c input: simplify
Just some minor things. In particular, don't call mp_input_wakeup()
manually, but make it part of queuing commands (as far as possible).
2014-09-13 01:14:07 +02:00
wm4 fc5df2b970 input: fix autorepeat
Mismatching units in timeout calculation.

Also, as a near-cosmetic change, explicitly wake up the core on the
right time. Currently this does nothing, because the core is woken up
anyway - but it will matter with the next commit.
2014-09-13 01:14:07 +02:00
wm4 e9b756c7ad input: remove central select() call
This is now unused. Get rid of it and all surrounding infrastructure,
and replace the remaining "wakeup pipe" with a semaphore.
2014-09-10 03:24:45 +02:00
wm4 ae63702a2c input: remove useless joystick.h/lirc.h include files
These really just waste space.
2014-09-10 00:51:36 +02:00
wm4 e2a093df02 input: use an input thread for joystick 2014-09-10 00:48:59 +02:00
wm4 fe0ca7559c input: use an input thread for lirc 2014-09-10 00:48:45 +02:00