summaryrefslogtreecommitdiffstats
path: root/player
Commit message (Collapse)AuthorAgeFilesLines
* sub: offset subtitle timing to video start PTSwm42014-07-221-1/+2
| | | | | | | | | | | | This allows using external subtitle files with e.g. transport stream files that don't start at time 0. Note that if the .ts file has timestamp resets, everything goes south. But I guess this was already the case before, unless there are external subtitle files that also include timestamp resets, which is unlikely. (On the other hand, you could for example expect that it works with embedded DVB subtitles, that were somehow captured from the same stream and use the same timestamps.)
* video: fix corner case with accidental EOFwm42014-07-221-5/+5
| | | | | | | | | | | | | | The video flushing logic was broken: if there are no more packets, decode_image() will feed flush packets to the decoder. Even if an image was produced, it will return the demuxer EOF state, and since commit 7083f88c, this EOF state is returned to the caller, which is incorrect. Revert this part of the change, and explicitly check for VD_WAIT (the bogus change was intended to forward this error code to the caller). Also, turn the "r < 1" into something equivalent that doesn't rely on the exact value of VD_EOF. "r < 0" is ok, because at least here, errors are always negative.
* player: fix idle mode event handlingwm42014-07-221-2/+2
|
* osd: properly handle OSD bar timeoutwm42014-07-211-4/+10
| | | | | This could just remain stuck on the screen, until the playloop happened to be run again.
* player: don't sleep after seekswm42014-07-211-0/+1
|
* audio: remove unused metadata fieldwm42014-07-211-1/+0
| | | | | This was used for replaygain at some point, until replaygain info was passed through explicitly.
* player: simplify a conditionwm42014-07-201-7/+8
| | | | | | | Move a condition somewhere else, which makes it conceptually simpler. Also, the assignment to full_audio_buffers removed with this commit was dead, and its value never used.
* player: simplify logic on video errorswm42014-07-201-1/+1
| | | | | | | | | Fatal errors in the vidoe chain (such as failing to initialize the video chain) disable video decoding. Restart the playloop, instead of just continuing the current iteration. The resulting behavior should be the same, but it gets rid of possible corner cases.
* audio: use symbolic constants instead of magic integerswm42014-07-201-4/+3
| | | | Similar to commit 26468743.
* player: readd code accidentally removed with commit 61efe87ewm42014-07-201-0/+5
| | | | Oops.
* player: fix regression with ordered chapterswm42014-07-202-14/+18
| | | | | | | | | | | | | | | | | | | Broken by commit 1301a907. This commit added demuxer threading, and changed some other things to make them simpler and more orthogonal. One of these things was ntofications about streams that appear during playback. That's an obscure corner case, but the change made handling of it as natural as normal initialization. This didn't work for two reasons: 1. When playing an ordered chapters file where the initial segment was not from the main file, its streams were added to the track list. So they were printed twice, and switching to the next segment didn't work, because the right streams were not selected. 2. EDL, CUE, as well as possibly certain Matroska files don't have any data or tracks in the "main" demuxer, so normally the first segment is picked for the track list. This was simply broken. Fix by sprinkling the code with various hacks.
* command: potentially fix dvd angle settingwm42014-07-201-5/+4
| | | | | | | | This called demux_flush(), but that doesn't make any sense with an asynchronously running demuxer. It would just keep reading and add new packets again. Explicitly pause the demuxer, so that this can't happen. Also, when flushing, data will be missing, so the decoders should always be reinitialized, even if the operation fails.
* player: don't wait forever with --cache-pause-below behaviorwm42014-07-201-0/+1
| | | | | | | Commit dc00b146, which disables polling by default, missed another instance of polling: when the player pauses automatically on low cache. This could lead to apparent freezes when playing network streams.
* video: use symbolic constants instead of magic integerswm42014-07-183-38/+43
| | | | | | | | | In my opinion this is not really necessary, since there's only a single user of update_video(), but others reading this code would probably hate me for using magic integer values instead of symbolic constants. This should be a purely cosmetic commit; any changes in behavior are bugs.
* video: don't block when reading video packetswm42014-07-183-13/+35
| | | | | | | | | | | | Instead of blocking on the demuxer when reading a packet, let packets be read asynchronously. Basically, it polls whether a packet is available, and if not, the playloop goes to sleep until the demuxer thread wakes it up. Note that the player will still block for I/O, because audio is still read synchronously. It's much harder to do the same change for audio (because of the design of the audio decoding path and especially initialization), so audio will have to be done later.
* player: remove the last instances of pollingwm42014-07-183-38/+39
| | | | | | | | | | | | | | | | | Mouse cursor handling, --heartbeat-cmd, and OSD messages basically relied on polling. For this reason, the playloop always used a small timeout (not more than 500ms). Fix these cases, and raise the timeout to 100 seconds. There is no reason behind this number; for this specific purpose it's as close to infinity as any other number. On MS Windows, or if vo_sdl is used, the timeout remains very small. In these cases the GUI code doesn't do proper event handling in the first place, and fixing it requires much more effort. getch2_poll() still does polling, because as far as I'm aware no event- based way to detect this state change exists.
* demux: add a demuxer threadwm42014-07-166-102/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a thread to the demuxer which reads packets asynchronously. It will do so until a configurable minimum packet queue size is reached. (See options.rst additions.) For now, the thread is disabled by default. There are some corner cases that have to be fixed, such as fixing cache behavior with webradios. Note that most interaction with the demuxer is still blocking, so if e.g. network dies, the player will still freeze. But this change will make it possible to remove most causes for freezing. Most of the new code in demux.c actually consists of weird caches to compensate for thread-safety issues (with the previously single-threaded design), or to avoid blocking by having to wait on the demuxer thread. Most of the changes in the player are due to the fact that we must not access the source stream directly. the demuxer thread already accesses it, and the stream stuff is not thread-safe. For timeline stuff (like ordered chapters), we enable the thread for the current segment only. We also clear its packet queue on seek, so that the remaining (unconsumed) readahead buffer doesn't waste memory. Keep in mind that insane subtitles (such as ASS typesetting muxed into mkv files) will practically disable the readahead, because the total queue size is considered when checking whether the minimum queue size was reached.
* ao_lavc: Fix design of audio pts handling.Rudolf Polzer2014-07-161-1/+1
| | | | | | | | | There was confusion about what should go into audio pts calculation and what not (mainly due to the audio push thread). This has been fixed by using the playing - not written - audio pts (which properly takes into account the ao's buffer), and incrementing the samples count only by the amount of samples actually taken from the buffer (unfortunately this now forces us to keep the lock too long for my taste).
* Revert "Remove DVD and Bluray support"wm42014-07-157-0/+495
| | | | | | This reverts commit 4b93210e0c244a65ef10a566abed2ad25ecaf9a1. *shrug*
* Remove DVD and Bluray supportwm42014-07-147-495/+0
| | | | It never worked well. Just remux your DVD and BD images to mkv.
* command: don't show VO information in colorspace propertieswm42014-07-131-3/+1
| | | | | | | | | | Until now, changing the properties showed the VO colorspace parameters on OSD. This didn't work quite well, because it showed the VO parameters _before_ the change. This is because at least one video frame with the new parameters has to be shown, and this doesn't happen right after changing the property, but a bit later. Also fix a random typo in unrelated code.
* Remove some mp_msg calls with no trailing \nwm42014-07-131-21/+21
| | | | | | | The final goal is all mp_msg calls produce complete lines. We want this because otherwise, race conditions could corrupt the terminal output, and it's inconvenient for the client API too. This commit works towards this goal. There's still code that has this not fixed yet, though.
* player: remove some inactive codewm42014-07-131-8/+1
| | | | | | | demux_seek() actually doesn't return seek success. Instead, it fails if the demuxer is flagged as unseekable (but this is checked explicitly at the beginning of this function), or if the seek target PTS is MP_NOPTS_VALUE (which can never happen).
* audio: drop buffered audio when switching tracks or filterswm42014-07-132-0/+2
| | | | | | | | No reason to wait until the audio has been played. This isn't a problem with gapless audio disabled, and since gapless is now default, this behavior might be perceived as regression. CC: @mpv-player/stable
* osc: improve previous commitChrisK22014-07-101-6/+3
|
* osc: round displayed cache valueChrisK22014-07-101-3/+3
| | | | Fixes #919
* build: include <strings.h> for strcasecmp()wm42014-07-103-0/+3
| | | | | | | It happens to work without strings.h on glibc or with _GNU_SOURCE, but the POSIX standard requires including <strings.h>. Hopefully fixes OSX build.
* demux: remove accurate_seek fieldwm42014-07-081-5/+3
| | | | It's unused now. (Only the dvd code used it until recently.)
* osc: fix failure when using DVD menuswm42014-07-071-1/+1
| | | | [osc] Lua error: mp.assdraw:31: attempt to concatenate local 's' (a nil value)
* lua: redo error handling, print backtraceswm42014-07-071-82/+90
| | | | | | | | | | | | | | | | | | | | The original goal was just adding backtraces, however making the code safe (especially wrt. to out of memory Lua errors) was hard. So this commit also restructures error handling to make it conceptually simpler. Now all Lua code is run inside a Lua error handling, except the calls for creating and destroying the Lua context, and calling the wrapper C function in a safe way. The new error handling is actually conceptually simpler and more correct, because you can just call any Lua function at initialization, without having to worry whwther it throws errors or not. Unfortunately, Lua 5.2 removes lua_cpcall(), so we have to emulate it. There isn't any way to emulate it in a way that works the same on 5.1 and 5.2 with the same semantics in error cases, so ifdeffery is needed. The debug.traceback() function also behaves weirdly differently between the Lua versions, so its output is not as nice as it could be (empty extra line).
* Remove stream_pts stuffwm42014-07-062-19/+0
| | | | | This was used by DVD/BD, but its usage was removed with one of the previous commits.
* demux: minor simplificationwm42014-07-061-1/+1
| | | | Oops, should have been part of commit 37085788.
* player: don't use stream position as fallback for percent-poswm42014-07-051-3/+2
| | | | | | | | This should be unneeded, and the packet position is already sufficient for this case. Accessing the stream position directly is going to be a problem when the stream is accessed from another thread later.
* dvd: move angle switching codewm42014-07-051-14/+28
| | | | | No need to provide a "nice" API for it; just do this stuff directly in the command code.
* dvd, bluray, cdda: add demux_disc containing all related hackswm42014-07-053-114/+0
| | | | | | | | | | | | DVD and Bluray (and to some extent cdda) require awful hacks all over the codebase to make them work. The main reason is that they act like container, but are entirely implemented on the stream layer. The raw mpeg data resulting from these streams must be "extended" with the container-like metadata transported via STREAM_CTRLs. The result were hacks all over demux.c and some higher-level parts. Add a "disc" pseudo-demuxer, and move all these hacks and special-cases to it.
* discnav: fix a commentwm42014-07-051-1/+1
|
* demux: make start time a simple fieldwm42014-07-052-3/+3
| | | | Simpler, especially for later changes.
* demux: make replaygain per-trackwm42014-07-051-1/+1
| | | | | | It's unlikely that files with multiple audio tracks and with replaygain actually happen, but this change might help avoid minor corner cases with later changes.
* client API: allow calling mpv_terminate_destroy(NULL)wm42014-07-041-0/+3
| | | | | | This is an oversight and a bug. CC: @mpv-player/stable
* command: include new "playback-time" property in update mechanismwm42014-07-031-1/+1
|
* command: remove some code duplication in cache propertieswm42014-07-021-75/+33
| | | | | | | This also means that the printed size is always rounded to KBs, because the cache properties are returned in KB. I think this doesn't matter much. But if it does, the cache properties should probably changed to return bytes in the first place.
* command: cache can actually have full-size 0wm42014-07-021-4/+4
| | | | Then it's simply empty.
* command: change cache perentage to float, add cache-free and cache-usedAndrey Morozov2014-07-024-9/+104
|
* Audit and replace all ctype.h useswm42014-07-014-5/+2
| | | | | | | | | | | | | | | | Something like "char *s = ...; isdigit(s[0]);" triggers undefined behavior, because char can be signed, and thus s[0] can be a negative value. The is*() functions require unsigned char _or_ EOF. EOF is a special value outside of unsigned char range, thus the argument to the is*() functions can't be a char. This undefined behavior can actually trigger crashes if the implementation of these functions e.g. uses lookup tables, which are then indexed with out-of-range values. Replace all <ctype.h> uses with our own custom mp_is*() functions added with misc/ctype.h. As a bonus, these functions are locale-independent. (Although currently, we _require_ C locale for other reasons.)
* player: fix start position when specifying with percentTsukasa OMOTO2014-06-291-1/+1
|
* options: support setting start time relative to start PTSTsukasa OMOTO2014-06-291-3/+8
| | | | Signed-off-by: wm4 <wm4@nowhere>
* player: make the time display relative to start PTSTsukasa OMOTO2014-06-296-10/+27
| | | | | | This commit makes the playback start time always at time 0. Signed-off-by: wm4 <wm4@nowhere>
* sub: fix undefined behavior with dvd://wm42014-06-281-1/+1
| | | | | | The string could get reallocated. CC: @mpv-player/stable
* scripting: shorten a linewm42014-06-261-2/+3
| | | | | | Also allows it to deal with NULL return values, which currently is not needed, but may or may not be required at some point in the future (what if malloc fails).
* config, player: avoid some temporary talloc contextswm42014-06-261-15/+10
| | | | | IMO a semi-bad concept, that the mpv code unfortunately uses way too much.
* player: create config dir if it doesn't existwm42014-06-261-0/+2
| | | | | | | This was dropped in the commit adding XDG support, probably accidentally. Also normalize some whitespace.
* player: remove some minor code duplication in config loader codewm42014-06-263-21/+16
| | | | | | | It's better to keep the logic in one place. Also drop that a broken config file aborts loading of the player. I don't see much reason for this, and it inflates the code slightly.
* Basic xdg directory implementationKenneth Zhou2014-06-263-19/+24
| | | | | | | | | | Search $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS for config files. This also negates the need to have separate user and global variants of mp_find_config_file() Closes #864, #109. Signed-off-by: wm4 <wm4@nowhere>
* command: fix tv-channel propertywm42014-06-251-0/+3
| | | | | Now it's at least actually relayed to the TV code. I didn't/couldn't test whether it actually works, though.
* options: Expose --colormatrix-primaries to the userNiklas Haas2014-06-221-0/+29
| | | | Signed-off-by: wm4 <wm4@nowhere>
* options: allow adding multiple files with --audio-filewm42014-06-181-2/+4
| | | | At least 1 person expected that this works this way.
* video: correct spelling: mp_image_params_equals -> mp_image_params_equalwm42014-06-171-2/+2
| | | | | The type is struct mp_image_params, so the "params" should have a "s". "equals" shouldn't, because it's plural for 2 params. Important.
* vo: make draw_image and vo_queue_image transfer image ownershipwm42014-06-171-1/+0
| | | | Basically a cosmetic change. This is probably more intuitive.
* encode: disable playback framedroppingwm42014-06-171-0/+1
| | | | | --framedrop is intended for playback only, and does nothing good with encoding. It would just randomly drop frames.
* discnav: make OSD path explicitly thread-safewm42014-06-161-16/+31
| | | | | | | | The main issue was actually that the OSD callback locked the subtitle decoder, which does not necessarily work, because the OSD code is already allowed to lock it. The state was already protected by unsetting the callback (which involes the OSD lock). So, in summary, this is probably just a cleanup.
* video/out: change aspects of OSD handlingwm42014-06-154-33/+12
| | | | | | | | | Let the VOs draw the OSD on their own, instead of making OSD drawing a separate VO driver call. Further, let it be the VOs responsibility to request subtitles with the correct PTS. We also basically allow the VO to request OSD/subtitles at any time. OSX changes untested.
* command: redo the property typewm42014-06-133-508/+601
| | | | | | | | | | | | | | | | | | | | | | | Instead of absuing m_option to store the property list, introduce a separate type for properties. m_option is still used to handle data types. The property declaration itself now never contains the option type, and instead it's always queried with M_PROPERTY_GET_TYPE. (This was already done with some properties, now all properties use it.) This also fixes that the function signatures did not match the function type with which these functions were called. They were called as: int (*)(const m_option_t*, int, void*, void*) but the actual function signatures were: int (*)(m_option_t*, int, void*, MPContext *) Two arguments were mismatched. This adds one line per property implementation. With additional the reordering of the parameters, this makes most of the changes in this commit.
* win32: implement --priority differentlywm42014-06-121-2/+2
| | | | | | | Does anyone actually use this? For now, update it, because it's the only case left where an option points to a global variable (and not a struct offset).
* encode: don't load Lua scriptswm42014-06-121-0/+2
| | | | This is most likely never intended.
* encode: make option struct localwm42014-06-112-4/+6
| | | | Similar to previous commits.
* Add more constwm42014-06-117-15/+15
| | | |