Commit Graph

1107 Commits

Author SHA1 Message Date
wm4 4c3f042777 command: make the "run" command work on Windows too
Do so by using mp_subprocess(). Although this uses completely different
code on Unix too, you shouldn't notice a difference. A less ncie thing
is that this reserves an entire thread while the command is running
(which wastes some memory for stack, at least). But this is probably
still the simplest way, and the fork() trick is apparently not
implementable with posix_subprocess().
2015-01-01 20:37:49 +01:00
wm4 39548ad9e9 Update copyright year 2015-01-01 00:00:00 +01:00
wm4 84fe12fab5 client API: add function to create new mpv_handles from existing ones
This may or may not be useful for client API users.

Fold this API extension into the previous API bump. The previous bump
was only yesterday, so it's ok.
2014-12-31 20:50:06 +01:00
wm4 a850bf786e vo_opengl_cb: simplify API uninitialization
Until now, calling mpv_opengl_cb_uninit_gl() at a "bad moment" could
make the whole thing to explode. The API user was asked to avoid such
situations by calling it only in "good moments". But this was probably a
bit too subtle and could easily be overlooked.

Integrate the approach the qml example uses directly into the
implementation. If the OpenGL context is to be unitialized, forcefully
disable video, and block until this is done.
2014-12-31 20:31:19 +01:00
wm4 65f2c6c716 vo_opengl_cb: pass context directly
This is simpler than setting the context after VO creation, which
requires the code to check for the context on every entrypoint.
2014-12-31 19:12:44 +01:00
wm4 282e3202d5 video: pass some VO params as struct
Not particularly elegant, but better than adding more and more stuff to
the relevant function signatures.
2014-12-31 19:01:28 +01:00
wm4 63a414c708 command: make empty vf-metadata not an error
If a filter exists, but has no metadata, just return success. This
allows the user to distinguish between no metadata available, and filter
not inserted.

See #1408.
2014-12-30 14:04:53 +01:00
Stefano Pigozzi 0fa9986a98 options: expand ~ for the include option
Fixes #1406
2014-12-30 09:23:36 +01:00
wm4 97ab40290e command: add filtered-metadata property
Goes in hand with the previous commit; the main purpose is to easily
show on OSD what is shown on terminal.
2014-12-29 23:03:39 +01:00
wm4 8048374a5c player: filter tags, add --display-tags option
This attempts to increase user-friendliness by excluding useless tags.
It should be especially helpful with mp4 files, because the FFmpeg mp4
demuxer adds tons of completely useless information to the metadata.

Fixes #1403.
2014-12-29 22:51:18 +01:00
wm4 6618e5d69a player: make --shuffle/--merge-files affect runtime loaded playlists
Until now, these options took effect only at program start. This could
be confusing when e.g. doing "mpv list.m3u --shuffle". Make them always
take effect when a playlist is loaded either via a playlist file, or
with the "loadlist" command.
2014-12-29 22:08:22 +01:00
wm4 a608a0cd8e command: stip path from playlist OSD display
But only if it's not e.g. a http URL.

Fixes #1388.
2014-12-27 21:20:57 +01:00
wm4 bde7fa5a46 player: force stereo as default when encoding
I think the new default for this option might be rather bad in encoding
mode. For starters, we don't even know what layers an encoder supports
at all.
2014-12-27 12:25:39 +01:00
wm4 77a4a87e7e player: fix random crashes on uninitialization
On uninitialization, the player will unselect all subtitles, and then
destroy the subtitle decoder. But it didn't correctly remove the
subtitle decoder from the OSD state, so it could happen that it would
access it after the decoder was destroyed.

Could lead to random crashes when switching files often.

Fixes #1389.
2014-12-27 12:24:44 +01:00
wm4 6659de707b player: cosmetics: rename a function
Something which has this many important sideffects shouldn't start have
a "get" prefix.
2014-12-27 12:23:00 +01:00
wm4 046333cebc player: ordered chapters: cosmetics
Drop some meaningless comments, fix codingstyle, fix some formatting
victims of the mp_msg refactoring, replace some memcpys with
assignments.
2014-12-26 20:10:43 +01:00
wm4 c57c295154 player: ordered chapters: bullshit reduction
Nobody cares about these redundant messages, they make the code even
more complicated than it has to be, and also they're annoying.
2014-12-26 20:10:43 +01:00
wm4 546feebeb9 player: ordered chapters: filter missing chapters
Ever since someone (not me) added some Matroska features which nobody
ever uses (ordered edition or some bullshit), I haven't had a fucking
clue what the fuck is going on in this fucking file. (Still agreed to
it, so it's my fault.)

mplayer2 handled missing chapters correctly (and I suppose in a somewhat
clean/simple manner), but the changed code doesn't. Since I can't even
follow this code because it's so arcanely complicated, just add a hack
that has the same effect.
2014-12-26 20:10:09 +01:00
wm4 adf7f0661e command: overlay_add: more flexible treatment of offset parameter
Essentially, don't make it the mmap() argument, and just add it to the
memory address. This hides tricky things like alignment reequirements
from the user.

Strictly speaking, this is not entirely backwards compatible: this adds
the regression that you can't access past 2 or 4 GB of a file on 32 bit
systems anymore. But I doubt anyone cared about this.

In theory, we could be clever, and just align the offset manually and
pass that to mmap(). This would also be transparent to the user, but
minimally more effort, so this is left as exercise to the reader.
2014-12-26 18:11:22 +01:00
wm4 3fdb6be316 win32: add mmap() emulation
Makes all of overlay_add work on windows/mingw.

Since we now don't explicitly check for mmap() anymore (it's always
present), this also requires us to make af_export.c compile, but I
haven't tested it.
2014-12-26 17:30:10 +01:00
wm4 fdb379109f player: hack against --keep-open misbehaving with broken files
If a file (or a demuxer) is broken, seeking close to the end of the file
doesn't work, and seek_to_last_frame() will be called over and over
again, burning CPU for no reason.

Observed with incomplete mp4 files. That this can happen was already
mentioned in commit 090f6cfc, but I guess now I'll do something against
it.

hrseek_lastframe is cleared by reset_playback_state(), so it's only set
if seek_to_last_frame() was called, and no other seek happened since
then. If finding the last frame succeeds, no EOF will happen (unless the
user unpauses, but then it will simply remain at the last frame). If it
fails, then it will return immediately, without retrying.
2014-12-24 15:12:11 +01:00
wm4 7593a1f638 player: fix a typo in message output
This typo has been around for over a year. Oops.
2014-12-24 14:35:04 +01:00
wm4 cb347a9d05 client API: fix compiler warning if openglcb API is disabled
The function is void, and of course you can't return anything from it.
(Why does C or gcc even allow this?)
2014-12-22 12:47:05 +01:00
wm4 16a5971d28 vo_opengl_cb: free context on exit
Minor memory leak.

Actually, this also exposes some problems in the QtQuick example. This
will have to be fixed in the example.
2014-12-22 12:45:43 +01:00
wm4 4b4d3a57bf client API: fix mpv_wakeup()
Of course this was going to get stuck in the retry loop.

Fixes #1372.
2014-12-22 01:53:39 +01:00
wm4 49d01d81e0 sub: reset sub decoder correctly when cycling subtitles
reset_subtitles() works in mpctx->d_sub[], which is set to NULL before
calling it from uninit_sub(). This fixes resetting the subtitle when
cycling subtitle tracks.

