Commit Graph

37449 Commits

Author SHA1 Message Date
wm4 68f46675bc cache: reduce message spam
Output only 1 message every 5 seconds at most.
2014-01-16 23:06:41 +01:00
Tomáš Chvátal 788241649d mpv.desktop: use %U in desktop file as we can open urls
Signed-off-by: wm4 <wm4@nowhere>
2014-01-16 23:06:41 +01:00
wm4 e10e1a57d0 lua: use core log level names
When the Lua code was written, the core didn't have names for log levels
yet (just numbers). The only user visible change is that "verbose"
becomes "v", since this level had different names.
2014-01-16 23:06:41 +01:00
wm4 d646d78ccb lua: allow scripts to snoop messages
Adds the following Lua function to enable message events:

    mp.enable_messages(size, level)

size is the maximum number of messages the ringbuffer consists of. level
is the minimum log level for a message to be added to the ringbuffer,
and uses the same values as the mp.log() function. (Actually not yet,
but this will be fixed in the following commit.)

The messages will be delivered via the mp_event() in the user script,
using "message" as event name. The event argument is a table with the
following fields:

    level: log level of the message (string as in mp.log())
    prefix: string identifying the module of origin
    text: contents of the message

As of currently, the message text will contain newline characters. A
message can consist of several lines. It is also possible that a
message doesn't end with a newline, and a caller can use multiple
messages to "build" a line. Most messages will contain exactly 1 line
ending with a single newline character, though.

If the message buffer overflows (messages are not read quickly enough),
new messages are lost until the queued up messages are read. At the
point of the overflow, a special overflow message is inserted. It will
have prefix set to "overflow", and the message text is set to "".

Care should be taken not to print any messages from the message event
handler. This would lead to an infinite loop (the event handler would be
called again after returning, because a new message is available). This
includes mp.log() and all mp.msg.* functions. Keep in mind that the Lua
print() function is mapped to mp.msg.info().
2014-01-16 23:06:40 +01:00
wm4 8c5ea38cda msg: expose log level names 2014-01-16 23:06:40 +01:00
wm4 738dfbb2fe msg: add a mechanism to output messages to a ringbuffer
Until now, mp_msg output always went to the terminal. There was no way
to grab the stream of output messages. But this will be needed by
various future changes: Lua scripts, slave mode, client library...

