summaryrefslogtreecommitdiffstats
path: root/player/playloop.c
Commit message (Collapse)AuthorAgeFilesLines
* client API: turn mpv_suspend() and mpv_resume() into stubswm42016-11-221-3/+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.
* player: enable no-video subtitle display on coverart toowm42016-10-311-1/+1
| | | | | | | | | | | Coverart mode has the same issue as no-video mode, except that the video chain is fully active. It shows only 1 frame at the start, which would normally mean that only the subtitle at timestamp 0 is shown. Use the no-video subtitle rendering mode in this case instead. (This still doesn't handle subtitle display when playing cover-art without audio, or playing a single image. This is because there's nothing that will advance playback_pts.)
* player: show subtitles on VO if --force-window is usedwm42016-10-261-1/+1
| | | | | | | | | | | | | | | | | | | | | If a VO is created, but no video is playing (i.e. --force-window is used), then until now no subtitles were shown. This is because VO subtitle display normally depends on video frame timing. If there are no video frames, there can be no subtitles. Change this and add some code to handle this situation specifically. Set a subtitle PTS manually and request VO redrawing manually, which gets the subtitles rendered somehow. This is kind of shaky. The subtitles are essentially sampled at arbitrary times (such as when new audio data is decoded and pushed to the AO, or on user interaction). To make a it slightly more consistent, force a completely arbitrary minimum FPS of 10. Other solutions (such as creating fake video) would be more intrusive or would require VO-level API changes. Fixes #3684.
* player: consistently initialize screensaver state with --force-windowwm42016-10-261-1/+1
| | | | Whether this is a good or a bad thing, make sure it's consistent.
* player: don't leave buffering during underflowwm42016-10-211-2/+2
| | | | | | | | | | | | | | | | Don't leave the buffering state while the demuxer is still marked as having underflowed. It's unclear why this hasn't been done before - with the logic being complicated as it is, maybe there was a reason for this. This is actually still not very reliable, but should be better than what was before: on stream switching decoders can read packets all while the demuxer is executing a refresh seek, which creates the underrun situation - but nothing really totally guarantees that the underrun state remains stable when the demuxer is back at the current demuxer position. Anyway, it's an improvement. The rest of the touched condition is not changed, just moved around for cosmetic reasons.
* player: guard against MPSEEK_RELATIVE when current pts is unknownAman Gupta2016-10-211-0/+2
| | | | | | | | | | | in very rare circumstances, doing a relative seek like +1s will end up doing an absolute seek to 00:01. this guards against that possibility. so far i've only ever seen this issue when using --ad=lavc:ac3_at and doing several relative seeks in quick succession. this is likely either a bug in the audiotoolbox decoder in ffmpeg, or simply due to inherent latency in that hardware decoder which causes brief periods of time where the current audio pts is unknown.
* player: make --stop-screensaver runtime-changeablewm42016-10-021-4/+13
| | | | | | | | | | 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.
* x11: fix external fullscreen updatewm42016-09-231-0/+9
| | | | | | | | | | | | On x11, you can change the fullscreen via the window manager and without mpv's involvement. In these cases, the internal fullscreen flag has to be updated. The hack used for this didn't really work properly. Change it accordingly. The important thing is that the shadow copy of the option is updated. This is still not really ideal. Fixes #3570.
* player: use better way to wait for input and dispatching commandswm42016-09-161-13/+26
| | | | | | | | | | | | | | | | | | | 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-13/+25
| | | | | | | | | | | | | 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-1/+18
| | | | | | | | | | | | | 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).
* client API: implement mpv_suspend/resume slightly differentlywm42016-09-041-0/+2
| | | | | | | | 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.
* options: make mp_vo_opts options an actual sub-option groupwm42016-08-301-1/+1
| | | | | | | | | | | Just a minor refactor along the planned option change. This commit will make it easier to update (i.e. copy) the VO options without copying _all_ options. For now, behavior should be equivalent, though. (The VO options were put into a separate struct quite early - when all global variables were removed from the source code. It wasn't clear whether the separate struct would have any actual purpose, but it seems it will now. Awesome, huh.)
* player: make --force-window work with opengl-cbwm42016-08-301-0/+1
| | | | | No reason not to? This probably avoids surprises if someone really tries to combine them.
* player: make looping slightly more seamlesswm42016-08-181-4/+24
| | | | | | 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-7/+8
| | | | | | | | | | | | 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: 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/+8
| | | | | | | | | | | | | | | | | 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/+0
| | | | | | | | | | | | | | | | | 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: it's not --force-seeking but --force-seekablewm42016-07-061-1/+1
| | | | Oops. Fuck.
* player: remove unused return valuewm42016-06-081-6/+3
|
* player: tell user about --force-seeking if demuxer is not seekablewm42016-06-081-1/+2
| | | | | | | | | | | | | This comes up often, see e.g. #3220. The issue is that if the stream input is not seekable, the demuxer is marked as not seekable. But if the stream cache is enabled, the file still _might_ be seekable to a degree. We recently disabled seeking in this mode because it can cause very weird issues, mostly because if stream-layer seeking fails, the demuxers will arbitrarily misbehave. On the other hand, it can work if the seek is within the cached range, which is why the user can still enable it with --force-seeking. There is a weird trade-off between allowing this and not crapping up too easily, so just informing the user about the possibility seems best.
* build: silence -Wunused-resultNiklas Haas2016-06-071-1/+1
| | | | | | | | For clang, it's enough to just put (void) around usages we are intentionally ignoring the result of. Since GCC does not seem to want to respect this decision, we are forced to disable the warning globally.
* player: restore usual seeking behaviorwm42016-05-091-16/+31
| | | | | | | | | | | | | | | | | | | | | | Commit 786f37ae accidentally changed seeking behavior such that continuous seeking (holding the seek button down) would use the previous seek target timestamp, instead of the new video timestamp. (This is for the default mode, seeking to keyframes.) The result is that the movement on the seekbar is smooth, but the way the video updates is awkward. Some might actually prefer the new behavior (and some players effectively show similar bahavior), but I don't. So restore the old behavior. This is done in two steps: First: strictly wait for the entire seek process to finish, which will effectively make the seeking code pick up the new video timestamp correctly. This would play audio immediately, which would result in noise during continuous seeking, which leads to second: explicitly abort the playback restarting process if this case is detected, and never play audio.
* player: strictly wait until done when backsteppingwm42016-04-271-1/+1
| | | | | | | | | | | This fixes backstepping getting "stuck" when e.g. holding down a key bound to the backstep command. The reason is that even if the backstep itself is finished, the next backstep might not take the new video PTS as reference if the hr-seek itself isn't finished yet. The intention of not waiting for the hr-seek to finish was faster backstepping by possibly skipping audio decoding. But it probably doesn't matter enough to make the rest of the code more complex.
* player: cleaner determination of current playback PTSwm42016-04-231-8/+11
| | | | | In particular, this won't overwrite the playback PTS in coverart mode, which actually fixes relative seeks.
* player: eagerly redraw OSD when seeking with coverartwm42016-04-231-1/+2
|
* player: force wakeup on playback restartwm42016-04-201-0/+1
| | | | Just a theoretical issue, most likely.
* player: reduce some timer callswm42016-04-201-4/+5
|
* player: minor simplification to buffering property updateswm42016-04-201-9/+4
| | | | | | | | | | Strictly schedule an update in regular intervals as long as either stream cache or demuxer are prefetching. Don't update just always because the stream cache is enabled ("idle != -1") or cache-related properties are observed (mp_client_event_is_registered()). Also, the "idle" variable was awkard; get rid of it with equivalent code.
* player: simplify an aspect of buffering determinationwm42016-04-191-15/+30
| | | | | | | | | | | | | | | 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?)
* player: loop on end of file if ab-loop-b is unsetwm42016-04-181-0/+3
| | | | Possibly slightly more useful/intuitive.
* cache: use a single STREAM_CTRL for various cache infowm42016-03-291-2/+3
| | | | | | | | Instead of having a separate for each, which also requires separate additional caching in the demuxer. (The demuxer adds an indirection, since STREAM_CTRLs are not thread-safe.) Since this includes the cache speed, this should fix #3003.
* player: simplify mp_seek()wm42016-02-281-55/+46
|
* demux: remove relative seekingwm42016-02-281-12/+3
| | | | | | | | | | | | | | | | | | | Ever since a change in mplayer2 or so, relative seeks were translated to absolute seeks before sending them to the demuxer in most cases. The only exception in current mpv is DVD seeking. Remove the SEEK_ABSOLUTE flag; it's not the implied default. SEEK_FACTOR is kept, because it's sometimes slightly useful for seeking in things like transport streams. (And maybe mkv files without duration set?) DVD seeking is terrible because DVD and libdvdnav are terrible, but mostly because libdvdnav is terrible. libdvdnav does not expose seeking with seek tables. (Although I know xbmc/kodi use an undocumented API that is not declared in the headers by dladdr()ing it - I think the function is dvdnav_jump_to_sector_by_time().) With the current mpv policy if not giving a shit about DVD, just revert our half-working seek hacks and always use dvdnav_time_search(). Relative seeking might get stuck sometimes; in this case --hr-seek=always is recommended.
* player: minor simplificationwm42016-02-271-12/+5
| | | | | | No need to pass endpts down in such a dumb way. Also remove an outdated comment somewhere.
* player: fix --force-window behaviorwm42016-02-251-2/+2
| | | | | | | | | | | | | | | | | _Of course_ the previous commit broke --force-window behavior (like it does every single time I touch it). vo_has_frame() gets cleared after a seek, so e.g. stopping playback of a file and going to the next by keeping the seek key down will enter a short moment without video at the end of the first file, which will set the stalled_video variable to true. Prevent it by using the indication whether the window was properly created (which is probably exactly what we want here). This function is also responsible for destroying the window when needed, and obviously we should never do that while video is active. (This is the actual bug, although the other change in this commit already hides the common breakage it caused.)
* player: honor --force-window if video is selected, but inactivewm42016-02-241-4/+10
| | | | | If a video track is selected, but no video is decoded from it (mostly with broken files), then create the window anyway.
* player: remove old timeline/ordered chapters supportwm42016-02-151-47/+12
|
* player: add complex filter graph supportwm42016-02-051-0/+53
| | | | | | | | | | | | | | | | 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: refactor: eliminate MPContext.d_audiowm42016-01-221-3/+3
|
* Relicense some non-MPlayer source files to LGPL 2.1 or laterwm42016-01-191-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This covers source files which were added in mplayer2 and mpv times only, and where all code is covered by LGPL relicensing agreements. There are probably more files to which this applies, but I'm being conservative here. A file named ao_sdl.c exists in MPlayer too, but the mpv one is a complete rewrite, and was added some time after the original ao_sdl.c was removed. The same applies to vo_sdl.c, for which the SDL2 API is radically different in addition (MPlayer supports SDL 1.2 only). common.c contains only code written by me. But common.h is a strange case: although it originally was named mp_common.h and exists in MPlayer too, by now it contains only definitions written by uau and me. The exceptions are the CONTROL_ defines - thus not changing the license of common.h yet. codec_tags.c contained once large tables generated from MPlayer's codecs.conf, but all of these tables were removed. From demux_playlist.c I'm removing a code fragment from someone who was not asked; this probably could be done later (see commit 15dccc37). misc.c is a bit complicated to reason about (it was split off mplayer.c and thus contains random functions out of this file), but actually all functions have been added post-MPlayer. Except get_relative_time(), which was written by uau, but looks similar to 3 different versions of something similar in each of the Unix/win32/OSX timer source files. I'm not sure what that means in regards to copyright, so I've just moved it into another still-GPL source file for now. screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but they're all gone.
* player: refactor: eliminate MPContext.d_videowm42016-01-171-6/+6
| | | | | | | | | | | | | | Eventually we want the VO be driven by a A->V filter, so a decoder doesn't even have to exist. Some features definitely require a decoder though (like reporting the decoder in use, hardware decoding, etc.), so for each thing which accessed d_video, it has to be redecided if and how it can access decoder state. At least the "framedrop" property slightly changes semantics: you can now always set this property, even if no video is active. Some untested changes in this commit, but our bio-based distributed test suite has to take care of this.
* player: refactor: eliminate MPContext.d_subwm42016-01-171-2/+1
| | | | The same is going to happen to d_video and d_audio later.
* player: simplify backsteppingwm42016-01-121-98/+18
| | | | | | | | | | | | | | Basically reimplement it. The old implementation was quite stupid, and was probably done this way because video filtering and output used to be way less decoupled. Now we can reimplement it in a very simple way: when backstepping, seek to current time, but keep the last frame that was supposed to be discarded when reaching the target time. When the seek finishes, prepend the saved frame to the video frame queue. A disadvantage is that the new implementation fails to skip over timeline boundaries (ordered chapters etc.), but this never worked properly anyway. It's possible that this will be fixed some time in the future.
* player: handle hrseek framedrop correctlywm42016-01-121-1/+1
| | | | | This was non-sense and checked the option instead of the actual flag. Possibly could lead to incorrect hr-seeks.
* mpv_talloc.h: rename from talloc.hDmitrij D. Czarkoff2016-01-111-1/+1
| | | | This change helps avoiding conflict with talloc.h from libtalloc.
* player: eliminate demux_get_next_pts()wm42016-01-111-2/+2
| | | | | | | | | | | | | | | | This slightly changes behavior when seeking with external audio/subtitle tracks if transport streams and mpeg files are played, as well as behavior when seeking with such external tracks. get_main_demux_pts() is evil because it always blocks on the demuxer (if there isn't already a packet queued). Thus it could lock up the player, which is a shame because all other possible causes have been removed. The reduced "precision" when seeking in the ts/mpeg cases (where SEEK_FACTOR is used, resulting in byte seeks instead of timestamp seeks) might lead to issues. We should probably drop this heuristic. (It was introduced because there is no other way to seek in files with PTS resets with libavformat, but its value is still questionable.)
* sub: change how subtitles are readwm42015-12-291-1/+2
| | | | |