summaryrefslogtreecommitdiffstats
path: root/player
Commit message (Collapse)AuthorAgeFilesLines
* Move compat/ and bstr/ directory contents somewhere elsewm42014-08-296-6/+6
| | | | | | | | | bstr.c doesn't really deserve its own directory, and compat had just a few files, most of which may as well be in osdep. There isn't really any justification for these extra directories, so get rid of them. The compat/libav.h was empty - just delete it. We changed our approach to API compatibility, and will likely not need it anymore.
* command: remove extra spaceRyan Jacobs2014-08-291-1/+1
| | | | Signed-off-by: wm4 <wm4@nowhere>
* command: export demuxer cache info propertieswm42014-08-281-1/+35
|
* player: update cache state only if requestedwm42014-08-283-2/+44
| | | | | | | | | Add a mechanism to the client API code, which allows the player core to query whether a client API event is needed at all. Use it for the cache update. In this case, this is probably a pure microoptimization; but the mechanism will be useful for other things too.
* audio: restore old speed change behaviorwm42014-08-282-2/+2
| | | | | | | | | | | | | | | | | | | | Don't attempt to resync after speed changes. Note that most other cases of audio reinit (like switching tracks etc.) still resync, but other code paths take care of setting the audio_status accordingly. This restores the old behavior of not trying to fix audio desync, which was probably changed with commit 261506e3. Note that the code as of now wasn't even entirely correct, since the A/V sync values are slightly shifted. The dsync depends on the audio buffer size, so a larger buffer size will show more extreme desync. Also see mplayer2 commit 213a224e, which should fixed this - it was not merged into mpv, because it disabled audio for too long, resulting in a worse user experience. This is similar to the issue this commit attempts to fix. Fixes: #1042 (probably) CC: @mpv-player-stable
* player: simplify chapter display name codeBen Boeckel2014-08-281-3/+2
| | | | | The display name is always recomputed, so we can always toss the input name.
* player: don't sort a NULL listBen Boeckel2014-08-281-1/+2
| | | | | This can occur if the directory does not have any files in it which causes files to never be non-NULL for qsort.
* player: dynamically change cache wait timeswm42014-08-272-1/+13
| | | | | | | | | | | Remove the hardcoded wait time of 2 seconds. Instead, adjust the wait time each time we unpause: if downloading the data took longer than its estimated playback time, increase the amount of data we wait for. If it's shorter, decrease it. The +/- is supposed to avoid oscillating between two values if the elapsed time and the wait time are similar. It's not sure if this actually helps with anything, but it can't harm.
* player: slightly better cache underrun detectionwm42014-08-271-5/+2
| | | | | | | | | | | | | | | | | | Use the "native" underrun detection, instead of guessing by a low cache duration. The new underrun detection (which was added with the original commit) might have the problem that it's easy for the playloop to miss the underrun event. The underrun is actually not stored as state, so if the demuxer thread adds a new packet before the playloop happens to see the state, it's as if it never happened. On the other hand, this means that network was fast enough, so it should be just fine. Also, should it happen that we don't know the cached range (the ts_duration < 0 case), just wait until the demuxer goes idle (i.e. read_packet() decides to stop). This pretty much should affect broken or unusual files only, and there might be various things that could go wrong. But it's more robust in the normal case: this situation also happens when no packets have been read yet, and we don't want to consider this as reason to resume playback.
* player: better cache status on status linewm42014-08-272-12/+23
| | | | | | | | | | | | | | The cache percentage was useless. It showed how much of the total stream cache was in use, but since the cache size is something huge and unrelated to the bitrate or network speed, the information content of the percentage was rather low. Replace this with printing the duration of the demuxer-cached data, and the size of the stream cache in KB. I'm not completely sure about the formatting; suggestions are welcome. Note that it's not easy to know how much playback time the stream cache covers, so it's always in bytes.
* player: fix basic playbackwm42014-08-271-6/+6
| | | | | | | | | | | | | The "buffering" logic was active even if the stream cache was disabled. This is contrary to what the manpage says. It also breaks playback because of another bug: the demuxer cache is smaller than 2 seconds, and thus the resume condition never becomes true. Explicitly run this code only if the stream cache is enabled. Also, fix the underlying problem of the breakage, and resume when the demuxer thread stops reading in any case, not just on EOF. Broken by previous commit. Unbreaks playback of local files.
* player: redo how stream caching and pausing on low cache workswm42014-08-271-21/+33
| | | | | | | | | | | | | | | | | | | Add the --cache-secs option, which literally overrides the value of --demuxer-readahead-secs if the stream cache is active. The default value is very high (10 seconds), which means it can act as network cache. Remove the old behavior of trying to pause once the byte cache runs low. Instead, do something similar wit the demuxer cache. The nice thing is that we can guess how many seconds of video it has cached, and we can make better decisions. But for now, apply a relatively naive heuristic: if the cache is below 0.5 secs, pause, and wait until at least 2 secs are available. Note that due to timestamp reordering, the estimated cached duration of video might be inaccurate, depending on the file format. If the file format has DTS, it's easy, otherwise the duration will seemingly jump back and forth.
* player: fix weird behavior when framestepping over format changeswm42014-08-261-1/+1
| | | | | | | | | | When video format changes, the frame before the frame with the new format sets video_status briefly to STATUS_DRAINING. This caused the code to handle the EOF case to kick in, which just pauses the player when trying to step past the last frame. As a result, trying to framestep over format changes resulted in pausing the player. Fix by testing against the correct status.
* player: minor changeswm42014-08-253-16/+6
| | | | | | | | | | | | This shouldn't change anything functionally. Change the A/V desync message. --framedrop is enabled by default now, so the text must be changed a little. I've never heard of audio outputs messing up A/V sync recently, so remove that part. Remove the unused ao_pts field. Reorder 2 A/V sync related expressions so that they look the same.
* command: change OSD formatting of "speed" propertywm42014-08-251-1/+1
| | | | The "x " prefix annoyed some users.
* options: compatibility hack for --slave-brokenwm42014-08-251-0/+6
| | | | | | | Seems some programs were still relying on it. Whatever, it's not hard to support. CC: @mpv-player/stable
* player: restore silent seekingwm42014-08-231-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Commit 846257da introduced an accidental feature: if you kept seeking (so playback never really resumes), the audio would never be played. This was nice, but commit 4c25b000 accidentally removed it again (due to the video_next_pts being earlier available than it used to be, so audio could be played before the player executed the next queued seek). Implicitly reintroduce the old behavior again by not decoding a second video frame immediately. Usually, the second frame is used to compute the frame duration needed to for accurate framedropping, but since the first frame after a seek is never dropped, we don't need this. Now the video code will queue the new frame to the VO immediately, and since fill_audio_out_buffers() is called in the playloop before write_video() and execute_queued_seek(), it never gets the chance to enter STATUS_READY, and seeks will be silent. This also has a nice side-effect: since the second frame is not decoded and filtered, seeking becomes slightly faster (back to the same level as with framedrop disabled). It seems this still sometimes plays a period of audio when keeping a seek key down. In my tests, this appeared to happen because the seek finished before the next key repeat was sent.
* audio: minor improvements to timeline switchingwm42014-08-234-13/+5
| | | | | | | | In theory, timestamps can be negative, so we shouldn't just return -1 as special value. Remove the separate code for clearing decode buffers; use the same code that is used for normal seek reset.
* osc: Use osd-font for playlist buttonsChrisK22014-08-221-2/+3
| | | | | Now that we use the symbols from the font, we should also actually use the font.
* player: some more debugging outputwm42014-08-221-0/+2
|
* player: fix recent speed change regressionwm42014-08-223-2/+6
| | | | | | | | | | | | | | Commit 5afc025c broke this. The reason is that mpctx->delay is updated when a new video frame is added. This value is also needed to resync audio, but it will be for the wrong PTS. They must be consistent with each other, and if they aren't, initial sync will be off by N video frames, which results at least in worse user experience. This can be reproduced by for example heavily switching between normal and 2x speed, or similar. Fix by readding the video_next_pts field (keeping its use minimal, instead of reverting the commit that removed it).
* player: don't clobber playback position on video endwm42014-08-221-5/+3
| | | | | | | | If video reaches EOF, and audio is also EOF (or is otherwise not meaningful, like audio disabled), then the playback position was briefly set to 0. Fix this by not trying to use a bogus audio PTS. CC: @mpv-player/stable (maybe)
* video: refactor queue handlingwm42014-08-222-76/+53
| | | | | | | | | | | | | | | This simplifies the code, and fixes an odd bug: the second-last frame was displayed for a very short duration if framedrop was enabled. The reason was that basically the time difference between second-last and last frame were skipped, because at this point EOF was already signaled. Also see commit b0959488 for a similar issue in the same code. This removes the messiness of the next_frame 2-frame queue, and strictly runs the "new frame" code when a frame is moved to the first position of the queue, instead of somehow messing with return codes. This also merges update_video() into video_output_image().
* video: get rid of video_next_pts fieldwm42014-08-226-24/+8
| | | | | | Not really needed anymore. Code should be mostly equivalent. Also get rid of some other now-unused or outdated things.
* video: move some code aroundwm42014-08-221-46/+45
| | | | | | No functional changes. init_vo() is now needed a bit further down, and moving it keeps definition and use close. adjust_sync() will be used by a function further up in one of the following commits.
* video: minor simplificationwm42014-08-221-21/+11
| | | | This is mostly equivalent, but simpler, and reduces some duplication.
* osc: revert disabling use_suspendwm42014-08-211-2/+0
| | | | It was an unintended/accidental change.
* terminal: some cleanupswm42014-08-212-8/+10
| | | | In particular, remove all the stupid debug printfs from the win code.
* osd+osc: Add left-arrow to osd-fontChrisK22014-08-211-2/+4
| | | | | For use as playlist navigation button in OSC, now the osd-font carries all symbols needed by the OSC.
* video: don't assume query_format is thread-safewm42014-08-202-6/+3
| | | | Although it's probably safe for most VOs, there's no guarantee.
* command: add estimated-frame-count & estimated-frame-number propertiesAndrey Morozov2014-08-191-0/+39
| | | | Signed-off-by: wm4 <wm4@nowhere>
* command: drop " %" from "cache" property OSD-formattingwm42014-08-181-1/+1
|
* player: never print status messages before playback beginswm42014-08-182-2/+4
| | | | | | | | | | | | | | | | | | After a new file is loaded, playback never starts instantly. Rather, it takes some playloop iterations until initial audio and video have been decoded, and the outputs have been (lazily) initialized. This means you will get status line updates between the messages that inform of the initialized outputs. This is a bit annoying and clutters the terminal output needlessly. Fix this by never printing the status line before playback isn't fully initialized. Do this by reusing the --term-playing-msg code (which prints a message once playback is initialized). This also makes sure the status line _is_ shown during playback restart when doing seeks. It's possible that the change will make the output more confusing if for some reason is stuck forever initializing playback, but that seems like an obscure corner case that never happens, so forget about it.
* player: remove unneeded callwm42014-08-183-6/+1
| | | | | | | | print_status() is called at a later point anyway (and before sleeping), so this code has little effect. This code was added in commit a4f7a3df5, and I can't observe any problems with idle mode anymore. Now print_status() is called from a single place only, within osd.c.
* player: cosmetics: make code more compactwm42014-08-161-5/+2
|
* audio: add a mode to insert silence on severe A/V desyncwm42014-08-152-4/+19
| | | | | | This is probably a stupid idea, but it can't be denied that this actually allows playing video without larger desync, even if video is too slow.
* video: add VO framedropping modewm42014-08-154-12/+30
| | | | | | | | | | | | | | | | | | | | | | | | This mostly uses the same idea as with vo_vdpau.c, but much simplified. On X11, it tries to get the display framerate with XF86VM, and limits the frequency of new video frames against it. Note that this is an old extension, and is confirmed not to work correctly with multi-monitor setups. But we're using it because it was already around (it is also used by vo_vdpau). This attempts to predict the next vsync event by using the time of the last frame and the display FPS. Even if that goes completely wrong, the results are still relatively good. On other systems, or if the X11 code doesn't return a display FPS, a framerate of 1000 is assumed. This is infinite for all practical purposes, and means that only frames which are definitely too late are dropped. This probably has worse results, but is still useful. "--framedrop=yes" is basically replaced with "--framedrop=decoder". The old framedropping mode is kept around, and should perhaps be improved. Dropping on the decoder level is still useful if decoding itself is too slow.
* player: use virtual time for --audio-file with ordered chapterswm42014-08-155-10/+16
| | | | | | | | | Apparently users prefer this behavior. It was used for subtitles too, so move the code to calculate the video offset into a separate function. Seeking also needs to be fixed. Fixes #1018.
* lua: wake up the core when setting OSDwm42014-08-151-0/+1
| | | | | | | | | | The OSD is marked as changed, but the core isn't notified and this doesn't immediately wakeup. (Possibly the OSD code should wakeup the core instead, but maybe that woudl be overkill.) Observed when using "mp.use_suspend = false" in the OSC, and pausing, and moving the mouse pointer out of the window. The last part of the fade remained visible for longer than intended.
* osc: Overhaul (wip)ChrisK22014-08-151-502/+848
| | | | | | | | | | | | Code reorganized to make layouts exchangeable alternative test layout can be tested with layout=slimbox in the OSC config timers are now used to properly animate the fade out when the player is paused duplicate seeks are discarded again
* sub: add option to workaround broken mkv fileswm42014-08-141-1/+3
| | | | See additions to options.rst.
* sub: call sub_reset() on seeks onlywm42014-08-142-4/+0
| | | | | | | | | | | | | | | | | sub_reset() was called on cycling subtitle tracks and on seeking. Since we don't want that subtitles disppear on cycling, sd_lavc.c didn't clear its internal subtitle queue on reset, which meant that seeking with PGS subtitles could leave the subtitle on screen (PGS subtitles usually don't have a duration set). Call it only on seeking, so we can also strictly clear the subtitle queue in sd_lavc. (This still can go very wrong if you disable a subtitle, seek, and enable it again - for example, if used with libavformat that uses "SSA" style demuxed ASS subtitle packets. That shouldn't happen with newer libavformat versions, and the user can "correct" it anyway by executing a seek while the subtitle is selected.)
* client API: directly lock playloopwm42014-08-141-4/+3
| | | | | | | | Until recently, vo_opengl could be accessed from a single thread only, due to the OpenGL API context being thread-specific. This issue doesn't exist anymore, because VOs run on their own thread. This means we can simply lock/unlock the playloop instead of doing something complicated to get the playloop thread to execute our code.
* lua: allow disabling suspendwm42014-08-141-2/+8
| | | | | I'd like to enable this by default, but unfortunately the OSC seems to have some problems with it.
* video: reduce non-sense messages when playing coverartwm42014-08-131-11/+14
| | | | Don't print PTS warnings by skipping the normal video path.
* video: don't run new frame processing on every iterationwm42014-08-131-19/+22
| | | | | | | This ran adjust_sync() on every playloop iteration, instead of every newly decoded frame. It seems this was idempotent in the common case, but the code was originally designed to be run once only, so restore that.
* video: move some more code aroundwm42014-08-131-38/+49
| | | | No functional changes.
* video: move some code aroundwm42014-08-131-45/+40
|
* video: exit early when nothing to dowm42014-08-131-7/+7
| | | | | These cases were probably confusing. Exit early, which makes it much clearer what's going on. Should not change anything functionally.
* video: minor simplification of the old framedrop codewm42014-08-131-10/+6
| | | | | No changes in functionality, other than being slightly more correct at stream EOF.
* player: don't quit with --loop-filewm42014-08-131-0/+1
| | | | | | Fixes #1009. CC: @mpv-player/stable
* video: fix and simplify video format changes and last frame displaywm42014-08-124-111/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | The previous commit broke these things, and fixing them is separate in this commit in order to reduce the volume of changes. Move the image queue from the VO to the playback core. The image queue is a remnant of the old way how vdpau was implemented, and increasingly became more and more an artifact. In the end, it did only one thing: computing the duration of the current frame. This was done by taking the PTS difference between the current and the future frame. We keep this, but by moving it out of the VO, we don't have to special-case format changes anymore. This simplifies the code a lot. Since we need the queue to compute the duration only, a queue size larger than 2 makes no sense, and we can hardcode that. Also change how the last frame is handled. The last frame is a bit of a problem, because video timing works by showing one frame after another, which makes it a special case. Make the VO provide a function to notify us when the frame is done, instead. The frame duration is used for that. This is not perfect. For example, changing playback speed during the last frame doesn't update the end time. Pausing will not stop the clock that times the last frame. But I don't think this matters for such a corner case.
* video: move display and timing to a separate threadwm42014-08-125-120/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The VO is run inside its own thread. It also does most of video timing. The playloop hands the image data and a realtime timestamp to the VO, and the VO does the rest. In particular, this allows the playloop to do other things, instead of blocking for video redraw. But if anything accesses the VO during video timing, it will block. This also fixes vo_sdl.c event handling; but that is only a side-effect, since reimplementing the broken way would require more effort. Also drop --softsleep. In theory, this option helps if the kernel's sleeping mechanism is too inaccurate for video timing. In practice, I haven't ever encountered a situation where it helps, and it just burns CPU cycles. On the other hand it's probably actively harmful, because it prevents the libavcodec decoder threads from doing real work. Side note: Originally, I intended that multiple frames can be queued to the VO. But this is not done, due to problems with OSD and other certain features. OSD in particular is simply designed in a way that it can be neither timed nor copied, so you do have to render it into the video frame before you can draw the next frame. (Subtitles have no such restriction. sd_lavc was even updated to fix this.) It seems the right solution to queuing multiple VO frames is rendering on VO-backed framebuffers, like vo_vdpau.c does. This requires VO driver support, and is out of scope of this commit. As consequence, the VO has a queue size of 1. The existing video queue is just needed to compute frame duration, and will be moved out in the next commit.
* video: don't keep multiple pointers to hwdec info structwm42014-08-111-1/+1
| | | | This makes a certain corner case simpler at a later point.
* player: remove cache status from video OSDwm42014-08-111-3/+0
|
* video: fix dangling pointer issuewm42014-08-111-1/+1
| | | | |