Commit Graph

1055 Commits

Author SHA1 Message Date
wm4 8a4239e0c2 player: dump list of satisfied deps instead of config.h with -v
Starting to get tired of seeing the full config.h in verbose output
every time. Make it slightly more elegant by outputting the list of
satisfied dependencies instead.
2015-03-11 23:33:05 +01:00
wm4 e9841630ad command: allow changing some VO options even if VO wasn't created yet
Instead of refusing to set properties like "fullscreen" if no VO was
created, always allow it. So if no VO is created, setting the property
merely changes the options (and will be applied once the VO is created).
This is consistent with similar behavior changes to some other
properties.

Improves the behavior reported in #1676.

Also, we shouldn't check the config_ok variable - the VO should do this.
2015-03-11 12:10:04 +01:00
wm4 ca474d22c9 player: fix crash when taking screenshots in idle mode
mpctx->filename is obviously not set if no file is playing.

When this code was written, it probably couldn't happen, because the
normal screenshot path fails much earlier in idle mode. But you can
still take screenshots in "full window" mode, and recently the
screenshot code was changed to use the "full window" mode if the normal
path does not work.
2015-03-11 12:02:31 +01:00
wm4 da46a13c6b audio: cut audio with spdif too on playback restart
When playback is started after seeking or opening a file, we need to
make sure audio and video line up exactly. This is done by cutting or
padding the audio stream to start on the video PTS.

This does not quite work with spdif: audio is compressed data, within a
spdif frame. There is no way to cut the audio "in between" the frames.
Cutting between the frames would just produce broken spdif packets, and
who knows how receivers will react to this (play noise?). But we still
can cut it in frame boundaries.

Unfortunately, we also insert 0 data for "silence" - we probably
shouldn't do this. Chances are the receiver will switch to PCM or so.
But for now this will have to do.

Note that this could be simplified somewhat, as soon as we work with
frames. See previous commit.
2015-03-10 15:17:57 +01:00
wm4 574bd127ec command: add display-fps property
Requested. Untested; leaving that to the users.
2015-03-10 14:50:56 +01:00
wm4 30b0a5b98a player: restore --dump-stats
Since the recent refactoring, it was initialized _before_ the command
line player options were set, and consequently could not be enabled.
2015-03-10 09:50:32 +01:00
wm4 89db92398e audio: refuse to change playback speed with spdif
Handle the failure gracefully, instead of exploding and disabling audio.
Just set the speed back to 1.0.

Also remove the AF_DETACH from af_scaletempo. This actually created a
dangling pointer in af_add(), a tricky consequence of af_add()
reconfiguring the filter chain and the newly added filter using
AF_DETACH. Fortunately the AF_DETACH is not needed (and probably never
worked - it comes from MPlayer times, and MPlayer also disables audio
when trying to change speed with spdif).
2015-03-07 20:34:05 +01:00
wm4 b2099f55d2 audio: make changing playback speed slightly more robust
Always use af_scaletempo if it's inserted, even if the option
--audio-pitch-correction=no is set.

Make sure all filters are reset on speed change. It's conceivable that
dynamic changes to the filter chain at runtime leave filters around
without resetting their speed parameters.

Also move the code to a separate function.
2015-03-07 20:27:13 +01:00
torque 4ff29f33b0 Lua: add unpack shim for Lua 5.2/5.3 compatibility.
The global unpack function got moved to table.unpack in Lua 5.2, and
it's only available as the global if 5.2 is built with compatibility
enabled (the default). Lua 5.3 does not build with 5.1 compatibility by
default.

Fixes #1648.
2015-03-06 12:28:20 +01:00
wm4 720d4a5a1a player: allow changing playback speed in early audio init stages
If the audio decoder was created, but no audio filter chain created yet
(still trying to decode a first audio frame), setting the "speed"
property could explode. It tried to recreate the filter chain, even
though no format was set yet.