This commit allows registering a ring buffer. A callback would be more
straight-forward, but since msg.c sits at the bottom of the lock
hierarchy (it's used by virtually everything), this would probably be a
nightmare. A ring buffer will be simpler and more predictable in the
long run.

We allocate new memory for each ringbuffer entry, which is probably a
bit expensive. We could try to be clever and somehow pack the data
directly into the buffer, but I felt like this wouldn't be worth the
complexity. You'd have to copy the data a bunch of times anyway. I'm
hoping that we can get away with using the ringbuffer mechanism for
low frequency important messages only (and not e.g. for high volume
debug messages), so the cost doesn't matter that much.

A ringbuffer has a simple, single log level. I considered allowing
--msglevel style per-prefix configuration for each ringbuffer, but
that would have been pretty complicated to implement, and wouldn't
have been that useful either.
2014-01-16 23:06:40 +01:00
wm4 49eb3c4025 msg: fix typo in comment 2014-01-16 23:06:40 +01:00
wm4 99ee43b33b msg: move special declarations to msg_control.h
While almost everything uses msg.h, the moved definitions are rarely
needed by anything.
2014-01-16 23:06:40 +01:00
wm4 5b14db5ab1 msg: print module prefixes even if message contains newlines
This makes

    mp_msg(x, y, "a\nb\n")

behave the same as

    mp_msg(x, y, "a\n")
    mp_msg(x, y, "b\n")

which is probably what one would expect. Before this commit, the "b"
line didn't have a prefix when using ths single mp_msg call.
2014-01-16 23:06:40 +01:00
Martin Herkt 26d6eb4a8a io/win32: move mp_attach_console to terminal-win.c
Why didn't I put it there from the start?
2014-01-16 11:25:52 +01:00
Johannes Nixdorf d5fce546a4 player: handle the corner cases in --term-osd-bar correctly
With the old code and pos == width - 2 one character too many is drawn.
2014-01-15 23:12:46 +01:00
Johannes Nixdorf 1d9c62b644 player: use more than 1/100 resolution for --term-osd-bar
If the terminal width is large enough the position marker jumps over
several characters because currently pos only increases in 1/100th steps.
2014-01-15 23:12:34 +01:00
ChrisK2 195e087086 osc: check for availabillity of percent-pos instead of length
... to decide wether the seekbar should be enabled or not.
2014-01-15 22:33:58 +01:00
wm4 5655038a95 command: if playback position is unknown, make percent-pos unavailable
Before that, it just returned -1.

The print case is inconsistent with that, but I'll leave it for now,
because it's consistent with status line / show_progress behavior.
2014-01-15 22:25:14 +01:00
James Ross-Gowan 80c11eba66 w32_common: add extended keys
Also VK_APPS/MP_KEY_MENU was missing.
2014-01-15 16:15:30 +01:00
wm4 45641378a2 player: add --term-osd-bar, which shows a status bar on the terminal
Feature request from github issue #451. Disabled by default, will
probably stay this way.
2014-01-15 16:14:37 +01:00
wm4 ca8937d7d2 bstr: add function for splitting UTF-8 2014-01-15 16:13:07 +01:00
wm4 904060ad7b msg: update comment 2014-01-15 13:36:48 +01:00
wm4 44993ba0fb msg: terminal OSD uses stderr, not stdout
This is more correct. E.g. if you do "mpv file.mkv > /dev/null", stdout
will not be a terminal, but stderr (used by terminal OSD and status
line) is.
2014-01-15 13:36:39 +01:00
James Ross-Gowan 4276e9443d w32_common: prevent decoding certain keys twice
This is a bit of a hack, but in order to prevent TranslateMessage from
seeing WM_KEYDOWN messages that we already know how to decode, move the
decoding logic to the event loop. This should fix #476, since it stops
the generation of extraneous WM_CHAR messages that were triggering more
than one action on keydown.
2014-01-15 13:32:25 +01:00
Grzegorz Blach 8255400e9c Detect Lua on FreeBSD 2014-01-15 00:18:14 +01:00
wm4 635b2f2690 player: don't print status in --idle mode
Apparently this annoys certain users. Restores old behavior.
2014-01-14 22:24:07 +01:00
wm4 5196b03fb2 player: avoid stalling when starting a network stream
Starting a network stream could stall by executing uncacheable stream
control requests (STREAM_CTRL_GET_LANG and STREAM_CTRL_GET_DVD_INFO).
Being uncacheable means the player has to wait until the cache is done
reading the current block of data. These requests can't be cached
because they're too complicated, so the only way to avoid them is
special casing the DVD and Bluray streams (which are the only things
which need these requests), and not doing them in other cases.

(This is kind of inelegant, but so is the rest of the DVD/BD code.)
2014-01-14 22:24:07 +01:00
Stefano Pigozzi 9dc9254da2 cocoa: add application icon to the Dock when run from CLI
Application icon was added to the Dock only when run inside of a bundle. That
was handled automatically by OS X using the Info.plist definition.

To add the Application icon when run as a CLI program, I used the samme
approach in the X11 code and loaded the icon as a static binary blob inside
of mpv's binary. This is the simplest approach as it avoid headackes when
relocating the binary and such.
2014-01-14 20:42:12 +01:00
wm4 e32adef9c4 ebml: remove length parameters from read functions
Many ebml_read_* functions have a length int pointer parameter, which
returns the number of bytes skipped. Nothing actually needed this
(anymore), and code using it was rather hard to understand, so get rid
of them.
2014-01-14 17:38:51 +01:00
wm4 bbbea7934f ebml: remove unused functions
These were mostly replaced by ebml_read_element().
2014-01-14 17:38:44 +01:00
wm4 72d5273bc1 demux_mkv: remove unused macros 2014-01-14 17:38:32 +01:00
wm4 3c2f93aec8 demux_mkv: improve robustness by explicitly checking for level 1 elements
Matroska makes it pretty hard to resync correctly on broken files:
random data returns "valid" EBML IDs with a high probability, and when
trying to skip them it's likely that you skip a random amount of data
(instead of considering the element length invalid).

Improve upon this by skipping known level 1 elements only. Consider
everything else invalid and call the resync code. This might result in
annoying behavior when Matroska adds new level 1 elements, although it
won't be particularly harmful. Matroska doesn't really allow us to do
better (even mkvtoolnix explicitly checks for known level 1 elements).

Since we now don't always want to combine EBML element skipping and
resyncing, remove ebml_read_skip_or_resync_cluster(), and make
ebml_read_skip() more tolerant against skipping broken elements.

Also, don't resync when reading sub-elements, and instead do resyncing
when reading them results in an error.
2014-01-14 17:38:21 +01:00
wm4 ae27e13a0a demux_mkv: avoid skipping too much data in corrupted files
Until now, corrupted files were detected if the size of an element (that
should be skipped) was larger than the remaining file. This still could
skip larger regions of the file itself if the broken size happened to be
within the file.

Change it so that it's never allowed to skip outside the parent's
element.
2014-01-14 17:38:08 +01:00
wm4 b51713e8e7 msg: don't clear term OSD lines that are not used 2014-01-14 17:37:55 +01:00
wm4 f3133e8704 terminal-unix: fix terminfo/termcap name for cursor up
"ku" is for input, not output. This happened to work on urxvt, but broke
on xterm (and probably a dozen of other terminals).
2014-01-14 17:37:40 +01:00
wm4 da00282e3a msg: fix printing of module header
The code to set root->header was moved before the point where it's used,
which broke the logic.
2014-01-14 17:37:30 +01:00
wm4 1cd1fb9e5c terminal-unix: add fallback for enter key
This worked just fine if terminfo or termcap was available.
2014-01-13 23:12:14 +01:00
wm4 d52fc906c3 terminal-unix: fix fallbacks in case terminfo/termcap are disabled
These two escape sequences were swapped. (They are used only if
terminfo/termcap are not available.)
2014-01-13 23:11:46 +01:00
wm4 710a45a386 terminal-unix: add termcap/terminfo documentation links
Apparently, some people are not clever enough to google this
information.

Proper googling to find these links done by Kovensky.
2014-01-13 20:13:16 +01:00
wm4 1d64b0101f manpage: document --term-osd=force
Apparently this was forgotten when it was first added, or maybe it's an
arrifact from the rst conversion.
2014-01-13 20:11:18 +01:00
wm4 6759941fca player: redo terminal OSD and status line handling
The terminal OSD code includes the handling of the terminal status line,
showing player OSD messages on the terminal, and showing subtitles on
terminal (the latter two only if there is no video window, or if
terminal OSD is forced).

This didn't handle some corner cases correctly. For example, showing an
OSD message on the terminal always cleared the previous line, even if
the line was an important message (or even just the command prompt, if
most other messages were silenced).

Attempt to handle this correctly by keeping track of how many lines the
terminal OSD currently consists of. Since there could be race conditions
with other messages being printed, implement this in msg.c. Now msg.c
expects that MSGL_STATUS messages rewrite the status line, so the caller
is forced to use a single mp_msg() call to set the status line.

Instead of littering print_status() all over the place, update the
status only once per playloop iteration in update_osd_msg(). In audio-
only mode, the status line might now be a little bit off, but it's
perhaps ok.

Print the status line only if it has changed, or if another message was
printed. This might help with extremely slow terminals, although in
audio+video mode, it'll still be updated very often (A-V sync display
changes on every frame).