Actually, this was probably a feature, because it's annoying if
subtitles don't show up when cycling them. But it also can have
unintended consequences, so get rid of it.
2014-12-21 23:48:20 +01:00
wm4 dc0b0cdeb0 player: cosmetics: move code around
Separate commit to reduce noise in the following one.
2014-12-21 23:47:00 +01:00
wm4 7d43a7ea84 player: don't show "0%" percentage in infinite streams 2014-12-20 17:31:58 +01:00
wm4 9f4b01400e player: print only changed tags
The code in the demuxer etc. was changed to update all metadata/tags at
once, instead of changing each metadata field. As a consequence,
printing of the tags to the terminal was also changed to print
everything on each change.

Some users didn't like this. Add a very primitive way to avoid printing
fields with the same value again if metadata is marked as changed. This
is not always correct (could print unchanged fields anyway), but usually
works.

(In general, a rather roundabout way to reflect a changed title with ICY
streaming...)

Fixes #813 (let's call it a "policy change").
2014-12-19 23:54:21 +01:00
wm4 d910a0faa8 player: cosmetics: remove ancient comment
The DVD horror was confined to specific parts of the player, instead of
having it spread everywhere.
2014-12-17 22:57:20 +01:00
wm4 c721948efe command: extend revert_seek command
"revert_seek mark" basically forces the seekback point. It's basically a
one-way bookmark.
2014-12-17 22:56:45 +01:00
wm4 c8727ed9fc command: format ${avsync} like on terminal status line
Padding with spaces is very useless for OSD (because most fonts are
variable width), but it's good when using it on the terminal, e.g. for
reproducing the default terminal status line.
2014-12-16 05:07:38 +01:00
wm4 756adee999 client API: be more lenient about mpv_suspend/resume mismatches
Before this commit, this was defined to trigger undefined behavior. This
was nice because it required less code; but on the other hand, Lua as
well as IPC support had to check these things manually. Do it directly
in the API to avoid code duplication, and to make the API more robust.
(The total code size still grows, though...)

Since all of the failure cases were originally meant to ruin things
forever, there is no way to return error codes. So just print the
errors.
2014-12-15 14:44:47 +01:00
wm4 a40df83bae lua: cosmetics: fix some include directives
Apparently, the atomics were used by the win32 subprocess code. This
code was moved to a separate file, but the atomics.h include was
forgotten.
2014-12-15 14:44:47 +01:00
wm4 fcec3df700 scripting: fix/improve deprecation message
The message was missing a '\n', so it was merged with the next line,
which also typically caused it not to be printed with the colors for
warnings.

Print the full new path in the warning message. (Normally, cfg should
never be NULL, so accounting for this case is just for robustness.)
2014-12-15 06:24:05 +01:00
Avi Halachmi (:avih) 39e04e9294 options: deprecate 'lua' based options/dirs for 'script'
- --lua and --lua-opts change to --script and --script-opts
- 'lua' default script dirs change to 'scripts'
- DOCS updated

- 'lua-settings' dir was _not_ modified

The old lua-based names/dirs still work, but display a warning.

Signed-off-by: wm4 <wm4@nowhere>
2014-12-15 04:39:56 +01:00
wm4 5b618ef629 command, dvd: add property which returns list of DVD titles
This was requested.

It seems libdvdread can't get the duration for titlesets other than the
currently opened title. The data structures contain dangling pointers
for these, and MPlayer works this around by opening every title
separately for the purpose of dumping the title list.
2014-12-13 20:25:56 +01:00
wm4 82317593e9 options: add option for ignoring patch in resume mechanism
Whatever.

Fixes #1281.
2014-12-13 00:04:08 +01:00
wm4 98e400216d player: add a --keep-open=always mode
The --keep-open behavior was recently changed to act only on the last
file due to user requests (see commit 735a9c39). But the old behavior
was useful too, so bring it back as an additional mode.

