summaryrefslogtreecommitdiffstats
path: root/player
Commit message (Collapse)AuthorAgeFilesLines
* Lua: add unpack shim for Lua 5.2/5.3 compatibility.torque2015-03-061-0/+2
| | | | | | | | | 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.
* player: allow changing playback speed in early audio init stageswm42015-03-061-1/+1
| | | | | | | | | 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.
* player: fix operation if command line is emptywm42015-03-061-10/+11
| | | | | | | 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".)
* player, client API: refactor cplayer init, reduce client API differenceswm42015-03-053-48/+51
| | | | | | | | | | | | | 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.)
* player: minor simplificationwm42015-03-051-3/+3
| | | | | argv is always terminated with a NULL, so we don't need to drag argc along. Simplifies the following commit a little bit.
* player: use symbolic constant for seek precisionwm42015-03-044-29/+43
| | | | Meh.
* input: use flag option type for some input commandswm42015-03-041-4/+11
| | | | | | | | | | 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.
* build: fix warnings with --disable-libasswm42015-03-041-2/+2
| | | | This crap seems to break every other fullmoon.
* audio: change playback speed directly in resamplerwm42015-03-021-10/+2
| | | | | | | | | | | | | 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.)
* player: refine rar:// playlist-safety handlingwm42015-03-021-3/+6
| | | | | | | | | | | | 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.
* Lua: add mp.get_screen_margins().torque2015-03-011-0/+12
| | | | | | 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.
* client API: make some more properties observablewm42015-02-271-1/+2
| | | | A/V sync things.
* player: adjust A/V desync messagewm42015-02-261-3/+3
| | | | | | 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.)
* ytdl: add "--ytdl-params" optionThiago Kenji Okada2015-02-251-0/+7
| | | | | | | | | | | 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>
* ytdl: add --no-warningswm42015-02-241-1/+1
| | | | | | Silences "[ytdl_hook] WARNING: video doesn't have subtitles", which was an annoying and pointless message printed with almost all youtube videos.
* ytdl: Adapt to new subtitles structureJaime Marquínez Ferrándiz2015-02-241-9/+11
| | | | The requested formats can be sorted by preference and the result gives now an url or the subtitles file content
* encoding: allow encoding to channel configurations other than stereowm42015-02-231-1/+3
| | | | | | | | | | 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.)
* player: fix demuxer lifetime managementwm42015-02-222-52/+43
| | | | | | | | | | | 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.
* demux: add a demux_open_url() functionwm42015-02-201-9/+3
| | | | | Often stream and a demuxer are opened at the same time. Provide a function for this and replace most of its uses.
* demux: change demux_open() signaturewm42015-02-201-10/+10
| | | | Fold the relatively obscure force_format parameter into demuxer_params.
* demux: add free_demuxer_and_stream() functionwm42015-02-201-9/+4
| | | | | Although their lifetimes are conceptually different, it happens often that a demuxer is destroyed together with its stream.
* player: move timeline scanning (ordered chapters etc.) to a threadwm42015-02-201-7/+15
| | | | | | | | | | | | 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.)
* player: cosmetics: async/non-blocking -> reentrantwm42015-02-203-13/+13
| | | | | | 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.
* player: enable cache and demuxer thread for subtitles toowm42015-02-182-3/+7
| | | | | | | | | 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.
* player: allow unsetting --term/osd-playing-msgwm42015-02-181-2/+2
| | | | | | 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).
* demux_edl: make independent from MPContextwm42015-02-172-6/+0
|
* demux_edl: move implementationwm42015-02-171-302/+0
| | | | Same deal as with demux_cue, and a separate commit for the same reasons.
* demux_cue: make independent from MPContextwm42015-02-172-5/+0
| | | | Also see previous commit(s).
* demux_cue: move implementationwm42015-02-171-415/+0
| | | | | | | | 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.
* matroska: move timeline code to demux/wm42015-02-171-654/+0
| | | | | Separate from previous commit, because git is bad at tracking file renames when the file contents are also changed.
* matroska: make timeline code independent of MPContextwm42015-02-173-114/+117
|
* player: use a separate context for timeline loader stuffwm42015-02-172-22/+46
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* player: use a macro to remove an element from an arraywm42015-02-171-6/+1
| | | | Should be equivalent.
* player: actually close files when using sub_removewm42015-02-171-13/+38
| | | | | | | | | 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.
* command: add rescan_external_fileswm42015-02-163-4/+24
| | | | | | | | | Requested. Hopefully will be useful for things that download and add external subtitles on demand. Or something. Closes #1586.
* command: nicer OSD message when setting audio-devicewm42015-02-161-0/+14
| | | | Requested.
* sub: mess with styling defaults, change --ass-use-margins behaviorwm42015-02-162-2/+4
| | | | | | | | | | | | | | | | | | | 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.
* osxbundle: config file special case isn't needed anymorewm42015-02-151-6/+0
| | | | | | 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.
* player: undeprecate 'config' fileswm42015-02-151-22/+5
| | | | | | | 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).
* player: fix audio-device-list updateswm42015-02-143-0/+8
| | | | | | | 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.
* ao_coreaudio: add support for hotplug notificationsStefano Pigozzi2015-02-142-4/+10
| | | | | | | | | | 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.
* Fix build on OSX broken by previous commitwm42015-02-131-1/+1
| | | | Hopefully.
* vf_vapoursynth: add display refresh rate propertyJulian2015-02-131-0/+2
| | | | | This value is not necessarily trustworthy (it might change) and can be 0.
* player: deprecate 'config' files (use mpv.conf), warn against clasheswm42015-02-131-5/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* command: mark get_property as deprecatedwm42015-02-131-0/+4
| | | | | Using it just makes no sense. But we're really being nice about this and don't remove it immediately.
* demux: hack for instant stream switchingwm42015-02-131-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.)
* encoding: fixed-vo option was removedwm42015-02-131-1/+0
|
* player: add a --loop=force modewm42015-02-122-8/+6
| | | | | | | 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.
* osx: move code to unset input context to the right placewm42015-02-121-4/+4
| | | | | | | 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).
* osx: move cocoa specific call out of common codewm42015-02-121-8/+0
| | | | This is almost equivalent, and gets rid of the ifdef.
* player: drop explicit exit() callswm42015-02-121-14/+9
| | | | | | | | | 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.)
* audio: add device change notification for hotpluggingwm42015-02-122-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Revert "player: make --force-window create the window immediately on start"wm42015-02-121-1/+0
| | | | | | | | | | | This reverts commit acc5e8f57419debdb74234a228b44db75023e28b. 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.
* player: use af_scaletempo when slowing down audio toowm42015-02-121-1/+1
| | | | | | 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.
* player: skip audio filter reinit on some types of speed changeswm42015-02-101-1/+11
| | | | | | | | | | | | | 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.
* tl_matroska: only check the chapter count when adding chaptersBen Boeckel2015-02-061-3/+3
| | | | | | | 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.
* tl_matroska: squeeze down the number of parametersBen Boeckel2015-02-061-62/+77
| | | | | |