summaryrefslogtreecommitdiffstats
path: root/player/core.h
Commit message (Collapse)AuthorAgeFilesLines
* player: fix a corner case in previous commitwm42017-04-141-0/+1
| | | | | | | | | The previous commit set "mpctx->playback_active = false;" before unload hooks were processed. This was intentional, but could in theory cause playback_active to be set to true again, and actually it's plain wrong if playback was exited in the middle it. There needs to be something else that forces playback_active to be set to false while in this unloading state.
* player: fix core-idle and eof-reached update notifcationswm42017-04-141-1/+4
| | | | | | | | Make mpv_observe_property() work correctly on them even with --keep-open-pause=no. This also changes the situations in which the screensaver is enabled/disabled subtly.
* player: unmess pause state handlingwm42017-04-141-2/+2
| | | | | | | | | Merge the pause_player() and unpause_player() functions. Make sure the pause events are emitted properly. We can now set the internal pause state based on a predicate, instead of e.g. handle_pause_on_low_cache() making a mess to trigger the internal pause state as wanted. Preparation for some more changes.
* player: make screenshot commands honor the async flagwm42017-04-011-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | And also change input.conf to make all screenshots async. (Except the every-frame mode, which always uses synchronous mode and ignores the flag.) By default, the "screenshot" command is still asynchronous, because scripts etc. might depend on this behavior. This is only partially async. The code for determining the filename is still always run synchronously. Only encoding the screenshot and writing it to disk is asynchronous. We explicitly document the exact behavior as undefined, so it can be changed any time. Some of this is a bit messy, because I wanted to avoid duplicating the message display code between sync and async mode. In async mode, this is called from a worker thread, which is not safe because showing a message accesses the thread-unsafe OSD code. So the core has to be locked during this, which implies accessing the core and all that. So the code has weird locking calls, and we need to do core destruction in a more "controlled" manner (thus the outstanding_async field). (What I'd really want would be the OSD simply showing log messages instead.) This is pretty untested, so expect bugs. Fixes #4250.
* player: add experimental stream recording featurewm42017-02-071-0/+8
| | | | | This is basically a WIP, but it can't remain in a branch forever. A warning is print when using it as it's still a bit "shaky".
* player: add prefetching of the next playlist entrywm42017-01-181-3/+17
| | | | | | | | | | | | Since for mpv CLI, the player state is a singleton, full prefetching is a bit tricky. We do it only on the demuxer layer. The implementation reuses the old "open thread". This means there is significant potential for regressions even if the new option is not used. This is made worse by the fact that I barely tested this code. The generic mpctx_run_reentrant() wrapper is also removed - this was its only user, and its remains become part of the new implementation.
* player: restructure cancel callbackwm42017-01-181-0/+6
| | | | | | | | | | | | As preparation for file prefetching, we basically have to get rid of using mpctx->playback_abort for the main demuxer (i.e. the thing that can be prefetched). It can't be changed on a running demuxer, and always using the same cancel handle would either mean aborting playback would also abort prefetching, or that playback can't be aborted anymore. Make this more flexible with some refactoring. Thi is a quite shitty solution if you ask me, but YOLO.
* scripting: minor logging improvementswm42017-01-141-0/+1
| | | | | | | | Give scripting backends a proper name, instead of calling everything "scripts". Log client exit directly in client.c, as that is more general (doesn't change actual output).
* player: change aspects of cover art handlingwm42017-01-101-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Cover art handling is a disgusting hack that causes a mess in all components. And this will stay this way. This is the Xth time I've changed cover art handling, and that will probably also continue. But change the code such that cover art is injected into the demux packet stream, instead of having an explicit special case it in the decoder glue code. (This is somewhat more similar to the cover art hack in libavformat.) To avoid that the over art picture is decoded again on each seek, we need some additional "caching" in player/video.c. Decoding it after each seek would work as well, but since cover art pictures can be pretty huge, it's probably ok to invest some lines of code into caching it. One weird thing is that the cover art packet will remain queued after seeks, but that is probably not an issue. In exchange, we can drop the dec_video.c code, which is pretty convenient for one of the following commits. This code duplicates a bunch of lower-level decode calls and does icky messing with this weird state stuff, so I'm glad it goes away.
* player: remove dysfunctional edition switching OSD codewm42017-01-051-2/+1
| | | | | | | | | | | | | Was intended to show a "nice" message on edition switching. In practice, the message was never visible. The OSD code checks whether a demuxer is loaded, and if not, discards the message - meaning if the OSD code happened to run before the demuxer was fully loaded, no message was shown. This is apparently a regression due to extensions to the OSD and the situations in which it can be used. Remove the broken code since it's too annoying to fix. Instead, a default property message will be shown, which is a bit uglier, but actually not too unuseful.
* video: use demuxer-signaled duration for last video framewm42016-12-211-0/+3
| | | | | | | | | Helps with gif, probably does unwanted things with other formats. This doesn't handle --end quite correctly, but this could be added later. Fixes #3924.
* client API: turn mpv_suspend() and mpv_resume() into stubswm42016-11-221-1/+0
| | | | | | | | | | | As threatened by the API changes document. This commit also removes or stubs equivalent calls in IPC and Lua scripting. The stubs are left to maintain ABI compatibility. The semantics of the API functions have been close enough to doing nothing that this probably won't even break existing API users. Probably.
* audio: move some fallback handling to common AO reload functionwm42016-10-051-0/+1
| | | | | | | | | Now a reload requested by an AO behaves in exactly the same way as changing an AO-related options (like --audio-channels or --audio-exclusive). This is good for testing and uniform behavior. (You could go as far as saying it's a necessity, because the spotty and obscure AO reload behavior is hard to reproduce and thus hard to test at all.)
* player: make --stop-screensaver runtime-changeablewm42016-10-021-0/+1
| | | | | | | | | | Move the screensaver enable/disable determination to a central place, and call it if the stop-screensaver property is changed. Also, do not stop the screensaver when in idle mode (i.e. no file is loaded). Fixes #3615.
* player: enable reading from stdin after loading input.confwm42016-09-291-1/+1
| | | | Someone requested this.
* command: add a load-script commandwm42016-09-221-0/+1
| | | | | | | The intention is to give libmpv users as much flexibility to load scripts as using mpv from CLI, but without restricting libmpv users from having to decide everything on creation time, or having to go through hacks like recreating the libmpv context to update state.
* player: make --osc/--ytdl settable during playbackwm42016-09-201-0/+1
| | | | | | | | | Setting the osc or ytdl properties will now load/unload the associated scripts. (For ytdl this does not mean the currently played URL will be reloaded.) Also add a changelog entry for this, which also covers the preceding work for --terminal.
* player: minor changes in init codewm42016-09-191-1/+0
| | | | | | | | | | | | Move the MPV_LEAK_REPORT env query to mp_create(), where it will also be used by the client API (it might be helpful, so why not). The same applies to MPV_VERBOSE. The prepare_playlist() call doesn't need to be in mp_initialize() and can just be in mp_play_files() to reduce the size of mp_initialize(). Also, remove wakeup_playloop(), which is 100% redundant with mp_wakeup_core_cb().
* player: make --terminal freetly settable at runtimewm42016-09-191-0/+1
| | | | | | | | | | | | | | | | | | | So client API users don't have to care about whether to set this before or after mpv_initialize(). We still don't enable terminal at any point before mpv_initialize(), because reasons. This also subtly changes some behavior how terminal options are applied while parsing. This essentially reverts the behavior as it was reported in issue #2588. Originally, I was hoping to get rid of the pre-parse option pass, but it seems this is absolutely not possible due to the way config and command line parsing are entangled. Command line options take priority over configfile options, so they have to be applied later - but we also want to apply logging and terminal options as specified on the command-line, but _before_ parsing the config files. It has to be this way to see config file error messages on the terminal, or to hide them if --no-terminal is used. libmpv considerations also factor into this.
* player: more option/property consistency fixeswm42016-09-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Some properties had a different type from their equivalent options (such as mute, volume, deinterlace, edition). This wasn't really sane, as raw option values should be always within their bounds. On the other hand, these properties use a different type to reflect runtime limits (such as range of available editions), or simply to improve the "UI" (you don't want to cycle throuhg the completely useless "auto" value when cycling the "mute" property). Handle this by making them always return the option type, but also allowing them to provide a "constricted" type, which is used for UI purposes. All M_PROPERTY_GET_CONSTRICTED_TYPE changes are related to this. One consequence is that you can set the volume property to arbitrary high values just like with the --volume option, but using the "add" command it still restricts it to the --volume-max range. Also deprecate --chapter, as it is grossly incompatible to the chapter property. We pondered renaming it to --chapters, or introducing a more powerful --range option, but concluded that --start --end is actually enough. These changes appear to take care of the last gross property/option incompatibilities, although there might still be a few lurking.
* player: use better way to wait for input and dispatching commandswm42016-09-161-1/+4
| | | | | | | | | | | | | | | | | | | Instead of using input_ctx for waiting, use the dispatch queue directly. One big change is that the dispatch queue will just process commands that come in (e.g. from client API) without returning. This should reduce unnecessary playloop excutions (which is good since the playloop got a bit fat from rechecking a lot of conditions every iteration). Since this doesn't force a new playloop iteration on every access, this has to be enforced manually in some cases. Normal input (via terminal or VO window) still wakes up the playloop every time, though that's not too important. It makes testing this harder, though. If there are missing wakeup calls, it will be noticed only when using the client API in some form. At this point we could probably use a normal lock instead of the dispatch queue stuff.
* player: litter code with explicit wakeup callswm42016-09-161-0/+1
| | | | | | | | | | | | | This does 3 kinds of changes: - change sleeptime=x to mp_set_timeout() - change sleeptime=0 to mp_wakeup_core() calls (to be more explicit) - change commands etc. to call mp_wakeup_core() if they do changes that require the playloop to be rerun This is preparation for the following changes. The goal is to process client API requests without having to rerun the playloop every time. As of this commit, the changes should not change behavior. In particular, the playloop is still implicitly woken up on every command.
* player, ao, vo: don't call mp_input_wakeup() directlywm42016-09-161-0/+2
| | | | | | | | | | | | | Currently, calling mp_input_wakeup() will wake up the core thread (also called the playloop). This seems odd, but currently the core indeed calls mp_input_wait() when it has nothing more to do. It's done this way because MPlayer used input_ctx as central "mainloop". This is probably going to change. Remove direct calls to this function, and replace it with mp_wakeup_core() calls. ao and vo are changed to use opaque callbacks and not use input_ctx for this purpose. Other code already uses opaque callbacks, or has legitimate reasons to use input_ctx directly (such as sending actual user input).
* stream, demux, config: remove some dead/unneeded option-related codewm42016-09-091-1/+0
| | | | | | | | | | This has all been made unnecessary recently. The change not to copy the global option struct in particular can be made because now nothing accesses the global options anymore in the demux and stream layers. Some code that was accidentally added/changed in commit 5e30e7a0 is also removed, because it was simply committed accidentally, and was never used.
* client API: implement mpv_suspend/resume slightly differentlywm42016-09-041-0/+1
| | | | | | | | Why do these API calls even still exist? I don't know, and maybe they don't make any sense anymore. But whether they should be removed or not is not a decision I want to make now. I want to get rid of mp_dispatch_suspend/resume(), though. So implement the client APIs slightly differently.
* player: make looping slightly more seamlesswm42016-08-181-0/+2
| | | | | | This affects A-B loops and --loop-file, and audio. Instead of dropping audio by resetting the AO, try to make it seamless by not sending data after the loop point, and after the seek send new data without a reset.
* player: allow passing flags to queue_seek()wm42016-08-151-2/+6
| | | | | | | | | | | | Change the last parameter from a bool to an int, which is supposed to take bit-flags. The at this point only flag is MPSEEK_FLAG_DELAY, which replaces the previous bool parameter. The old false parameter becomes 0, the old true parameter becomes MPSEEK_FLAG_DELAY. Since the old "immediate" parameter is now essentially inverted, two coalesced immediate and delayed seeks end up as delayed instead of immediate. This change doesn't matter, since there are no relative immediate seeks anyway.
* player: add --audio-wait-open optionswm42016-08-091-0/+1
| | | | Complements the option added in the previous commit.
* player: gross hack to improve non-hr seeking with external audio trackswm42016-08-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Relative seeks backwards with external audio tracks does not always work well: it tends to happen that video seek back further than audio, so audio will remain silent until the audio's after-seek position is reached. This happens because we strictly seek both video and audio demuxer to the approximate desirted target PTS, and then start decoding from that. Commit 81358380 removes an older method that was supposed to deal with this. It was sort of bad, because it could lead to the playback core freezing by waiting on network. Ideally, the demuxer layer would probably somehow deal with such seeks, and do them in a way the audio is seeked after video. Currently this is infeasible, because the demuxer layer assumes a single demuxer, and external tracks simply use separate demuxer layers. (MPlayer actually had a pseudo-demuxer that joined external tracks into a single demuxer, but this is not flexible enough - and also, the demuxer layer as it currently exists can't deal with dynamically removing external tracks either. Maybe some time in the future.) Instead, add a gross hack, that essentially reseeks the audio if it detects that it's too far off. The result is actually not too bad, because we can reuse the mechanism that is used for instant track switching. This way we can make sure of the right position, without having to care about certain other issues. It should be noted that if the audio demuxer is used for other tracks too, and the demuxer does not support refresh seeking, audio will probably be off by even a higher amount. But this should be rare.
* player: offset demuxer on start/seek properly with audio/sub delaywm42016-08-041-0/+1
| | | | | | | | | | | | | | | | | Assume you use a large value like --audio-delay=20. Then until now the player would just have seeked normally to a "too late" position, and played silence for about 20 seconds until audio in the correct time range is coming again. Change this by offsetting seeks by the right amount. This works for both external and muxed files. If a seek isn't precise, then it works only for external files. This might cause issues with very large delay options. Hr-seek skipping could take a lot of time (especially because it affects video too), the demuxer queue could overflow, and other weird corner cases could appear. But we just try this on best-effort basis, and if the user uses extreme values we don't guarantee good behavior.
* audio: refactor mixer code and delete mixer.cwm42016-07-171-1/+9
| | | | | | | | | | | | | | | | | mixer.c didn't really deserve to be separate anymore, as half of its contents were unnecessary glue code after recent changes. It also created a weird split between audio.c and af.c due to the fact that mixer.c could insert audio filters. With the code being in audio.c directly, together with other code that unserts filters during runtime, it will be possible to cleanup this code a bit and make it work like the video filter code. As part of this change, make the balance code work like the volume code, and add an option to back the current balance value. Also, since the balance semantics are unexpected for most users (panning between the audio channels, instead of just changing the relative volume), and there are some other volumes, formally deprecate both the old property and the new option.
* player: rewrite deinterlace filter auto-insertionwm42016-07-051-0/+2
| | | | | | | | | | | | | | Instead of using the "vf" command code (which changes filters at runtime on user input), use the general filter-insertion code. The latter was added later, and is more suitable for automatically inserted filters. The old code failed in particular when using watch-later saving, which stored the filter list in the resume config file. If a user changed the hardware decoding mode via command line, the stored filter chain was out of date and could cause failure due to not working with hardware or software decoding mode. Storing the deinterlace filter in the filter list was unavoidable, because it was part of the user state. (The new code only edits the actually instantiated filters.)
* player: do not update OSD all the time when pausedwm42016-06-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Normally, OSD is updated every time the playloop is run. This has to be done, because the OSD may implicitly reference various properties, without knowing whether they really need to be updated or not. (There's a property update mechanism, but it's mostly unavailable, because OSD is special-cased and can not use the client API mechanism properly.) Normally, these updates are no problem, because the OSD is only actually printed when the OSD text actually changes. But commit d23ffd24 added a rate-limiting mechanism, which tries to limit OSD updates at most every 50ms (or the next video frame). Since it can't know in advance whether the OSD is going to change or not, this simply waked up the player every 50ms. Change this so that the player is updated only as part of general updates determined through mp_notify(). (This function also notifies the client API of changed properties.) The desired result is that the player will not wake up at all in normal idle mode, but still update properties that can change when paused, such as the cache. This is mostly a cosmetic change (in the sense of making runtime behavior just slightly better). It has the slightly more negative consequence that properties which update implicitly (such as "clock") will not update periodically anymore.
* video: refactor how VO exports hwdec device handleswm42016-05-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The main change is with video/hwdec.h. mp_hwdec_info is made opaque (and renamed to mp_hwdec_devices). Its accessors are mainly thread-safe (or documented where not), which makes the whole thing saner and cleaner. In particular, thread-safety rules become less subtle and more obvious. The new internal API makes it easier to support multiple OpenGL interop backends. (Although this is not done yet, and it's not clear whether it ever will.) This also removes all the API-specific fields from mp_hwdec_ctx and replaces them with a "ctx" field. For d3d in particular, we drop the mp_d3d_ctx struct completely, and pass the interfaces directly. Remove the emulation checks from vaapi.c and vdpau.c; they are pointless, and the checks that matter are done on the VO layer. The d3d hardware decoders might slightly change behavior: dxva2-copy will not use the VO device anymore if the VO supports proper interop. This pretty much assumes that any in such cases the VO will not use any form of exclusive mode, which makes using the VO device in copy mode unnecessary. This is a big refactor. Some things may be untested and could be broken.
* player: simplify an aspect of buffering determinationwm42016-04-191-1/+2
| | | | | | | | | | | | | | | Calculate the buffering percentage in the same code which determines whether the player is or should be buffering. In particular it can't happen that percentage and buffering state are slightly out of sync due to calling DEMUXER_CTRL_GET_READER_STATE and reusing it with the previously determined buffering state. Now it's also easier to guarantee that the buffering state is updated properly. Add some more verbose output as well. (Damn I hate this code, why did I write it?)
* sub: make preloading more robustwm42016-03-061-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Subtitles can be preloaded, which means they're fully read and copied into ASS_Track. This in turn is mainly for the sake of being able to do subtitle seeking (when it comes down to it, subtitle seeking is the cause for most trouble here). Commit a714f8e92 broke preloaded subtitles which have events with unknown duration, such as some MicroDVD samples. The event list gets cleared on every seek, so the property of being preloaded obviously gets lost. Fix this by moving most of the preloading logic to dec_sub.c. If the subtitle list gets cleared, they are not considered preloaded anymore, and the logic for demuxed subtitles is used. As another minor thing, preloadeding subtitles did neither disable the demux stream, nor did it discard packets. Thus you could get queue overflows in theory (harmless, but annoying). Fix this by explicitly discarding packets in preloaded mode. In summary, now the only difference between preloaded and normal demuxing are: 1. a seek is issued, and all packets are read on start 2. during playback, discard the packets instead of feeding them to the subtitle decoder This is still petty annoying. It would be nice if maintaining the subtitle index (and maybe a subtitle packet cache for instant subtitle presentation when seeking back) could be maintained in the demuxer instead. Half of all file formats with interleaved subtitles have this anyway (mp4, mkv muxed with newer mkvmerge).
* player: minor simplificationwm42016-02-271-2/+2
| | | | | | No need to pass endpts down in such a dumb way. Also remove an outdated comment somewhere.
* player: slightly simplify how demuxer streams are enabled/disabledwm42016-02-251-1/+1
| | | | | Instead of having reselect_demux_streams() look at all streams, make it look at the current stream that is being enabled/disabled.
* player: remove unused MPContext.stream fieldwm42016-02-231-2/+0
| | | | | | | It was just dead code. Also fixes the stream-open-filename property, which is supposed to be read-only if a file was already opened.
* player: remove MPContext.sources fieldswm42016-02-231-2/+0
| | | | | | Some oddity that is not needed anymore. The only thing which still referenced them was avoiding loading external files more than once, which is now prevented by checking the list of tracks instead.
* player: remove old timeline/ordered chapters supportwm42016-02-151-20/+1
|
* player: add complex filter graph supportwm42016-02-051-0/+17
| | | | | | | | | | | | | | | | See --lavfi-complex option. This is still quite rough. There's no support for dynamic configuration of any kind. There are probably corner cases where playback might freeze or burn 100% CPU (due to dataflow problems when interaction with libavfilter). Future possible plans might include: - freely switch tracks by providing some sort of default track graph label - automatically enabling audio visualization - automatically mix audio or stack video when multiple tracks are selected at once (similar to how multiple sub tracks can be selected)
* player: move audio and video decoder init to separate functionswm42016-02-051-0/+2
| | | | Preparation.
*