Fixes #1332 (or rather, should help with it).
2014-12-12 23:45:16 +01:00
wm4 d17c3b63c3 command: add properties for current bitrate
Fixes #1192.
2014-12-12 01:00:58 +01:00
wm4 eb36bd6945 lua: don't ignore key press events for script key bindings
Meh.
2014-12-10 18:36:05 +01:00
wm4 efd3f6f0d2 command: fix crash with some forms of script_binding
"script_binding name ..." just crashed it. Oops.
2014-12-10 18:28:09 +01:00
wm4 f0cdd673a8 player: update chapter marks when switching files
This wasn't done, so the chapter marks of the previous file were
visible. It's harmless, but looks unpolished, so fix it.
2014-12-10 17:52:21 +01:00
wm4 c6dc0c6d99 command: add "idle" property
Yes, it's redundant with events.
2014-12-10 14:42:57 +01:00
wm4 900c2e9f78 player: change interaction between revert_seek and ab-loops
The result isn't quite what I imagined, because the A-point is never
marked as a seek point (so you can't jump between A and B), but it's
still slightly better than before.
2014-12-09 21:55:27 +01:00
wm4 fb855b8659 client API: expose OpenGL renderer
This adds API to libmpv that lets host applications use the mpv opengl
renderer. This is a more flexible (and possibly more portable) option to
foreign window embedding (via --wid).

This assumes that methods like context sharing and multithreaded OpenGL
rendering are infeasible, and that a way is needed to integrate it with
an application that uses a single thread to render everything.

Add an example that does this with QtQuick/qml. The example is
relatively lazy, but still shows how relatively simple the integration
is. The FBO indirection could probably be avoided, but would require
more work (and would probably lead to worse QtQuick integration, because
it would have to ignore transformations like rotation).

Because this makes mpv directly use the host application's OpenGL
context, there is no platform specific code involved in mpv, except
for hw decoding interop.

main.qml is derived from some Qt example.

The following things are still missing:
- a way to do better video timing
- expose GL renderer options, allow changing them at runtime
- support for color equalizer controls
- support for screenshots
2014-12-09 17:59:04 +01:00
wm4 ca1ec30a4b player: restore ab-loop settings with playback resume
Fixes #1324.
2014-12-09 08:32:01 +01:00
wm4 6a88de05a7 build: fix --disable-libass
Still supported, but obviously untested.

You shouldn't use this option anyway.
2014-12-08 18:17:20 +01:00
wm4 b9f5daf9c3 player: make chapter seek to end jump to last frame with --keep-open
There were complaints that a chapter seek past the last chapter was
quitting the player. Change the behavior to what is expected: the last
frame.

If no chapters are available, this still does nothing.
2014-12-08 17:27:07 +01:00
Stefano Pigozzi f56fcd71bb options: add a 'once' idle mode
This allows to make mpv wait for file open events at start but close
after it is done playing the first playlist.
2014-12-07 16:22:38 +01:00
wm4 3afe76133b sub: remove assertion
This should clearly be impossible, but it seems to happen with ordered
chapters for a user.

Since I can't tell what the actual bug is and it seems impossible to
know the details without downloading possibly huge files, this is
probably the best we can do.

Should at least partially fix #1319.
2014-12-07 14:21:12 +01:00
wm4 090f6cfc30 player: when seeking past EOF with --keep-open, seek to last frame
It feels strange that seeking past EOF with --keep-open actually leaves
the player at a random position. You can't even unpause, because the
demuxer is in the EOF state, and what you see on screen is just what was
around before the seek.

Improve this by attempting to seek to the last video frame if EOF
happens. We explicitly don't do this if EOF was reached normally to
increase robustness (if the VO got a frame since the last seek, it
obviously means we had normal playback before EOF).

If an error happens when trying to find the last frame (such as not
actually finding a last frame because e.g. the demuxer misbehaves), this
will probably turn your CPU into a heater. There is no logic to prevent
reinitiating the last-frame search if the last-frame search reached EOF.
(Pausing usually prevents that EOF is reached again after a successful
last-frame search.)

Fixes #819.
2014-12-07 02:47:54 +01:00
ChrisK2 f299debaa0 osc: improve slimbox layout and minor code cleanups 2014-12-05 19:37:31 +01:00
ChrisK2 e883c48caa assdraw: Properly approximate circle for rounded box
source: http://spencermortensen.com/articles/bezier-circle/
2014-12-05 19:37:31 +01:00
wm4 f95a4bceaa osc, dvd, bd: fix mouse state when changing menu modes
The flags weren't correctly set, and the mouse cursor remained visible
after leaving menu mode.

This was apparently broken in 0.7.0 too.

Fixes #1316.
2014-12-05 16:04:04 +01:00
wm4 a4feecce4e discnav: remove redundant call
This was made the default a while ago.
2014-12-04 22:42:07 +01:00
wm4 c3d6f4b63b dvd, bd: don't unnecessarily block on demuxer/stream all the time
This was completely breaking any low-level caching. Change it so that at
least demuxer caching will work.

Do this by using the metadata cache mechanism to funnel through the menu
commands.

For some incomprehensible reason, I had to reorder the events (which
affects their delivery priority), or they would be ignored. Probably
some crap about the event state being cleared before it could be
delivered. I don't give a shit.

All this code sucks. It would probably be better to let discnav.c access
the menu event "queue" directly, and to synchronize access with a mutex,
instead of going through all the caching layers, making things
complicated and slow.
2014-12-04 22:42:07 +01:00
wm4 7aa91af8a7 dvd, bd, osc: disable OSC while a menu is active
They interfere.

It turns out that commit b6ca4a48 actually broke this in weird ways, but
this solution is better anyway.
2014-12-04 18:32:14 +01:00
wm4 8fc3d7dc39 lua: fully cleanup removed key bindings
This is basically cosmetic; it was leaking the old handler functions.
2014-12-03 23:01:19 +01:00
wm4 f984b79720 client API: allow multiple mpv instances with terminal=yes
This is simply not allowed, and doing it triggered an assertion. It's
still not allowed, because the terminal and related functionality is a
global resource, and there doesn't seem to be a sane way to manage the
signal handlers.

But be a bit nicer, and just the terminal if it's already in use.

Note that terminal _output_ happens anyway. This becomes usable with
this commit. To facilitate logging-only usage further, also explicitly
disable terminal input, so that "terminal=yes" can be used for logging
without much interference with other things. (It'll still overwrite some
signal handlers, though.)
2014-12-02 20:36:55 +01:00
wm4 b6ca4a48e1 osc: always force mouse_move binding
So the OSC will still appear when using --no-input-default-bindings. It
also means it may override a user's mouse_move binding, but I guess
users who don't want the OSC should just use the --no-osc option.
2014-12-02 20:36:55 +01:00
wm4 29bc781b68 lua: fix broken error message
luaL_error() doesn't support %.*s, because it uses Lua's own format
string mechanism that just looks like the C one. Just drop this part.
2014-12-02 20:36:55 +01:00
wm4 d650fd21b1 player: don't signal an error if --stream-dump is used
The player thinks an error happened because no audio or video was played
after finishing the file, but this obviously makes no sense with stream
dumping. (error_playing follows the client API convention that negative
values are errors.)
2014-12-02 20:36:55 +01:00
wm4 980f3ea071 client API: print version on initialization
A rather big oversight, because a log produced with the client API will
not contain the mpv version at all otherwise.
2014-12-02 20:36:55 +01:00
wm4 a399339b95 player: don't ignore relative seeks by 0 seconds
I don't know why this done; most likely it had no real reason.

Remove it because it breaks "refresh seeks" to the same position.
(Although the refresh seeks mpv sometimes does were fine.)
2014-11-29 01:03:37 +01:00
wm4 87f5ba6ab3 command: avoid returning invalid FPS values
It's possible that fps is sometimes 0 in case it's unset.
2014-11-29 00:37:34 +01:00
wm4 a937ba203d player: reset frame step counter on seeks
I suppose this wasn't done in order to keep the frame step counter
active even in the next file, but actually it was reset anyway.
2014-11-29 00:27:17 +01:00
wm4 3295caca3d lua: add a function that formats Lua values as strings
Yep, Lua is so crappy that the stdlib doesn't provide anything like
this.

Repurposes the undocumented mp.format_table() function and moves it to
mp.utils.
2014-11-29 00:03:46 +01:00
wm4 70630fb803 player: simplify and fix ordered chapter EOF handling
Ordered chapter EOF was handled as special-case of ending the last
segment. This broke --kee-open, because it set AT_END_OF_FILE in an
"inconvenient" place (after checking for --keep-open, and before the
code that exits playback if EOF is reached).

We don't actually need to handle the last segment specially. Instead, we
remain in the same segment if it ends. The normal playback logic will
recognize EOF, because the end of the segment "cuts off" the file.

Now timeline_set_from_time() never "fails", and we can remove the old
segment EOF handling code in mp_seek().
2014-11-28 22:07:46 +01:00
wm4 78f0cb9281 command: sub_add with "auto" should not always select a subtitle track
Running "sub_add file.srt auto" during hook execution automatically
selected the first added track. This happened because all tracks added
with sub_add are marked as "external", and external subtitles are always
selected by default.

Fix this by negating the "external" flag when autoselecting subtitles
during loading. The no_default flag exists for this purpose; it was
probably added for libquvi originally, where we had the same issue.
2014-11-27 18:57:18 +01:00
wm4 a3026c9640 audio: alternative fix for previous commit
This is a somewhat obscure situation, and happens only if audio starts
again after it has ended (in particular can happens with files where
audio starts later). It doesn't matter much whether audio starts
immediately or some milliseconds later, so simplify it.
2014-11-27 18:52:22 +01:00
wm4 0ed77ca7e2 audio: fix busy loop when seeking while paused
When playing paused, the amount of decoded audio is limited to a small
amount (1 sample), because we don't write any audio to the AO when
paused. The small amount could trigger the case of the wanted audio
being too far in the future in the PTS sync code, which set the audio
status to STATUS_DRAINING, which in turn triggered the EOF code in the
next iteration. This was ok, but unfortunately, this triggered another
retry in order to check resuming from EOF by setting the status to
STATUS_SYNCING, which in turn lead to the busy loop by alternating
between the 2 states. So don't try resyncing while paused.

Since the PTS syncing code also calls ao_reset(), this could cause the
pulseaudio daemon to consume some CPU time as well.

This was caused by commit 33b57f55. Before that, the playloop was merely
run more often, but didn't cause any problems.

Fixes #1288.
2014-11-27 10:19:28 +01:00
ChrisK2 67f775bfbb ytdl: bump requrired youtube-dl version to 2014.11.26 2014-11-26 17:41:15 +01:00
ChrisK2 13845cf6fe ytdl: Try to handle multi-arc videos
this currently uses a sketchy but apparently working workaround,
which will be removed once the neccessary changes in youtube-dl
are implemented

Fixes #1277
2014-11-26 17:36:23 +01:00
ChrisK2 07ddfd4f8a ytdl: When using DASH, print actual duration
prints the actual duration as reported by youtube-dl to the
terminal when available
2014-11-26 17:17:05 +01:00
wm4 78f59df6ed client API: make sure youtube-dl is not used by default
Currently, --ytdl is off by default, but even if this is changed, never
enable it by default for the client API. It would be inappropriate to
start an intrusive external subprocess behind the host application's
back.
2014-11-25 17:27:19 +01:00
wm4 7d6e58471f audio: make mp_audio_config_to_str return a stack-allocated string
Simpler overall.
2014-11-25 11:11:31 +01:00
wm4 28b6ce39d3 audio: make mp_chmap_to_str() return a stack-allocated string
Simplifies memory management.
2014-11-24 19:56:01 +01:00
wm4 0c5fd5a047 lua: remove redundant call 2014-11-24 16:47:13 +01:00
wm4 89c1525585 lua: always handle key repeat on the script side
Simpler, and leaves the decision to repeat or not fully to the script
(instead of requiring the user to care about it when remapping a script
binding).
2014-11-24 16:47:03 +01:00
wm4 2a017734a5 lua, ipc: remove leftovers
MPV_EVENT_SCRIPT_INPUT_DISPATCH is now unused/deprecated.

Also remove a debug-print from defaults.lua.
2014-11-24 10:33:55 +01:00
wm4 5bbd734fff command: don't queue framesteps
If repeated framestep commands are sent, just unpause the player, instead
of playing N frames for N repeated commands.
2014-11-23 15:31:32 +01:00
wm4 17ee2ca524 player: don't crash when using sub_seek without subtitles
Recent regression. It turns out the assertion was completely unneeded.

Fixes #1285.
2014-11-23 15:13:35 +01:00
wm4 ae5df9be98 input, lua: redo input handling
Much of it is the same, but now there's the possibility to distinguish
key down/up events in the Lua API.
2014-11-23 15:13:35 +01:00
wm4 7b47f12f8f client API: restrict client names
Use a fixed size array for the client name, which also limits the client
name in size. Sanitize the client name string, and replace characters
that are not in [A-Za-z0-9] with '_'.
2014-11-23 15:13:34 +01:00
wm4 4cdd346246 input: set mouse area by default for all input
Otherwise, mouse button bindings added by mp.add_key_binding() would be
ignored.

It's possible that this "breaks" some older scripts using undocumented
Lua script functions, but it should be safe otherwise.

Fixes #1283.
2014-11-23 09:10:51 +01:00
James Ross-Gowan ef0d1cddb6 lua: subprocess: move to osdep/subprocess-{win,posix}.c
The subprocess code was already split into fairly general functions,
separate from the Lua code. It's getting pretty big though, especially
the Windows-specific parts, so move it into its own files.
2014-11-22 18:15:13 +11:00
James Ross-Gowan 060bf43d02 lua: subprocess: use macros for SetHandleInformation
Apparently both parameters refer to the same set of flags (the first is
a mask for which flags to set.)
2014-11-22 18:15:11 +11:00
James Ross-Gowan d2848daebb lua: subprocess: fix handle inheritance race condition
Normally, when creating a process with inherited handles on Windows, the
process inherits all inheritable handles from the parent, including ones
that were created on other threads. This can cause a race condition,
where unintended handles are copied into the new process, preventing
them from being closed correctly while the process is running. The only
way to prevent this on Windows XP was to serialise the creation of all
inheritable handles, which is clearly unacceptable for libmpv.

Windows Vista solves this problem by allowing programs to specify
exactly which handles are inherited, so do that on Vista and up.

See http://blogs.msdn.com/b/oldnewthing/archive/2011/12/16/10248328.aspx
2014-11-22 18:15:10 +11:00
James Ross-Gowan 6a1746b4e3 lua: subprocess: fix Ctrl+C handling on Windows
The CREATE_NO_WINDOW flag is used to prevent the subprocess from
creating an empty console window when mpv is not running in a console.
When mpv is running in a console, it causes the subprocess to detach
itself, and prevents it from seeing Ctrl+C events, so it hangs around in
the background after mpv is killed.

Fix this by only specifying CREATE_NO_WINDOW when mpv is not attached to
a console. When it is attached to a console, subprocesses will
automatically inherit the console and correctly receive Ctrl+C events.
2014-11-22 18:15:09 +11:00
James Ross-Gowan f2b94a3b49 lua: subprocess: cancel pending I/O before return
I'm not sure if this is necessary, but it can't hurt, and it's what
you're supposed to do before leaving the stack frame that contains the
OVERLAPPED object and the buffer. If there is no pending I/O, CancelIo
will do nothing and GetOverlappedResult will silently fail.
2014-11-22 18:15:08 +11:00
wm4 85fb2af369 Remove some superfluous NULL checks
In all of these situations, NULL is logically not allowed, making the
checks redundant.

Coverity complained about accessing the pointers before checking them
for NULL later.
2014-11-21 05:18:09 +01:00
wm4 00626817c8 lua: add a way to add repeatable key bindings
For these, autorepeat is enabled.
2014-11-21 00:01:59 +01:00
wm4 a1811211a2 command: dvd: better audio/video recovery on angle switching
Does the same thing as the drop_buffers command. When implementing that
command, it turned out that resetting the higher level playback state
was more effective for achieving smooth recovery.

Untested; I don't even have any DVDs or DVD images with multiple angles.
2014-11-20 22:45:02 +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
Jaime Marquínez Ferrándiz cf8efe3235 options: add --ytdl-format option for youtube-dl format
It's passed with the '--format' option to youtube-dl.

If it isn't set, we don't pass '--format best' so that youtube-dl can
use the options from its configuration file.

Signed-off-by: wm4 <wm4@nowhere>
2014-11-20 00:17:13 +01:00
wm4 079ecd7f01 player: integrate ytdl_hook.lua 2014-11-19 18:59:38 +01:00
ChrisK2 0f7df89468 lua: add youtube-dl hook script
This merely adds the file without using it, for the sake of retaining
authorship information.

Signed-off-by: wm4 <wm4@nowhere>
2014-11-19 18:37:39 +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 5d1a3fb406 command: improve A-B loop behavior
If the B point is set, then loop back to A.

Also, update the OSD bar if necessary.
2014-11-18 20:28:54 +01:00
James Ross-Gowan c644178098 lua: subprocess: support cancellation on Windows 2014-11-18 13:34:00 +01:00
James Ross-Gowan 67132750a6 lua: subprocess: use overlapped I/O on Windows
Instead of threads, use overlapped (asynchronous) I/O to read from both
stdout and stderr. Like in d0643fa, stdout and stderr could be closed at
different times, so a sparse_wait function is added to wrap
WaitForMultipleObjects and skip NULL handles.
2014-11-18 13:34:00 +01:00
wm4 4bd6c91d9b command: implement A-B loops
Probably needs to be polished a bit more. Also, might require a key
binding that can set/clear the loop points in a more intuitive way.

For now, something like this can be put into input.conf to use it:

ctrl+y set ab-loop-a ${time-pos}    # set A
ctrl+x set ab-loop-b ${time-pos}    # set B
ctrl+c set ab-loop-a no             # clear (mostly)

Fixes #1241.
2014-11-18 01:36:35 +01:00
wm4 469eb321e8 command: adjust previous commit
Due to the current code structure, the "current" entry and the entry
which is playing can be different. This is probably silly, but still
try to mark the entries correctly.

Refs #1260.
2014-11-17 22:48:38 +01:00
wm4 ebd41bdf6c command: playlist property: return if an entry is currently playing
This actually doesn't even write/return the new sub-property, because
I dislike the idea of dumping that field for every single playlist
entry, even though it's "needed" only for one.

Fixes #1260.
2014-11-17 22:16:52 +01:00
wm4 f4804b0c45 lua: subprocess: remove minor code duplication
Now that the code for stderr and stdout does exactly the same things,
and the specialization is in the callbacks, this is blatantly
duplicated.

Also, define a typedef for those callbacks to reduce the verbosity.
2014-11-16 19:18:23 +01:00
James Ross-Gowan ebccfc4351 lua: subprocess: add Windows implementation
Doesn't handle mp_cancel yet.
2014-11-16 18:08:02 +01:00
ahoka b4a147bbe2 man: document osc seekbarstyle option 2014-11-15 20:20:54 +01:00
ahoka e7b45b1efa osc: add validation for string user options 2014-11-15 20:20:52 +01:00
ahoka 6de303c339 osc: add seekbarstyle option 2014-11-15 20:20:50 +01:00
wm4 2125e49422 sub: workaround braindead libass API
libass won't use embedded fonts, unless ass_set_fonts() (called by
mp_ass_configure_fonts()) is called. However, we call this function when
the ASS_Renderer is initialized, which is long before the .ass file is
actually loaded. (I'm not sure why it tries to keep 1 ASS_Renderer, but
it always did this.)