This is inconvenient and should not happen.
2015-03-06 12:15:03 +01:00
wm4 90496f3088 player: fix operation if command line is empty
main() being called with argc==0 is probably possible. Fix by skipping
the program name early. (I already changed and reverted this once, but
this time we make sure that it's less likely to confuse the skipped argv
with main()'s argv by naming it "options".)
2015-03-06 11:31:05 +01:00
wm4 2e26639155 player, client API: refactor cplayer init, reduce client API differences
Move the command line parsing and some other things to the common init
routine shared between command line player and client API. This means
they're using almost exactly the same code now.

The main intended side effect is that the client API will load mpv.conf;
though still only if config loading is enabled.

(The cplayer still avoids creating an extra thread, passes a command
line, and prints an exit status to the terminal. It also has some
different defaults.)
2015-03-05 11:22:15 +01:00
wm4 dcabceb626 player: minor simplification
argv is always terminated with a NULL, so we don't need to drag argc
along. Simplifies the following commit a little bit.
2015-03-05 10:57:38 +01:00
wm4 e35da1ac02 player: use symbolic constant for seek precision
Meh.
2015-03-04 17:31:36 +01:00
wm4 5c49fe97cb input: use flag option type for some input commands
This gets rid of the need for a second (or more) parameters; instead it
can be all in one parameter. The (now) redundant parameter is still
parsed for compatibility, though.

The way the flags make each other conflict is a bit tricky: they have
overlapping bits, and the option parser disallows setting already set
bits.
2015-03-04 17:31:36 +01:00
wm4 0bbf36b796 build: fix warnings with --disable-libass
This crap seems to break every other fullmoon.
2015-03-04 17:28:36 +01:00
wm4 89bc2975e9 audio: change playback speed directly in resampler
Although the libraries we use for resampling (libavresample and
libswresample) do not support changing sampelrate on the fly, this makes
it easier to make sure no audio buffers are implicitly dropped. In fact,
this commit adds additional code to drain the resampler explicitly.

Changing speed twice without feeding audio in-between made it crash
with libavresample inc ertain cases (libswresample is fine). This is
probably a libavresample bug. Hopefully this will be fixed, and also I
attempted to workaround the situation that crashes it. (It seems to
point in direction of random memory corruption, though.)
2015-03-02 19:09:44 +01:00
wm4 a4b6bf8c41 player: refine rar:// playlist-safety handling
It was possible to make the player play local files by putting rar://
links into remote playlists, and some other potentially unsafe things.

Redo the handling of it. Now the rar-redirector (the thing in
demux_playlist.c) sets disable_safety, which makes the player open any
playlist entries returned. This is fine, because it redirects to the
same file anyway (just with different selection/interpretation of the
contents). On the other hand, rar:// itself is now considered fully
unsafe, which means that it is ignored if found in normal playlists.
2015-03-02 19:09:36 +01:00
torque 1bbf1eb3ce Lua: add mp.get_screen_margins().
When used with mp.get_screen_size(), mp.get_screen_margins() allows a
Lua script to determine what portion of the mpv window actually has the
video in it.
2015-03-01 13:08:39 +01:00
wm4 d896f043e4 client API: make some more properties observable
A/V sync things.
2015-02-27 12:24:04 +01:00
wm4 a5f3083ae7 player: adjust A/V desync message
Broken drivers are an issue rather often. Maybe this gives the user an
idea that this could be the reason. (We can't dump much more info on a
80x24 terminal.)
2015-02-26 10:38:37 +01:00
Thiago Kenji Okada 633147c959 ytdl: add "--ytdl-params" option
This option allows the user to pass non-supported options directly to
youtube-dl, such as "--proxy URL", "--username USERNAME" and
'--password PASSWORD".

There is no sanity checking so it's possible to break things (i.e.
if you pass "--version" mpv exits with random JSON error).

Signed-off-by: wm4 <wm4@nowhere>
2015-02-25 22:32:48 +01:00
wm4 7cff2e4131 ytdl: add --no-warnings
Silences "[ytdl_hook] WARNING: video doesn't have subtitles", which was
an annoying and pointless message printed with almost all youtube
videos.
2015-02-24 10:58:09 +01:00
Jaime Marquínez Ferrándiz 7281a72fab ytdl: Adapt to new subtitles structure
The requested formats can be sorted by preference and the result gives now an url or the subtitles file content
2015-02-24 10:43:29 +01:00
wm4 636d6d724d encoding: allow encoding to channel configurations other than stereo
A while ago, we made mpv output the native number of channels by
default, instead of stereo. I assumed this was not wanted for encode
mode.

