Commit Graph

1107 Commits

Author SHA1 Message Date
wm4 6de3fe0b34 command: fix display-fps property (again)
This caused complaints because the fps was basically rounded on
microsecond boundaries in the vsync interval (it seemed convenient to
store only the vsync interval). So store the fps as float too, and let
the "display-fps" property return it directly.
2015-03-13 13:14:11 +01:00
wm4 9a7fc55607 command: display-fps is the display FPS as assumed by the VO
Requested change in behavior.

Note that we set the assumed "infinite" display_fps to 1e6, which
conveniently lets vo_get_vsync_interval() return a dummy value of 1,
which can be easily checked against, and still avoids doing math with
float INFs.
2015-03-12 23:41:25 +01:00
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
Julian 349067a6ab vf_vapoursynth: add display refresh rate property
This value is not necessarily trustworthy (it might change) and can be
0.
2015-02-13 22:35:47 +01:00
wm4 db167cd438 player: deprecate 'config' files (use mpv.conf), warn against clashes
Apparently there's at least one distro which ships a /etc/mpv/mpv.conf
file (mpv doesn't install such a file). This breaks config files named
'config' located in the user's mpv config directory, because mpv first
loads files named 'config' and then 'mpv.conf'. There is no mechanism
for putting files with different names into the same config path order.
(Even worse, that mpv.conf file only set an option to the default value.
Why do distros always do very stupid things?)

Print a warning on collisions.

Although using 'config' was well-supported, supporting both names is
starting to become messy, so deprecate 'config' and print a warning if
one is found.

At least we will be able to remove the whole mess once 'config' files
are ignored...

This also affects the osx-bundle, which intentionally used these not-so-
optimal semantics. Solve it in a different way. (Unfortunately with an
ifdef - it's not required, but having to explain everyone why mpv tries
to load a osx-bundle.mpv file on Linux and Windows would consume
energy.)

Closes #1569.
2015-02-13 22:28:44 +01:00
wm4 fd5403cb40 command: mark get_property as deprecated
Using it just makes no sense. But we're really being nice about this and
don't remove it immediately.
2015-02-13 21:48:11 +01:00
wm4 f9f2e1cc4e demux: hack for instant stream switching
This removes the delay when switching audio tracks in mkv or mp4 files.
Other formats are not enabled, because it's not clear whether the
demuxers fulfill the requirements listed in demux.h. (Many formats
definitely do not with libavformat.)

Background:

The demuxer packet cache buffers a certain amount of packets. This
includes only packets from selected streams. We discard packets from
other streams for various reasons. This introduces a problem: switching
to a different audio track introduces a delay. The delay is as big as
the demuxer packet cache buffer, because while the file was read ahead
to fill the packet buffer, the process of reading packets also discarded
all packets from the previously not selected audio stream. Once the
remaining packet buffer has been played, new audio packets are available
and you hear audio again.

We could probably just not discard packets from unselected streams. But
this would require additional memory and CPU resources, and also it's
hard to tell when packets from unused streams should be discarded (we
don't want to keep them forever; it'd be a memory leak).

We could also issue a player hr-seek to the current playback position,
which would solve the problem in 1 line of code or so. But this can be
rather slow.

So what we do in this commit instead is: we just seek back to the
position where our current packet buffer starts, and start demuxing from
this position again. This way we can get the "past" packets for the
newly selected stream. For streams which were already selected the
packets are simply discarded until the previous position is reached
again.

That latter part is the hard part. We really want to skip packets
exactly until the position where we left off previously, or we will skip
packets or feed packets to the decoder twice. If we assume that the
demuxer is deterministic (returns exactly the same packets after a seek
to a previous position), then we can try to check whether it's the same
packet as the one at the end of the packet buffer. If it is, we know
that the packet after it is where we left off last time.

Unfortunately, this is not very robust, and maybe it can't be made
robust. Currently we use the demux_packet.pos field as unique packet
ID - which works fine in some scenarios, but will break in arbitrary
ways if the basic requirement to the demuxer (as listed in the demux.h
additions) are broken. Thus, this is enabled only for the internal mkv
demuxer and the libavformat mp4 demuxer.

(libavformat mkv does not work, because the packet positions are not
unique. Probably could be fixed upstream, but it's not clear whether
it's a bug or a feature.)
2015-02-13 21:17:17 +01:00
wm4 96547a810e encoding: fixed-vo option was removed 2015-02-13 00:18:54 +01:00
wm4 aee0978d50 player: add a --loop=force mode
Requested. See manpage additions.

This also makes the magical loop_times constants slightly saner, but
shouldn't change the semantics of any existing --loop option values.
2015-02-12 22:41:45 +01:00
wm4 c59a4f12db osx: move code to unset input context to the right place
Setting the input context is always called, both in cplayer and libmpv,
and under HAVE_COCOA. Unsetting the input context was done only the
cplayer uninit call. Also it was under HAVE_COCOA_APPLICATION, so it was
not unset in libmpv (dangling pointer).
2015-02-12 21:18:23 +01:00
wm4 b8de478f51 osx: move cocoa specific call out of common code
This is almost equivalent, and gets rid of the ifdef.
2015-02-12 21:18:12 +01:00
wm4 e920a00eba player: drop explicit exit() calls
The code in main.c calls exit() explicitly, but the code is actually
easier to follow by simply exiting from main() instead. The exit() call
in av_log.c happens only on severely broken builds, so replace it with
abort().

(Shuts up rpmlint warnings.)
2015-02-12 17:28:22 +01:00
wm4 f061befb33 audio: add device change notification for hotplugging
Not very important for the command line player; but GUI applications
will want to know about this.

This only adds the internal API; support for specific audio outputs
comes later.

This reuses the ao struct as context for the hotplug event listener,
similar to how the "old" device listing API did. This is probably a bit
unclean and confusing. One argument got reusing it is that otherwise
rewriting parts of ao_pulse would be required (because the PulseAudio
API requires so damn much boilerplate). Another is that --ao-defaults is
applied to the hotplug dummy ao struct, which automatically applies such
defaults even to the hotplug context.

Notification works through the property observation mechanism in the
client API. The notification chain is a bit complicated: the AO notifies
the player, which in turn notifies the clients, which in turn will
actually retrieve the device list. (It still has the advantage that it's
slightly cleaner, since the AO stuff doesn't need to know about client
API issues.)

The weird handling of atomic flags in ao.c is because we still don't
require real atomics from the compiler. Otherwise we'd just use atomic
bitwise operations.
2015-02-12 17:17:41 +01:00
wm4 7bbc617019 Revert "player: make --force-window create the window immediately on start"
This reverts commit acc5e8f574.

As expected, some didn't like this. Others won't like this revert.
Whatever.

See #1561.

This should go into mpv 0.8.0 before it's released.
2015-02-12 12:01:12 +01:00
wm4 1d9134d044 player: use af_scaletempo when slowing down audio too
In my opinion the artifacts created by af_scaletempo on extreme slowdown
(50% or so) are too bothersome - but users disagree. So use
af_scaletempo on any speed changes, not just on speedup.
2015-02-12 11:58:35 +01:00
wm4 abbaaaa6e7 player: skip audio filter reinit on some types of speed changes
This avoids potentially dropping some small amount of audio data
buffered in filters.

Reinit can be skipped only if the filter is af_scaletempo (which maps to
AF_CONTROL_SET_PLAYBACK_SPEED). The other case using af_lavrresample is
much more complicated due to filter chain politics.

Also, changing speed between 1.0 and something higher typically inserts
or removes the filter, so this obviously requires reinitialization. It
can be prevented by forcing the filter with --af=scaletempo.
2015-02-10 22:48:15 +01:00
Ben Boeckel c9558e560e tl_matroska: only check the chapter count when adding chapters
Fixes #1445 without failing in the case where file outside.mkv with N
chapters references inside.mkv with N+1 chapters. Since we don't care
about the number of chapters in inner files (yet; nested chapters would
change this, but also make chapters dynamic anyways), don't check there.
2015-02-06 11:55:16 +01:00
Ben Boeckel aa9347883f tl_matroska: squeeze down the number of parameters
Much cleaner. The difference between timeline_info and
inner_timeline_info is that timeline_info is stuff the top-level cares
about and inner_timeline_info is just for the current chapter.
2015-02-06 11:55:15 +01:00
wm4 cfd3d5b520 player: do not autoload audio with audio files, enable autoloading
Autoload external audio files only if there's at least a video track
(which is not coverart pseudo-video).

Enable external audio file autoloading by default. Now that we actively
avoid doing stupid things like loading an external audio file for an
audio-only file, this should be fine.

Additionally, don't autoload subtitles if a subtitle is played.
Although you currently can't play subtitles without audio or video,
it's disturbing and stupid that the player might load subtitle files
with different extension and then fail.
2015-02-05 22:14:17 +01:00
wm4 868d0f1e83 matroska: warn against mismatching segments
Matroska ordered chapters require all segment files to have the same
layout. If a referenced file has more tracks than the main file or
misses some tracks, the file is invalid.

Also see issue #1553.
2015-02-04 23:04:21 +01:00
wm4 59dc351772 player: move timeline specific handling to timeline loaders
In particular, gets rid of the Matroska specifics from the common code.
2015-02-04 23:04:21 +01:00
wm4 e163284b68 command: add on_unload hook
Fixes #1552.
2015-02-04 23:04:01 +01:00
wm4 acc5e8f574 player: make --force-window create the window immediately on start
Before this change, window creation was delayed until the video was
initialized. This guaranteed that the first window size was that of the
video, so the WM would place it correctly.

Some time ago, it was requested on the IRC channel that --force-window
should not do this. Sometimes, it can take a while until video is
initialized, e.g. when youtube-dl is used (which incurs lots of network
delay). In this case, it's awkward that it takes so long until a window
(any window) is shown.

On the other hand, this can cause incorrect window placement with some
WMs. We simply hope that this won't happen with modern WMs. (Although it
does with the WM I use, crappy old IceWM.)
2015-02-03 23:19:38 +01:00
wm4 c3c714b059 player: remove --fixed-vo
In ancient times, this was needed because it was not default, and many
VOs had problems with it. But it was always default in mpv, and all VOs
are required to deal with it. Also, running --fixed-vo=no is not useful
and just creates weird corner cases. Get rid of it.
2015-02-03 23:11:08 +01:00
xylosper 95fd83a269 command: new commands audio_add/audio_remove/audio_reload
These commands are counterparts of sub_add/sub_remove/sub_reload which
work for external audio file.

Signed-off-by: wm4 <wm4@nowhere>
(minor simplification)
2015-02-03 13:53:39 +01:00
Stefano Pigozzi a3be14683a command: add property returning detected audio device
This can be useful to adjust some other audio related properties
at runtime depending on the audio device being used.
2015-02-03 00:40:02 +01:00
wm4 2a9534871d command: add property returning detected hwdec API
This is somewhat imperfect, because detection of hw decoding APIs is
mostly done on demand, and often avoided if not necessary. (For example,
we know very well that there are no hw decoders for certain codecs.)

This also requires every hwdec backend to identify itself (see hwdec.h
changes).
2015-02-02 22:43:13 +01:00
wm4 c07e046bfa player: add external audio file auto-loading
Apparently some people want this. Not enabled by default.

Fixes #967.
2015-02-02 21:23:12 +01:00
wm4 c8631b3b06 command: add properties returning the current VO and AO driver
This wasn't possible before.
2015-02-02 18:07:37 +01:00
wm4 ef827af06c client API: add mpv_wait_async_requests()
This does what it's documented to do.

The implementation reuses the code in mpv_detach_destroy(). Due to the
way async requests currently work, just sending a synchronous dummy
request (like a "ignore" command) would be enough to ensure
synchronization, but this code will continue to work even if this
changes.

The line "ctx->event_mask = 0;" is removed, but it shouldn't be needed.
(If a client is somehow very slow to terminate, this could silence an
annoying queue overflow message, but all in all it does nothing.)

Calling mpv_wait_async_requests() and mpv_wait_event() concurrently is
in theory allowed, so change pthread_cond_signal() to
pthread_cond_broadcast() to avoid missed wakeups.

As requested in issue #1542.
2015-02-02 18:07:37 +01:00
wm4 9d8b00f1d6 command: add dummy get implementation for tv-channel property
A small cosmetic change with the effect that pressing 'k' shows
"unavailable" instead of "error" (even if no  TV code is active).
2015-02-02 18:07:37 +01:00
wm4 5af4c81e5b player: dump audio jitter to stats file
This allows us to plot the difference between video timestamps, and the
adjusted video timestamps due to syncing video to audio speed.
2015-02-01 18:32:26 +01:00
wm4 720eb187fd command: send additional property change events in-between loading
Opening the stream and opening the demuxer are both done asynchronously,
meaning the player reacts to client API requests. They also can
potentially take a while. Thus it's better to process outstanding
property changes, so that change events are sent for properties that
were changed during opening.
2015-02-01 18:25:12 +01:00
wm4 77664895a1 command: improve observability of some audio properties
In particular, this would fix the sending the initial change event. It
was easily missed because MPV_EVENT_FILE_LOADED usually triggered it,
but the actual property could change only later, because audio
initialization really is kind of asynchronous to it.

This probably fixes #1544.
2015-02-01 18:21:48 +01:00
wm4 a169a2fb79 player: don't treat audio playback restart while paused special
I guess this was supposed to be some sort of optimization, but even
though it probably works, it's pretty meaningless and I couldn't measure
a difference. One special case killed.
2015-01-30 23:54:43 +01:00
wm4 48f96f43ec player: minor simplification in A/V-sync related code
Just minor things.
2015-01-30 23:49:30 +01:00
wm4 3813c3804f Revert "player: allow seeking audio between video frames"
This reverts commit 7b3feecbc2.

It's broken, hr-seek never ends at a video position before seek pts.
Not sure what I was thinking, although it did work anyway when
artificially forcing a video frame to display before seek pts.
2015-01-30 23:42:01 +01:00
wm4 a7c43babb7 player: print desync message on negative A/V-sync too
At least there is _some_ problem if this happens. It would mean that
audio is playing slower than video. Normally, video is synced to audio,
so if audio stops playback completely, video will not advance at all.
But using things like --autosync, it's well possible that this kind of
desync happens.
2015-01-30 21:26:29 +01:00
wm4 e123c1dfcd player: rearrange some A/V-sync related code
Move the update_avsync_before_frame() call further down. Moving it
closer to where the time_frame value is used (and which the function
updates) should make the code more readable. With this change, there's
no need anymore to reset the time_frame value on the video reconfig
path.

Move the update_avsync_after_frame() up. Now no meaningful amount of
time passes since the previous get_relative_time() call anymore, and the
second one can be removed.
2015-01-30 21:18:30 +01:00
wm4 9d57e7d23c player: use correct type for some relative times
We use double for these things everywhere, just this code didn't. It
likely doesn't matter much, and this code is for an optional feature
too.
2015-01-30 21:10:39 +01:00
wm4 1cd11c43ee command: change sub-visibility OSD message
Now it shows one of:
- "Subtitles hidden" (sub-visibility=no)
- "Subtitles visible" (sub-visibility=yes, sub!=no)
- "Subtitles visible (but no subtitles selected)" (otherwise)

It should be a bit more self-explanatory than before. On the other hand,
I have no clue about UI issues.

This also gets close to what's reasonably possible with the OSD
expansion string syntax, which is why it looks so awful.
2015-01-29 20:28:39 +01:00
wm4 cd41d1c7eb player: move more code out of central playloop function
...into its own functions. The central playloop function is still too
big, but looks much cleaner now.

No changes in functionality. The code moved to handle_playback_restart()
is unindented by 1 level and moving it out of the if condition around.
The if condition is inverted and early-exits from the function. Also
some comments are changed.
2015-01-29 15:15:13 +01:00
wm4 86d4094b98 player: remove redundant variable
mpctx->audio_delay always has the same value as opts->audio_delay. (This
was not the case a long time ago, when the audio-delay property didn't
actually write to opts->audio_delay. I think.)
2015-01-29 15:15:01 +01:00
wm4 7b3feecbc2 player: allow seeking audio between video frames
This allows seeking audio between two video frames that are relatively
far away.

The implementation of this is a bit subtle. It pretend the audio
position is different, and the actual PTS adjustment happens in audio.c
with this line:

    sync_pts -= mpctx->audio_delay - mpctx->delay;

Effectively this is the same as setting sync_pts to hrseek_pts after
this line, though. (I'm actually not sure if this could be written in a
more straightforward way; probably yes.)
2015-01-28 19:40:12 +01:00
wm4 7f7340ce76 player: enable hr-seek on audio after video end
Some files can have audio after video has ended, and playback of the
audio-only remainder is supposed to work just fine.

Seeking is broken-ish though. Not much can be done about this, since
it's the way demuxers work. Also, such files are obscure corner cases.
But enabling hr-seek for audio after video end can improve the situation
a lot.

This helps with issue #1533. The reported also provided a command line
to produce such a file:

    ffmpeg -i image.jpg -i audio.flac -threads $(nproc) \
        -c:v libvpx -crf 10 -qmin 5 -qmax 55 \
        -vf scale=360:-1 -sws_flags lanczos -c:a libvorbis -ac 2 \
        -b:a 128K out.webm
2015-01-28 19:40:12 +01:00
Diogo Franco (Kovensky) 631c256819 player: demote matroska ordered chapter scanning messages to Verbose
Causes a lot of terminal spam on large folders and is not actually
useful except maybe for debugging.
2015-01-28 11:43:48 +09:00
Ben Boeckel 2bbad06bfc ta: rename MP_TALLOC_ELEMS to MP_TALLOC_AVAIL
The macro actually returns the *available* space in the array, not how
much is actually filled in.
2015-01-27 18:09:36 +01:00
wm4 00b2611352 command: export more details about file seekability
If a file is unseekable (consider e.g. a http server without resume
functionality), but the stream cache is active, the player will enable
seeking anyway. Until know, client API user couldn't know that this
happens, and it has implications on how well seeking will work. So add a
property which exports whether this situation applies.

Fixes #1522.
2015-01-26 13:46:33 +01:00
wm4 792db4eee3 player: fix framestep over timeline segment boundaries
This was subtly broken by commit a937ba20. Instead of framestepping over
the timeline segment boundary, it would just unpause playback, because
seeking now resets mpctx->step_frames. This was especially apparent when
doing something like "mpv *.jpg --merge-files".

Fix by restoring the step_frames field specifically if the seek is done
for switching segment boundaries. Hopefully the number fields which need
such an exception on seeking won't grow and turn this code into a mess.
2015-01-26 12:29:27 +01:00
wm4 9b8d3acc8b options: list correct default value for --screenshot-template
Make the default value part of the option metadata, instead of doing
this in the screenshot code. Makes more sense with --list-options and
the command.c option metadata properties.
2015-01-26 11:38:23 +01:00
wm4 9cba451949 lua: do not use math.pow()
It's the first thing that breaks with Lua 5.3. I don't know if there
are other failures because I don't care enough.
2015-01-25 01:23:29 +01:00