Fix by calling mp_ass_configure_fonts() after loading them. This also
means this function will be called multiple times - hopefully this is
harmless (it will reinit fontconfig every time, though).

While we're at it, also initialize the ASS_Renderer lazily.

Fixes #1244.
2014-11-15 19:43:43 +01:00
wm4 508d236c9a command: list filters/VOs/AOs with option-info
Another special-case, but pretty simple after all.
2014-11-14 14:52:51 +01:00
wm4 5d12a2696e command: export some option metadata
This might be interesting for GUIs and such.

It's probably still a little bit insufficient. For example, the filter
and audio/video output lists are not available through this.
2014-11-13 18:01:27 +01:00
wm4 71168e740e command: rename "option-flags" property to "option-info" 2014-11-13 17:27:31 +01:00
wm4 13033ce2c4 command: make sub-properties more flexible
This makes it work with all kind of types, instead of just some simple
ones.
2014-11-13 17:26:22 +01:00
wm4 23e0682dd4 command: export mpv configure arguments as property
It seems strange that a client API user can't get this string, other
than analyzing the mpv log output.
2014-11-13 16:18:40 +01:00
wm4 a9ece6371f player: simplify audio uninit on segment switches
The purpose of temporarily setting stop_play was to make the audio
uninit code to explicitly drain audio if needed. This was the only way
to do it before ao_drain() was made a separate function; now we can just
do it explicitly instead.
2014-11-12 19:30:58 +01:00
wm4 f0efd0b100 audio: fix some issues when reloading the AO
We absolutely need to clear the AO reference in the mixer.