Instead of hardcoding the terminal sequences, use
terminfo/termcap to get the sequences. Remove the --term-osd-esc option,
which allowed to override the hardcoded escapes - it's useless now.

The fallback for terminals with no escape sequences for moving the
cursor and clearing a line is removed. This somewhat breaks status line
display on these terminals, including the MS Windows console: instead of
querying the terminal size and clearing the line manually by padding the
output with spaces, the line is simply not cleared. I don't expect this
to be a problem on UNIX, and on MS Windows we could emulate escape
sequences. Note that terminal OSD (other than the status line) was
broken anyway on these terminals.

In osd.c, the function get_term_width() is not used anymore, so remove
it. To remind us that the MS Windows console apparently adds a line
break when writint the last column, adjust screen_width in terminal-
win.c accordingly.
2014-01-13 20:08:13 +01:00
wm4 8721f9151f player: don't block terminal OSD while seeking
Seeking usually show the status on OSD. In terminal OSD mode, no status
is shown, because there is already a separate status line.
Unfortunately, the mechanism for showing the status was still active,
which forced showing no message while the code for showing seek status
was active.
2014-01-13 19:46:16 +01:00
wm4 a1c22f763d player: mention subtitles in av_desync_help_text
Insane .ass subtitle scripts can cause severe slowdown (depending on the
speed of the machine, or the insanity of the script), so mention how to
test without subtitles. This is mainly to make the user aware that
subtitle rendering can be a problem. For longwinded explanation, there
isn't enough space.
2014-01-12 21:41:09 +01:00
wm4 ad654f3803 options: remove --screenw and --screenh
Doesn't make any sense anymore. X11 (which was mentioned in the manpage)
autodetects it, and everything else ignored the option values.

