Commit Graph

39366 Commits

Author SHA1 Message Date
wm4 131633b4e5 command: extend sub_add command 2014-10-21 00:15:04 +02:00
wm4 b79f291f4b command: remove hook cancellation mechanism
I doubt anyone will actually use this correctly. Also, there was a bug
(a typo) which prevented it from working at all.
2014-10-20 23:43:10 +02:00
wm4 a67be5dd05 command: allow sub_add at an earlier stage 2014-10-20 23:33:46 +02:00
wm4 d38e36b98f osdep: shorten thread name on glibc only
Instead of affecting every platform, do this for glibc only (where it's
known to be a problem), and only if the right error is returned.
2014-10-20 21:50:49 +02:00
Ben Boeckel c918b8a3f3 manpage: fix a typo 2014-10-20 00:23:55 +02:00
wm4 600221e723 osdep: limit thread names to 16 characters
It turns out the glibc people are very clever and return an error if the
thread name exceeds the maximum supported kernel length, instead of
truncating the name. So everyone has to hardcode the currently allowed
Linux kernel name length limit, even if it gets extended later.

Also the Lua script filenames could get too long; use the client name
instead.

Another strange thing is that on Linux, unrelated threads "inherit" the
name by the thread they were created. This leads to random thread names,
because there's not necessarily a strong relation between these threads
(e.g. script command leads to filter recreation -> the filter's threads
are tagged with the script's thread name). Unfortunate.
2014-10-20 00:17:11 +02:00
wm4 1aae992585 stream: stupid compilation workaround for win32
On win32, open() is a function-like macro. The line of code changed
with this commit accidentally expanded the macro. Prevent this macro
expansion. Not sure why that happened now. Since as far as I remember
system functions can be defined as macros, this affects in theory not
only win32.
2014-10-19 23:49:42 +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 c6dca55665 manpage: ipc: mention unavailability on Windows
Windows doesn't have unix domain sockets, and can't handle sockets and
pipes in an uniform way. Only the libwaio fallback code is available,
which doesn't do JSON.
2014-10-19 22:35:45 +02:00
wm4 2f559ac70b player: shutdown all clients before actual uninit
This seems safer. It might be possible that commands sent by the clients
could recreate e.g. audio or video outputs.
2014-10-19 22:34:37 +02:00
wm4 2cd25891b6 manpage: ipc: mention the socat tool
This is not realy obvious, so I assume this is a helpful hint.

Although the usefulness of such an approach is probably influenced by
the fact that the player might send events that arrive in the short
window while the socket is connected.
2014-10-19 22:34:37 +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 c854ce934e audio: quote devices in --audio-device=help
The output is a bit confusing. Quoting the device name probably helps a
little bit; also add minimal explanations to the manpage.
2014-10-19 16:36:38 +02:00
Stefano Pigozzi 7e66a35969 fix build on OS X and BSD 2014-10-19 12:55:29 +02:00
ChrisK2 78151efc7e Merge pull request #1195 from kevmitch/luafix
lua: fix lua_objlen -> lua_rawlen for lua 5.2
2014-10-19 08:10:10 +02:00
Kevin Mitchell 60ed674fce lua: fix lua_objlen -> lua_rawlen for lua 5.2 2014-10-18 22:37:46 -07:00
wm4 ff029cb4cf lua: strictly free memory on errors
Thanks to the recently introduced mp_lua_PITA(), this is "simple" now.
It fixes leaks on Lua errors. The hack to avoid stack overflows
manually isn't needed anymore, and the Lua error handler will take
care of this.
2014-10-19 05:51:37 +02:00
wm4 5548c75e55 lua: expose JSON parser
The JSON parser was introduced for the IPC protocol, but I guess it's
useful here too.

The motivation for this commit is the same as with 8e4fa5fc (again).
2014-10-19 05:51:37 +02:00
wm4 987146362e lua: add an utility function for starting processes
Because 1) Lua is terrible, and 2) popen() is terrible. Unfortunately,
since Unix is also terrible, this turned out more complicated than I
hoped. As a consequence and to avoid that this code has to be maintained
forever, add a disclaimer that any function in Lua's utils module can
disappear any time. The complexity seems a bit ridiculous, especially
for a feature so far removed from actual video playback, so if it turns
out that we don't really need this function, it will be dropped again.