The audio_status must be changed to a state where no code assumes that
the AO is available. (It's allowed to do this blindly.)
2014-11-12 14:19:16 +01:00
wm4 88762cd6a7 player: make the osd-msg prefix work for playlist_next/prev
If input.conf e.g. contains "n osd-msg playlist_next", then pressing the
n key will switch to the next file, and display the filename on OSD.
2014-11-11 22:07:16 +01:00
wm4 5fd8a1e04c audio: make decoders output refcounted frames
This rewrites the audio decode loop to some degree. Audio filters don't
do refcounted frames yet, so af.c contains a hacky "emulation".

Remove some of the weird heuristic-heavy code in dec_audio.c. Instead of
estimating how much audio we need to filter, we always filter full
frames. Maybe this should be adjusted later: in case filtering increases
the volume of the audio data, we should try not to buffer too much
filter output by reducing the input that is fed at once.

For ad_spdif.c and ad_mpg123.c, we don't avoid extra copying yet - it
doesn't seem worth the trouble.
2014-11-10 22:02:05 +01:00
wm4 e094e9cb75 audio: change how filters are inserted on playback speed changes
Use a pseudo-filter when changing speed with resampling, instead of
somehow changing a samplerate somewhere. This uses the same underlying
mechanism, but is a bit more structured and cleaner. It also makes some
of the following changes easier.

Since we now always use filters to change audio speed, move most of the
work set_playback_speed() does to recreate_audio_filters().
2014-11-10 22:02:05 +01:00
wm4 c3d446ee2e player: don't try to use duration 0 2014-11-10 18:11:33 +01:00
wm4 cb13d7fadb dvd, bluray: reload demuxer on title changes
Causes the player to reload the demuxer and to relist the found
streams. Probably slightly dangerous/broken, because the demuxer
thread and possibly even the decoders will keep reading data from
the new title before the new demuxer takes over.

Fixes #1250.
2014-11-10 10:50:55 +01:00
Alessandro Ghedini 5f175b0bdc command: send property-change event on playlist change 2014-11-09 15:31:48 +01:00
wm4 3d7d1f3f26 video/out: minor simplification to event query function
The "clear" parameter is confusing and useless.
2014-11-09 10:01:16 +01:00
wm4 b021d038c2 audio/out: make ao_request_reload() idempotent
This is what you would expect. Before this commit, each
ao_request_reload() call would just queue a reload command, and then
recreate the AO for the number of times the function was called.

Instead of sending a command, introduce some sort of event retrieval
mechanism. At least for the reload case, use atomics, because we're too
lazy to setup an extra mutex.
2014-11-09 09:58:44 +01:00
wm4 7ee4e53369 audio: handle reinit after AO reload slightly cleaner
Don't print bogus messages about packets read in verbose mode.
2014-11-09 09:54:39 +01:00
wm4 33b57f5557 player: improve audio time display
This commit fixes a "cosmetic" user interface issue. Instead of
displaying the interpolated seek time on OSD, show the actual audio
time.

This is rather silly: when seeking in audio-only mode, it takes some
iterations until audio is "ready", but on the other hand, the audio
state machine is rather fickle, and fixing this cosmetic issue would be
intrusive. So just add a hack that paints over the ugly behavior as
perceived by the user. Probably the lesser evil.

It doesn't happen if video is enabled, because that mode sets the
current time immediately to video PTS. (Audio has to be synced to video,
so the code is a bit more complex.)

Fixes #1233.
2014-11-08 16:09:42 +01:00
wm4 9f239464da command: silence a warning on win32
Same goal as a change in the #1255 PR, but IMO slightly less
ifdefferish.
2014-11-08 10:24:26 +01:00
wm4 64f6e88c45 command: fix option-flags property
The sub-path wasn't adjusted, and it worked only in some situations.
2014-11-08 10:19:17 +01:00
wm4 1a5650b628 command: export the flag whether an option was set on commandline
Can be useful for certain scripts; I think someone requested this.
2014-11-07 16:33:41 +01:00
wm4 c6cf38a4dd client: remove redundant assignment
This is set by send_reply().
2014-11-07 16:21:03 +01:00
wm4 18ade94c89 client API: silence silly clang warning
The values compared here happen to be of unsigned enum types - but the
test is not supposed to break if we somehow force the enum to signed, or
if the compiler happens to use a signed type (as far as I remember, the
exact integer type the compiler can use is implementation-defined).
2014-11-07 15:58:51 +01:00
Kevin Mitchell 351608e5cc command: add display-names property
Call VOCTRL_GET_DISPLAY_NAMES it when the property is
requested. The vo should return the names of the displays that the mpv
window is covering.  For example, with x11 vos, xrandr names LVDS1,
HDMI1, etc.
2014-11-07 01:14:03 -08:00
wm4 ea613c2592 command: use playback time as reference for sub_seek
update_subtitle() already uees playback_pts to make subtitles work
better in no-audio mode. Using get_current_time() usually gets
playback_pts, but also has the advantage that it will use the seek
target time during seeks. This will result in multiple sub_seek commands
doing the right thing (at least as long as they're far enough apart so
that seeking is actually initiated when the second command is run).
2014-11-05 18:47:12 +01:00
wm4 5e9dfe932f player: fix --secondary-sid
Use the "default" selection for the ff-index, not the "no" selection.

Broken by commit f0f83ff.
Fixes #1243.
2014-11-04 18:53:36 +01:00
wm4 416c86f3cb command: add window-minimized property (X11 only)
More or less requested by #1237.

Should be simple to extend this to other backends.
2014-11-02 20:55:07 +01:00
wm4 4e2574f025 command: make window-scale property observable
Add a generic mechanism to the VO to relay "extra" events from VO to
player. Use it to notify the core of window resizes, which in turn will
be used to mark all affected properties ("window-scale" in this case) as
changed.

(I refrained from hacking this as internal command into input_ctx, or to
poll the state change, etc. - but in the end, maybe it would be best to
actually pass the client API context directly to the places where events
can happen.)
2014-11-02 20:53:56 +01:00
wm4 3a95a0887c command: expose mpv version as property
A client API user has no other way to know the version.
2014-11-02 17:44:24 +01:00
wm4 975e98b3fe player: print anamorphic size only if video is anamorphic
Has been annoying me since forever.
2014-11-02 17:34:02 +01:00
wm4 969757baa0 player: always use demux_chapter
Instead of defining a separate data structure in the core.

For some odd reason, demux_chapter exported the chapter time in
nano-seconds. Change that to the usual timestamps (rename the field
to make any code relying on this to fail compilation), and also remove
the unused chapter end time.
2014-11-02 17:29:41 +01:00
wm4 1cebd16350 player: add --chapters-file option
Note that you can't pass .cue or .edl files to it, at least not yet.

Requested in context of allowing to specify custom chapters. For that
to work well, we probably need to add some sort of chapter metadata
pseudo-demuxer.
2014-11-02 17:23:04 +01:00
wm4 0c3df23335 osd: properly wakeup when the OSD function disappears
Fixes #1236.
2014-11-01 17:32:34 +01:00
wm4 dab6cbca16 player: update meaning of drop_frame_cnt
Rename the variable, update comments, and update the documentation of
the property which returns its value.
2014-11-01 01:07:21 +01:00
wm4 0e97808fc5 player: show AV-desync message in all framedrop modes
This was shown only if decoder-framedropping was enabled, and only if at
least 50 frames were dropped by it. Since drop_frame_cnt used to mean
"number of late frames", this code made sense, but this is not the case
anymore: drop_frame_cnt can be even 0, all while video gets hopelessly
behind audio.

One problem with this is that short desync spikes (which usually can
probably dealt with) will also cause this message to be shown. If it
gets triggered too often, the code will need to be adjusted.
2014-11-01 01:06:22 +01:00
wm4 3f3a6b13bd sub: remove osd_get_sub()
Trades one strange thing against another, but seems slightly less
strange.
2014-11-01 00:02:01 +01:00
wm4 13d408fe8d sub: be more flexible about changes to how subtitles are rendered
For example, if --force-window is used, and video is switched off during
playback, then you need to redecide the rendering method to get subs
displayed correctly.

Do this by moving the state setup code into a function, and call it on
every frame.
2014-10-31 23:43:22 +01:00
wm4 b17585e636 player: change framedrop display in the status line
Hopefully less confusing, and hopefully doesn't exceed the terminal
width in any situation.
2014-10-31 01:01:58 +01:00
wm4 6ddd2b8e03 player: improve exit message in some scenarios
If you played e.g. an audio-only file and something bad happened that
interrupted playback, the exit message could say "No files played".
This was awkward, so show a different message in this case.

Also overhaul how the exit status is reported in order to make this
easier. This includes things such as not reporting a playback error
when loading playlists (playlists contain no video or audio, which
was considered an error).

Not sure if I'm happy with this, but for now it seems like a slight
improvement.
2014-10-31 00:51:52 +01:00
wm4 2bb02879aa player: don't display zero duration for files with unknown duration
On OSD/terminal, just don't display the duration if unavailable.

Make the "length" property unavailable if duration is unavailable.
2014-10-29 21:54:59 +01:00
wm4 2c320fb609 player: add an option to abort playback on partial init failures
This is probably what libmpv users want; and it also improves error
reporting (or we'd have to add a way to communicate such mid-playback
failures as events).
2014-10-28 20:30:12 +01:00
wm4 0c71ae0528 player: handle DVB demuxer reloading correctly
This was probably done incorrectly in cases when the currently selected
channel had no data. I'm not sure if this codepath is functional at all,
though. Maybe not.

Untested due to lack of DVB hardware.
2014-10-28 20:30:12 +01:00
wm4 65db3291b3 client API: better error reporting
Give somewhat more information on playback failure.
2014-10-28 20:30:12 +01:00
wm4 3cde02fe22 client API: add an enum for mpv_event_end_file.reason
Using magic integer values was an attempt to keep the API less verbose.
But it was probably not a good idea.

Reason 1 (restart) is not made explicit, because it is not used anymore
starting with the previous commit. For ABI compatibility, the value is
left as a hole in the enum.
2014-10-28 20:30:12 +01:00
wm4 77b06fa017 player: handle edition reloading slightly differently
Use the codepath that is normally used for DVD/BD title switching and
DVB channel switching. Removes some extra artifacts from the client API:
now MPV_EVENT_END_FILE will never be called on reloads (and neither is
MPV_EVENT_START_FILE).
2014-10-28 20:30:12 +01:00
Alessandro Ghedini 650e889752 command: play the correct entry with loadfile ... append-play
The playlist may be non-empty even if the player is idle. Instead of playing the
first entry, play the entry that was just added.
2014-10-27 21:50:43 +01:00
wm4 963edf5765 player: don't spam video-reconfig event
Without --force-window, this is called on every iteration or so, and
calling uninit_video_out() sends the video-reconfig event. Avoid sending
redundant events.

Fixes #1225 (using an alternative patch).
2014-10-27 21:05:21 +01:00
Alessandro Ghedini c18cf4394d command: try 'icy-title' metadata for media-title as well 2014-10-27 16:21:50 +01:00
wm4 dced2aa81b command: add audio-device property
Meant for changing the --audio-device at runtime.
2014-10-27 12:18:25 +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 f2d51171f7 lua: subprocess: fix dumb 2014-10-26 01:52:31 +02:00
wm4 d0643fa02d lua: subprocess: tunnel stderr through mp_log
Pretty much a fringe-feature, but also it's awkward if something appears
on the terminal with no indication for the source.

This is made quite awkward by the fact that stderr and stdout could be
closed at different times, and that poll() doesn't accept "holes" in its
FD list. Invalid (.e.g negative) FDs just make it return immediately, as
required by the standard. So sparse_poll() takes care of the messy
details.
2014-10-26 01:40:36 +02:00
wm4 38546d5a99 lua: parse_json(): fix inverted condition for trail argument
It accidentally had the opposite meaning.
2014-10-26 01:40:36 +02:00
wm4 0cfada604d lua: subprocess: don't distinguish pipe errors/EOF
What was the purpose of that? Probably none.

Also simplify another thing: if we get the cancel signal through FD,
there's no reason to check it separately.
2014-10-26 01:40:36 +02:00
wm4 9b45b48c46 Drop libquvi support
No development activity (or even any sign of life) for almost a year.

A replacement based on youtube-dl will probably be provided before the
next mpv release. Ask on the IRC channel if you want to test.

Simplify the Lua check too: libquvi linking against a different Lua
version than mpv was a frequent issue, but with libquvi gone, no
direct dependency uses Lua, and such a clash is rather unlikely.
2014-10-25 20:18:22 +02:00
wm4 5b91f89852 lua: fix some more lua_tostring() mistakes
Why can't it just raise an error?
2014-10-25 17:20:25 +02:00
wm4 ef252b2314 lua: lua_tostring() on an error value can return NULL
Lua is so clever it allows values that can't be converted to strings, in
which case lua_tostring() returns NULL. Trigger undefined behavior.
2014-10-24 21:57:06 +02:00
wm4 55e3dab7eb command: finish hook execution if client fails
Translation: if the (to be added) youtube-dl Lua script crashes, don't
wait forever when opening something.
2014-10-24 21:57:02 +02:00
wm4 f1481df0b6 command: add vo-configured property
So a client API user can know when a window is created or destroyed.

Also might be useful for the OSC: it could disable itself if video is
disabled.

Before this commit, there were only indirect ways of detecting this.
2014-10-24 15:34:53 +02:00
wm4 96b339fc07 player: disable --force-window if VO fails
Otherwise, it'd retry creating the window all the time.
2014-10-24 15:34:39 +02:00
wm4 f4ad398b28 video: send MPV_EVENT_VIDEO_RECONFIG on uninit
This event basically means "something about video changed", and uninit
is certainly an important change.
2014-10-24 15:34:28 +02:00
wm4 db86eaad3d player: adjust uninit order of components
Most things should be allowed to access the client API unconditionally
(for example for sending events), so move destroying the client API
down. Also, mp_uninit_ipc() should happen before the point at which all
clients are shutdown, or there will be a small time window in which new
clients can be created after destroying them all.
2014-10-24 15:34:04 +02:00
wm4 986d15ea9c command: fix debug output
It was a bit ugly/annoying.
2014-10-24 13:42:02 +02:00
ChrisK2 223d9b6bc9 osc: make text squuezing layout dependent
Wether and when the text of a button should be squeezed when it
gets too long can now be configured in the layout:

lo.button.maxchars = <number>
nil = no squeezing (default)

If the button text has more than <maxchars> characters, it will
be squeezed to the estimated width of <maxchars>.
2014-10-24 01:56:15 +02:00
ChrisK2 bff5948f00 osc: make tooltip_an default property 2014-10-24 01:16:04 +02:00
wm4 c9234d769d player: fix exiting if both audio and video fail initializing
The player was supposed to exit playback if both video and audio failed
to initialize (or if one of the streams was not selected when the other
stream failed). This didn't work; for one this check was missing from
one of the failure paths. And more importantly, both checked the
current_track array incorrectly.

Fix these issues, and move the failure handling code into a common
function.

CC: @mpv-player/stable
2014-10-23 18:31:43 +02:00
wm4 626dcf1772 lua: fix non-sense
Let's actually test our code next time.
2014-10-23 15:13:05 +02:00
wm4 7cf18a8db9 client API: print properties set with -v
Useful for debugging. Considered doing this in command.c, but it's
easier here.
2014-10-23 15:13:05 +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
Martin Herkt 5a3c6563e4 osc.lua: add “bottombar” and “topbar” layouts 2014-10-23 13:02:32 +02:00
wm4 41c91d87d6 command: return error on invalid/absent IDs with ff-sid/ff-aid
Instead of just disabling the stream.

Also, check if the selected track has the right type, or we'd crash.
2014-10-23 12:03:26 +02:00
wm4 be950351d9 player: show busy symbol on OSD if seeking takes too long
Same as it's done on the terminal.
2014-10-22 16:11:44 +02:00
wm4 65ba6f9f57 lua: don't let temporary values take the place of arguments
Because Lua is so terrible, it's easy to confuse temporary values pushed
to the Lua stack with arguments if the arguments are checked after that.

Add a hack that should fix this.
2014-10-22 01:10:15 +02:00
wm4 7eb047b241 command: make reverse cycle_values match up with forward one
The behavior of reverse cycling (with the "!reverse" magic value) was a
bit weird and acted with a "delay". This was because the command set the
value the _next_ command should use. Change this and make each command
invocation select and use the next command directly. This requires an
"uninitialized" special index in the counter, but that is no problem at
all.
2014-10-21 23:55:32 +02:00
wm4 4d5903f915 command: fix video-rotate update when paused
Due to the way video-rotate currently works, the state will be
automatically updated once new video is decoded. So the filter chain
doesn't need to be reinitialized automatically, but there is a need to
trigger the video instant refresh code path instead.

Also move the support function closer to an annoying similar yet
different function. They probably can be unified next time major changes
are done to this code.
2014-10-21 23:34:56 +02:00
wm4 bd315dfaf9 lua: don't use "output" as identifier
I suspect this clashes with libcs,w hich define "stdout" as macro.
Hopefully fixes #1206.
2014-10-21 13:44:21 +02:00
wm4 bc1893e036 command: add cursor-autohide property
Allows properly changing/updating the cursor state. Useful for client
API window embedding, because the host application may not want the mpv
window to grab mouse input, and this has to manually handle the cursor.
Changing the cursor of foreign windows is usually not sane.

It might make sense to allow changing the cursor icon, but that would be
much more complicated, so I won't add it unless someone actually
requests it.
2014-10-21 13:42:15 +02:00
wm4 0fa9e2bff0 command: add playback-abort property
Now this is obscure.
2014-10-21 13:38:41 +02:00
wm4 cdbc865ad0 command: add video-rotate property 2014-10-21 13:31:30 +02:00
wm4 f0f83ff366 player: add stream selection by ffmpeg index
Apparently using the stream index is the best way to refer to the same
streams across multiple FFmpeg-using programs, even if the stream index
itself is rarely meaningful in any way.

For Matroska, there are some possible problems, depending how FFmpeg
actually adds streams. Normally they seem to match though.
2014-10-21 13:19:20 +02:00
wm4 bcc3d72995 sd_lavc: strictly letter-box PGS subtitles
Getting subtitle scaling and positioning right even if there are video
filters, which completely change the image (like cropping), doesn't seem
to have a single, correct solution. To some degree, the results are
arbitrary, so we may as well do what is most useful to the user.

In this case, if the PGS resolution aspect ratio and the video output
aspect ratio mismatch, letter-box it, instead of stretching the subs
over the video frame. (This will require additional fixes, should it
turn out that there are PGS subtitles which are stretched by design.)

Fixes #1205.
2014-10-21 11:37:32 +02:00
Kevin Mitchell 599c510902 command: add field-dominance property 2014-10-21 00:55:15 +02:00
wm4 40d6b5ca85 lua: add convenience function for hooks
So the user doesn't have to care about the awkward low-level details.
2014-10-21 00:38:56 +02:00
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 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 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 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 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
Stefano Pigozzi 7e66a35969 fix build on OS X and BSD 2014-10-19 12:55:29 +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 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
Alessandro Ghedini 13039414f5 input: implement JSON-based IPC protocol 2014-10-17 20:46:31 +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 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
shdown dc5d60611e player: quote %-starting strings
Leading percent sign is a quote indicator so it needs to be quoted
itself.
2014-10-16 21:17:01 +02:00
wm4 0e0dc5c5be player: fix crash on early audio uninit
Could crash when exiting playback in very early stages of
initialization.

CC: @mpv-player/stable
2014-10-16 01:03:02 +02:00
wm4 5a6a5695bb player: free subtitle renderer on exit
This was probably commented as an oversight. Since the subtitle renderer
was uninitialized on reinitialization anyway, this had no negative
consequences, except a memory on exit.
2014-10-16 01:01:27 +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 bc0ed90481 command: allow setting per-file options at runtime
The intended use-case is for doing this at load time, after the load
command was issued. (See following commit.)
2014-10-15 22:39:33 +02:00
wm4 7c69848e3e player: fix OSD cycling
OSD cycling attempted to remove the current message by setting an empty
message with duration 0. Duration 0 tripped up a corner case causing no
OSD to be displayed (until the next message was set), so exclude this
explicitly.
2014-10-14 19:20:36 +02:00
wm4 5bddff6a24 client API: allow returning float properties as integers
I'm starting to think that being type-strict with this interface
actually sucks. This commit is a step towards being less strict.
2014-10-14 15:54:03 +02:00
wm4 596231bc97 player: fix --frames
This could produce an extra frame, because reaching the maximum merely
signals the playloop to exit, without strictly enforcing the limit.

Fixes #1181.

CC: @mpv-player/stable
2014-10-14 13:29:38 +02:00
wm4 b9077214cf command: don't display non-sense if volume is unavailable
Showed "Volume: (unavailable)%". That was dumb.

The message string is now a bit convoluted; mostly because the property
expand syntax can't do "if-else", just "if".

CC: @mpv-player/stable
2014-10-11 21:35:08 +02:00
wm4 a3bf75279e command: make volume/mute unavailable if audio is not initialized
This does nothing good. This reverts a change made over a year ago - I
don't remember why this was originally done this way.

The main problem is that even if the volume option is set (something
like "--volume=75"), the volume property will always return "100" until
audio is initialized. If audio is uninitialized again, the volume
property will remain frozen at its last value.
2014-10-11 21:35:08 +02:00
James Ross-Gowan 2782f06491 client API: check result ptr in mpv_command_node
This follows the docs, which say the result parameter is optional.
2014-10-12 00:56:41 +11:00
wm4 c5c21abf78 lua: add command_native() function
This is the Lua equivalent of mpv_command_node().
2014-10-11 00:33:09 +02:00
wm4 63e2b6c4ae client API: add mpv_command_node[_async]
Allows passing native types as arguments.

Also some minor doc improvements, including giving some (natural)
improvements to mpv_free_node_contents().

Note: mpv_command_node_async() is completely untested.
2014-10-11 00:33:09 +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 2f28e071c8 command: make audio device list available to the client API 2014-10-10 19:49:10 +02:00
wm4 8417d86ce6 player: fix terminal status in idle mode
That's what this variable is for. This was missed in commit 9d5d031b.
2014-10-10 18:54:47 +02:00
wm4 3fc9f9d132 player: don't mess up cursor visibility state
Manually setting can break things forever, because it puts the VO cursor
state out of sync with the remembered state by handle_cursor_autohide().
Use the normal autohide code during idle mode too instead. (Originally
the idea was to make the cursor always visible in idle mode, but not so
important.)

Regression since e1e8b07c. Fixes #1166.

CC: @mpv-player/stable
2014-10-10 18:51:44 +02:00
wm4 edad4fc29b audio: change internal device listing API
Now we run ao_driver->list_devs on a dummy AO instance, which will
probably confuse everyone. This is done for the sake of PulseAudio.
2014-10-10 18:27:21 +02:00
wm4 19d21103e5 player: exit if audio init fails and there's no video
Seems logical. For some reason, the player allows deselecting both audio
and video stream without quitting (a deliberate feature of which I have
no idea why it was added years ago), so this is needed.
2014-10-10 15:15:58 +02:00
wm4 299bf5c017 player: signal EOF when using --frames 2014-10-10 15:14:11 +02:00
wm4 4758866a18 player: minor simplification 2014-10-10 15:13:04 +02:00
wm4 ad541c26f7 player: don't close audio device in gapless mode
I don't see much of a reason for this extra corner case.
2014-10-10 14:49:18 +02:00
wm4 f93419f6b2 player: --save-position-on-quit should always work (2)
This reimplements the feature reverted in the previous commit in a
different way.
2014-10-10 14:44:22 +02:00
wm4 d4b2a96d90 Revert "player: --save-position-on-quit should always work"
This reverts commit 45c8b97efb.

Some else complained (github issue #1163).

The feature requested in #1148 will be implemented differently in
the following commit.
2014-10-10 14:27:45 +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
Stefano Pigozzi ca353fcf92 libmpv/cocoa: make global events work and get rid of is_cplayer
After @frau's split of macosx_events from macosx_application, `is_cplayer' is
not needed anymore. At the moment only global events such as Media Keys and
Apple Remote work, because the VO-level ones were hardcoded to be disabled.
(that will be fix in a later commit ).
2014-10-09 22:14:41 +02:00
wm4 e96d6197d7 client API: add an explanatory comment
So someone reading this at least has a chance to find out what this is
needed for.
2014-10-09 21:23:46 +02:00
wm4 35649a990a audio: add device selection & listing with --audio-device
Not sure how good of an idea this is.

This commit doesn't add support for this to any AO yet; the AO
implementations will follow later.
2014-10-09 21:21:31 +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 bc6b8caa6d video: try harder to decode cover art picture only once
For cover art, we pretend that the video stream is infinite, but also
stop decoding once we have an image on the VO (this seems advantageous
for the case when strange filters are inserted or the VO image gets
lost). Since a while ago, the video chain started decoding 2 images
though ("Non-monotonic video pts: 0.000000 <= 0.000000"), which is
annoying and wasteful.

Improve this by handling a certain corner case at initialization, which
will decode a second image while the first one is still stuck in the
filter chain. Also, just in case there are filters which buffer a lot,
also force EOF filtering (which means we tell the filters to flush
buffered frames).

CC: @mpv-player/stable
2014-10-09 17:57:17 +02:00
wm4 69673271e8 player: don't reset buffering pausing state on seeks
This was added with commit 3cbd79b3, but it turns out this
unintentionally enables "real" pausing when seeking while buffering. It
was done for ensuring correct state of the "cache-buffering-state"
property, but it also turns out that this was unneeded (another variable
that is reset when seeking happens to take care of this).
2014-10-09 17:57:10 +02:00
wm4 0ec5d35d57 client API: introduce numeric log levels
Maybe using strings for log levels was a mistake (too broad and too
impractical), so I'm adding numeric log level at least for the receiver
side. This makes it easier to map mpv log levels to other logging
systems.

I'm still too stingy to add a function to set the log level by a numeric
value, though.

The numeric values are not directly mapped to the internal mpv values,
because then almost every file in mpv would have to include the client
API header.

Coalesce this into API version 1.6, since 1.6 was bumped just yesterday.
2014-10-08 14:17:33 +02:00
wm4 cd367198c0 player: minor cosmetic change 2014-10-08 00:24:35 +02:00
wm4 ac54f10490 player: remove unnecessary code
This part is already done by open_stream_async().
2014-10-07 22:13:36 +02:00
wm4 3cbd79b35b command: add cache-buffering-state property 2014-10-07 22:13:36 +02:00
wm4 128bb68d29 client API: clarify pause/unpause events, modify core-idle property
Whether you consider the semantics weird or not depends on your use
case, but I suppose it's a bit confusing anyway. At this point, we keep
MPV_EVENT_PAUSE/UNPAUSE for compatibility only.

Make the "core-idle" property somewhat more useful in this context.
2014-10-07 21:01:19 +02:00
wm4 ec7bc388d1 matroska: look for all known matroska file extensions
For segment linking (this mechanism matches file extensions to avoid
opening files which are most likely not Matroska files in order to speed
up scanning).
2014-10-06 22:33:21 +02:00
wm4 a9e6ba1b9a osd: don't let slow commands cut OSD messages short
Done for screenshot commands, requested by a user.
2014-10-06 22:19:24 +02:00