Commit Graph

37318 Commits

Author SHA1 Message Date
wm4 77e92bbb11 stream: treat embedded 0 bytes as error in stream_read_line
Text files should never contain these.
2014-01-19 21:15:54 +01:00
wm4 333a9491b7 stream: redo stream_read_line()
This simplifies the implementation and should make it more robust. For
example, we return an error if a line is longer than the provided buffer
(instead of splitting the line).

The code is much shorter, because now finding the new line and reading
characters is done in one go.
2014-01-19 21:15:54 +01:00
wm4 6afebbd0d9 demux_playlist: handle stream_read_line() errors
As of this commit, stream_read_line() can't actually error (except in
the case the passed in buffer is 0, which never happens here). This
commit is preparation for the following commit, which checks harder
whether the read data is actually text. Before this commit, an error
was treated as end-of-file, but the data read so far was considered
valid.
2014-01-19 21:15:54 +01:00
11rcombs a0cc204528 af: fixed out-of-bounds accesses caused by NUM_FMT and co.
Signed-off-by: wm4 <wm4@nowhere>

This merges pull request #496. The problem was that at least the
initialization of the distance[] array accessed af_fmtstr_table[]
entries that were out of bounds. Small cosmetic changes applied to
the original pull request.
2014-01-19 21:15:54 +01:00
James Ross-Gowan 32c0df1b53 w32: use the w32_common keymap in terminal-win too 2014-01-19 14:42:15 +01:00
reimar 55ea419ae3 cookies.c: cols must (and does) have 7 elements.
Doesn't affect the generated code, but avoids confusion
in both humans and newer Coverity versions.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@36623 b3059339-0415-0410-9bf9-f77b7e298cf2
2014-01-19 12:58:03 +01:00
reimar 8e2f301ee4 vcd_read: Fix sizeof argument.
The struct we need to copy is actually a cdrom_msf0, not cdrom_msf.
Even though the kernel for no good reason reads it in as a
cdrom_msf struct, but only uses the part shared with cdrom_msf0 -
this is probably a kernel bug.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@36622 b3059339-0415-0410-9bf9-f77b7e298cf2
2014-01-19 12:57:50 +01:00
wm4 2120a75a83 mpv.desktop: add some more mimetypes
Again from github issue #484.

Also, sorry for the typo in the earlier commit message.
2014-01-18 22:42:59 +01:00
wm4 03859a581c player: prevent null pointer deref on uninit after -V
Caused by the OSD changes. Fixes #490.
2014-01-18 17:59:34 +01:00
wm4 8cbed35403 mkv.desktop: add two more mime types
Stolen from github issue #484. No idea whether they're needed.
2014-01-18 16:46:27 +01:00
wm4 6f520bb956 osd: fix dvdnav highlights
Broken by previous commit.
2014-01-18 16:40:39 +01:00
wm4 7f4a09bb85 sub: uglify OSD code path with locking
Do two things:
1. add locking to struct osd_state
2. make struct osd_state opaque

While 1. is somewhat simple, 2. is quite horrible. Lots of code accesses
lots of osd_state (and osd_object) members. To make sure everything is
accessed synchronously, I prefer making osd_state opaque, even if it
means adding pretty dumb accessors.

All of this is meant to allow running VO in their own threads.
Eventually, VOs will request OSD on their own, which means osd_state
will be accessed from foreign threads.
2014-01-18 01:27:43 +01:00
wm4 92a9f11a0b sub: uglify sub decoder with locking
The plan is to make the whole OSD thread-safe, and we start with this.

We just put locks on all entry points (fortunately, dec_sub.c and all
sd_*.c decoders are very closed off, and only the entry points in
dec_sub.h let you access it). I think this is pretty ugly, but at least
it's very simple.

There's a special case with sub_get_bitmaps(): this function returns
pointers to decoder data (specifically, libass images). There's no way
to synchronize this internally, so expose sub_lock/sub_unlock functions.

To make things simpler, and especially because the lock is sort-of
exposed to the outside world, make the locks recursive. Although the
only case where this is actually needed (although trivial) is
sub_set_extradata().

One corner case are ASS subtitles: for some reason, we keep a single
ASS_Renderer instance for subtitles around (probably to avoid rescanning
fonts with ordered chapters), and this ASS_Renderer instance is not
synchronized. Also, demux_libass.c loads ASS_Track objects, which are
directly passed to sd_ass.c. These things are not synchronized (and
would be hard to synchronize), and basically we're out of luck. But I
think for now, accesses happen reasonably serialized, so there is no
actual problem yet, even if we start to access OSD from other threads.
2014-01-17 23:21:17 +01:00
wm4 49ebbce3e0 player: remove OSD message IDs
These were needed before the last commit, but now they don't do anything
anymore. (They were used to decide whether to replace or stack the
previous OSD message when a new one was displayed.)
2014-01-17 22:34:47 +01:00
wm4 a0a2ea8713 player: remove OSD stack
If certain OSD messages were displayed at the same time, the hidden
messages were put on the stack, and displayed again once the higher
priority messages disappeared. The idea was probably that lower priority
messages could not hide higher priority ones, and also that the lower
messages did not get lost.

But in practice, this gives confusing results with OSD messages randomly
reappearing for a brief time. Remove it.
2014-01-17 22:26:04 +01:00
wm4 c47c59f2df player: don't use OSD message stack for term OSD subs
Showing subtitles on terminal used the OSD message stack (which uses a
stack to "pile up" messages that were displayed at the same time). This
had a bunch of weird and annoying consequences. This accessed a certain
osd_state field, which is a minor annoyance since I want to make that
struct opaque. Implement this differently.
2014-01-17 21:55:23 +01:00
wm4 7e1bc6be00 cache: remove debug code
This was accidentally committed.

<rcombs> `mp_sleep_us(100000);` <-- are you drunk?
2014-01-17 00:15:14 +01:00
wm4 d3b5643589 lua: add a --lua-opts option, which can be queried by scripts
The values set by this new option can be queried by Lua scripts using
the mp.getopt() function. The function takes a string parameter, and
returns the value of the first key that matches. If no key matches, nil
is returned.
2014-01-16 23:06:41 +01:00
wm4 82067e6ac3 options: add key/value pair list option type 2014-01-16 23:06:41 +01:00
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