The motivation for this commit is the same as with 8e4fa5fc.

Note that there is an "#ifndef __GLIBC__". The GNU people are very
special people and thought it'd be convenient to actually declare
"environ", even though the POSIX people, which are also very special
people, state that no header declares this and that the user has to
declare this manually. Since the GNU people overtook the Unix world with
their very clever "embrace, extend, extinguish" strategy, but not 100%,
and trying to build without _GNU_SOURCE is hopeless; but since there
might be Unix environments which support _GNU_SOURCE features partially,
this means that in practice "environ" will be randomly declared or not
declared by system headers. Also, gcc was written by very clever people
too, and prints a warning if an external variable is declared twice (I
didn't check, but I suppose redeclaring is legal C, and not even the gcc
people are clever enough to only warn against a definitely not legal C
construct, although sometimes they do this), ...and since we at mpv hate
compiler warnings, we seek to silence them all. Adding a configure test
just for a warning seems too radical, so we special-case this against
__GLIBC__, which is hopefully not defined on other libcs, especially not
libcs which don't implement all aspects of _GNU_SOURCE, and redefine
"environ" on systems even if the headers define it already (because they
support _GNU_SOURCE - as I mentioned before, the clever GNU people wrote
software THAT portable that other libcs just gave up and implemented
parts of _GNU_SOURCE, although probably not all), which means that
compiling mpv will print a warning about "environ" being redefined, but
at least this won't happen on my system, so all is fine. However, should
someone complain about this warning, I will force whoever complained
about this warning to read this ENTIRE commit message, and if possible,
will also force them to eat a printed-out copy of the GNU Manifesto, and
if that is not enough, maybe this person could even be forced to
convince the very clever POSIX people of not doing crap like this:
having the user to manually declare somewhat central symbols - but I
doubt it's possible, because the POSIX people are too far gone and only
care about maintaining compatibility with old versions of AIX and HP-UX.

Oh, also, this code contains some subtle and obvious issues, but writing
about this is not fun.
2014-10-19 05:51:37 +02:00
wm4 0328fa2252 command: add "estimated-vf-fps" change notifcation 2014-10-19 05:51:37 +02:00
wm4 daab65693c lua: add a helper to auto-free temporary C memory
Using the Lua API is a big PITA because it uses longjmp() error
handling. That is, a Lua API function could any time raise an error and
longjmp() to a lower part of the stack. This kind of "exception
handling" is completely foreign to C, and there are no proper ways to
clean up the "skipped" stack frames.

Other than avoiding such situations entirely, the only way to deal with
this is using Lua "userdata", which is basically a malloc'ed data block
managed by the Lua GC, and which can have a destructor function
associated (__gc metamethod).

This requires an awful lot of code (because the Lua API is just so
terrible), so I avoided this utnil now. But it looks like this will make
some of the following commits much easier, so here we go.
2014-10-19 05:51:25 +02:00
wm4 76af31b0eb win32: remove an unneeded mechanism
Instead of relying on the macro-defined lseek(), just use _lseeki64
directly, and avoid a minor mess.
2014-10-19 05:51:25 +02:00
wm4 2458f0628e win32: remove outdated comment 2014-10-19 05:51:24 +02:00
Stefano Pigozzi fa904150bf cocoa: reintroduce async resize
After removing synchronous libdispatch calls, this looks like it doesn't
deadlock anymore. I also experimented with pthread_mutex_trylock liek wm4
suggested, but it leads to some annoying black flickering. I will fallback to
that only if some new deadlocks are discovered.
2014-10-18 18:30:22 +02:00
Stefano Pigozzi 421bce0077 Revert "cocoa: perform init and uninit synchronously"
This reverts commit a0ac8b6331.
2014-10-18 14:28:47 +02:00
wm4 f5a19f6328 manpage: ipc: explain security implications
It's kind of obvious, since the protocol by design has to allow you to
read (loadfile) and write (screenshot_to) random files, but better
make it explicit so that nobody accidentally does something insecure.
2014-10-17 23:03:08 +02:00
wm4 fd7bf67019 DOCS/client_api_examples: qtexample: don't require Qt 5.x
Exclude the worthless Qt 5.0-only demo code on Qt 4.x.
2014-10-17 22:36:23 +02:00
wm4 70cc42655d ipc: fix a small memory leak 2014-10-17 22:31:14 +02:00
wm4 d15df00643 win32: clear window handle on destruction
As I understand, otherwise, the code will try to destroy the same
window again in the cleanup part of the gui_thread(), which makes no
sense and is potentially dangerous.
2014-10-17 22:22:10 +02:00
wm4 201a656350 win32: get rid of mp_stat in the normal source code
mp_stat() instead of stat() was used in the normal code (i.e. even
on Unix), because MinGW-w64 has an unbelievable macro-mess in place,
which prevents solving this elegantly.