This commit keeps the assumption, but allows setting the number of audio
output channels at all, instead of always forcing stereo. (Pretty much a
hack.)
2015-02-23 16:25:12 +01:00
wm4 53867aa9d8 player: fix demuxer lifetime management
Commit f54220d9 attempted to improve this, but it got worse. Now there
was a crash when ytdl_hook.lua added external tracks. This happened
because close_unused_demuxers() assumed that sources[0] was the main
demuxer (so that it didn't close it). This assumption failed, because
the ytdl script can add external tracks before the main file is loaded.
The easy fix would have been to check for master_demuxer, and not i==0.
But instead give up on the old idea, make some stricter assumptions how
demuxers and external tracks map, and simplify the code.
2015-02-22 19:06:21 +01:00
wm4 1cac7d1a65 demux: add a demux_open_url() function
Often stream and a demuxer are opened at the same time. Provide a
function for this and replace most of its uses.
2015-02-20 21:56:55 +01:00
wm4 6aa6778ac4 demux: change demux_open() signature
Fold the relatively obscure force_format parameter into demuxer_params.
2015-02-20 21:21:14 +01:00
wm4 6c1355be96 demux: add free_demuxer_and_stream() function
Although their lifetimes are conceptually different, it happens often
that a demuxer is destroyed together with its stream.
2015-02-20 21:08:10 +01:00
wm4 44411674eb player: move timeline scanning (ordered chapters etc.) to a thread
Do timeline building (scanning & opening reference files for ordered
chapters, and more) in a thread. As a result, this process can actually
be stopped without having to kill the player.

This is pretty simple: just reuse the demuxer opening thread. We have
to give up on the idea that open_demux_reentrant() is reusable, though.

(Althoughthe timeline readers still need some fixes before they react to
the quit request.)
2015-02-20 20:30:05 +01:00
wm4 2c305d5b29 player: cosmetics: async/non-blocking -> reentrant
These functions do blocking work on a separate thread, but wait until
they return. So they are not async or non-blocking. But they do react to
user-input and client API accesses, which makes them reentrant.
2015-02-20 20:06:43 +01:00
wm4 102946ee03 player: enable cache and demuxer thread for subtitles too
Includes some logic for not starting the demuxer thread for fully read
subtitles. (Well, the cache will still waste _lots_ of resources, and
the cache always has to be created, because we don't know whether it'll
be needed _before_ opening the file.)

See #1597.
2015-02-18 21:12:57 +01:00
wm4 c7f450723f player: allow unsetting --term/osd-playing-msg
Treat an empty string as unset. The fact that the option values can be
NULL is merely weirdness due to how the option parser works (it
unfortunately doesn't initialize string fields to non-NULL).
2015-02-18 21:12:57 +01:00
wm4 d7a4cb14ff demux_edl: make independent from MPContext 2015-02-17 23:48:47 +01:00
wm4 1e44c811f3 demux_edl: move implementation
Same deal as with demux_cue, and a separate commit for the same reasons.
2015-02-17 23:48:39 +01:00
wm4 10781c2a9c demux_cue: make independent from MPContext
Also see previous commit(s).
2015-02-17 23:48:07 +01:00
wm4 7f03f46882 demux_cue: move implementation
Move the implementation, of which most was in tl_cue.c, to demux_cue.c.
Currently, this is illogical, because tl_cue.c still accesses MPContext.
This is going to change, and then it will be better if everything is in
demux_cue.c. This is only a separate commit to distinguish code movement
and actual work; the next commit will do the actual work.
2015-02-17 23:48:03 +01:00
wm4 edc0007e74 matroska: move timeline code to demux/
Separate from previous commit, because git is bad at tracking file
renames when the file contents are also changed.
2015-02-17 23:47:37 +01:00
wm4 5a186d5942 matroska: make timeline code independent of MPContext 2015-02-17 23:46:50 +01:00
wm4 a0a089f6a4 player: use a separate context for timeline loader stuff
Instead of accessing MPContext in player/timeline/*, create a separate
context struct, which the timeline loaders fill out. It turns out that
there's not much in the way too big MPContext that these need to access.

One major PITA is managing (and closing) the set of open demuxers. The
problem is that we need a list of all demuxers to make sure no unneeded
streams are enabled.

This adds a callback to the demuxer_desc struct, with the intention of
leaving to to the demuxer to call the right loader, instead of
explicitly checking the demuxer type and dispatching manually in common
code. I also considered making the timeline part of the demuxer state,
but decided against: it's too much of a mess wrt. memory management and
threading, and also doesn't make it clear who owns the child demuxers.
With the struct timeline decoupled from the demuxer state, it's at least
somewhat clear that the child demuxers are independent from the "main"
demuxer.

The actual changes to player/timeline/* are separated in the following
commits, because they're quite verbose. Some artifacts will be removed
later as soon as there's only 1 timeline loading mechanism.
2015-02-17 23:46:12 +01:00
wm4 969edb9e0b player: use a macro to remove an element from an array
Should be equivalent.
2015-02-17 23:43:43 +01:00
wm4 f54220d951 player: actually close files when using sub_remove
Also effects some other cases.

The real reason for this is for keeping track of which demuxers can be
closed (see following commit). Since I don't want to use reference
counting for this, some sort of simplistic mark-and-sweep is done to
determine whether a demuxer is still needed.
2015-02-17 23:43:13 +01:00
wm4 d26ba961d0 command: add rescan_external_files
Requested.

Hopefully will be useful for things that download and add external
subtitles on demand. Or something.

Closes #1586.
2015-02-16 22:08:16 +01:00
wm4 37183532ae command: nicer OSD message when setting audio-device
Requested.
2015-02-16 21:35:13 +01:00
wm4 2308b3a2a6 sub: mess with styling defaults, change --ass-use-margins behavior
Now --ass-use-margins doesn't apply to normal subtitles anymore. This is
probably the inverse from the mpv behavior users expected so far, and
thus a breaking change, so rename the option, that the user at least has
a chance to lookup the option and decide whether the new behavior is
wanted or not.

The basic idea here is:
- plain text subtitles should have a certain useful defalt behavior,
  like actually using margins
- ASS subtitles should never be broken by default
- ASS subtitles should look and behave like plaintext subtitles if
  the --ass-style-override=force option is used

This also subtly changes --sub-scale-with-window and adds the --ass-
scale-with-window option. Since this one isn't so important, don't
bother with compatibility.
2015-02-16 20:04:29 +01:00
wm4 816d7bba1f osxbundle: config file special case isn't needed anymore
The previous commit effectively fixes the mess caused by 'config' vs.
'mpv.conf', and the hack introduced by commit e01a6dac and extended by
commit db167cd4 isn't needed anymore.
2015-02-15 17:29:06 +01:00
wm4 a27aa68dd3 player: undeprecate 'config' files
Actually, it's pretty simple to look for multiple filenames at once,
since mp_find_all_config_files() is already a bit "special" anyway.

See #1569. Reverts most of commit db167cd4 (keeps osx-bundle.conf).
2015-02-15 14:28:49 +01:00
wm4 04472352ae player: fix audio-device-list updates
The way the AO wakes up the playloop has nothing to do with events;
instead we must query the events on the AO once the playloop was woken
up. Querying the events in every playloop iteration is thus the correct
way to do this.
2015-02-14 15:13:58 +01:00
Stefano Pigozzi 70802d519f ao_coreaudio: add support for hotplug notifications
This commit adds notifications for hot plugging of devices. It also extends
the old behaviour of the `audio-out-detected-device` property which is now
backed by the hotplugging code. This allows clients to be notified when the
actual audio output device changes.

Maybe hotplugging should be supported for ao_coreaudio_exclusive too, but it's
device selection code is a bit fragile.
2015-02-14 12:51:15 +01:00
wm4 5247416735 Fix build on OSX broken by previous commit
Hopefully.
2015-02-13 22:51:38 +01:00