Since for incomprehensible reasons the backends and vo.c still need to
exchange information about the screensize using the option fields,
they're not removed yet.
2014-01-11 18:58:07 +01:00
wm4 905029ec0c video/out: remove pointless x/y parameter from vo_x11_config_vo_window
This never made any real sense; the "backend" has to access vo->dx/dy
anyway.
2014-01-11 18:58:07 +01:00
wm4 d956bbc065 video/out: simplify monitor aspect handling
For some reason, this made all VO backends both set the screen
resolution in opts->screenwidth/height, and call
aspect_save_screenres(). Remove the latter. Move the code to calculate
the PAR-corrected window size from aspect.c to vo.c, and make it so that
the monitor PAR is recalculated when it makes sense.
2014-01-11 18:58:06 +01:00
wm4 3b8e457379 video/out: remove fallback handling for screensize/monitor pixel aspect
When using --monitoraspect, but either the screen width or height or
both are unknown, a fallback is applied. This is a completely useless
obscure corner case that's going to help nobody, so get it out of the
way.
2014-01-11 18:58:06 +01:00
Stefano Pigozzi 6a3ab66427 cocoa: fix window placement on secondary screens
For a long time the cocoa backend set the xinerama_x/y and used dx/dy from the
VO instance. This somewhat worked with some workarounds but wasn't really
what was supposed to be happening. Moreover 27e4360, which touched this
workaround introduced a regression.

New code doesn't set the xinerama_x/y values so that dx/dy are offsets in the
current screen (not a virtual screen composed of all the screens). The screen
reference detected during VOCTRL_UPDATE_SCREENINFO is also passed down to the
window initialization code.

Fixes #472
2014-01-11 14:06:40 +01:00
wm4 3433f25697 vd_lavc: matroska: remove weird code setting extra_huff for mjpeg
Like with the previous commit, this is probably not needed, but it's
unclear whether that really is the case. Most likely, it used to be
needed by some demuxer, and now the only demuxer left that could
_possibly_ trigger this is demux_mkv.c.

Note that mjpeg is the only decoder that reads the extra_huff option,
and nothing in libavformat actually sets the option. So maybe it's
fundamentally not needed anymore.
2014-01-11 01:49:20 +01:00
wm4 589f4871ea vd_lavc: matroska: remove weird realvideo special handling
This case can't happen with the normal realvideo codepath in
demux_mkv.c, because the code would errors out if the extradata is too
small, and everything would be broken anyway in the case the vd_lavc.c
condition is actually triggered.

It still might happen with VfW-muxed realvideo in Matroska, though.
Basically, I'm hoping this doesn't matter anyway, and that the vd_lavc.c
code was for other old demuxers, like demux_avi or demux_rm. Following
the commit history, it's not really clear for what demuxer this code
was added.
2014-01-11 01:47:14 +01:00
wm4 85e90668ae vd_lavc: minor simplification 2014-01-11 01:33:07 +01:00
wm4 14bd02a034 sd_lavc: use mp_lavc_set_extradata()
This includes the magical input padding required by libavcodec, which we
possibly didn't do before this commit.
2014-01-11 01:28:18 +01:00
wm4 4b4926bbb3 Factor out setting AVCodecContext extradata 2014-01-11 01:25:49 +01:00
Stefano Pigozzi 27e4360b0b cocoa: refactor init window positioning code 2014-01-10 20:39:25 +01:00