Add some dirty workarounds to hide mp_stat() from the normal code
properly. This now requires replacing all functions that use the
struct stat type. This includes fstat, lstat, fstatat, and possibly
others. (mpv currently uses stat and fstat only.)
2014-10-17 22:15:19 +02:00
wm4 a7eb363ac1 win32: make lseek() fail on pipes
On MingGW seeking on pipes succeeds.

This fix is quite similar to Gnulib's (lib/lseek.c).
2014-10-17 21:43:18 +02:00
wm4 0abe9b0e0a old-build: adjust to latest changes 2014-10-17 21:35:28 +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 e0f0f6fe26 manpage: add JSON IPC documentation 2014-10-17 20:46:31 +02:00
Alessandro Ghedini 13039414f5 input: implement JSON-based IPC protocol 2014-10-17 20:46:31 +02:00
wm4 c01151e0bf misc: add JSON parser 2014-10-17 20:46:31 +02:00
Stefano Pigozzi eb902efb04 cocoa: allow mouse events to bubble up with no-input-cursor
Previously we didn't report events to the core, but still prevented the events
to travel on the responder chain.
2014-10-17 19:19:45 +02:00
Stefano Pigozzi 49b6fa8779 cocoa: allow to disable apple remote at compile time
Actually doesn't remove the related flags so that one can still pass the
option with the option doing nothing.
2014-10-17 19:16:58 +02:00
wm4 a0acb6eaa7 demux: print a warning if stream is not seekable 2014-10-17 18:18:20 +02:00
wm4 01e1d0948d options: don't load per-file config files by default
Generally useless feature, and might be slightly dangerous if paths
can "escape" from the profile dir. (Normally this shouldn't be
possible, though.)
2014-10-17 02:55:31 +02:00
wm4 41b2927f39 sub: adjustments to --ass-style-override option
Now requires newest libass git. Since this feature wasn't part of a
libass release yet, I'm not bothering making the mpv code compatible
with as how it was previously implemented (it will just be disabled
with any older libass).

CC: @mpv-player/stable (because mpv-build uses libass git, and this
                        breaks the feature)
2014-10-17 02:06:08 +02:00
wm4 ca038d9a22 audio: don't go to sleep after audio reinit
It possibly goes to sleep without actually starting to decode audio.
Possibly fixes a problem with --no-osc --no-video reported on IRC.

CC: @mpv-player/stable
2014-10-17 01:10:49 +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 b5ca94af5c terminal: recognize ^h
Fixes #1185.

CC: @mpv-player/stable
2014-10-17 00:53:47 +02:00
wm4 a121331186 stream: better error message for unmatched protocol
See #1187.
2014-10-17 00:05:02 +02:00
wm4 708ca05cc6 vo_opengl: fix wrong comments
The previous commit was actually incorrect, and the change had
absolutely no effect. The two formats are (fortunately) the same. I'm
probably too tired.
2014-10-16 23:51:36 +02:00
wm4 b52c7273f4 vo_opengl: fix theoretical format mismatch issue
This would have been wrong for hw decoders which pass us NV12 or NV21.
The format the GL shader filter chain gets is stored in p->image_desc,
while p->image_format still contains the "real" input format (which in
case of hw decoding is an opsque hw accel format). Since no hw decoder
did this, this is really just a theoretical fix and doesn't fix any
actual bugs.
2014-10-16 23:44:10 +02:00