summaryrefslogtreecommitdiffstats
path: root/player/loadfile.c
Commit message (Collapse)AuthorAgeFilesLines
* player: remove dysfunctional edition switching OSD codewm42017-01-051-1/+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.
* player: don't print format detection error when aborting loadingwm42016-11-291-1/+1
| | | | | | | | The way playback/loading is stopped on the demuxer layer makes it report an error to the higher levels of the player. But if playback/loading was explicitly aborted, printing such an error is confusing and misleading. This was probably just an oversight anyway. Fix it by using the libmpv API reported error field instead, which handles this better.
* player: make --start-time work with --rebase-start-time=noAman Gupta2016-10-221-0/+3
|
* player: make --stop-screensaver runtime-changeablewm42016-10-021-0/+2
| | | | | | | | | | 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: some M_SETOPT_RUNTIME cleanupswm42016-09-221-1/+1
| | | | | | | | | Add this flag where needed. You shouldn't be able to set e.g. config-dir in these situations. Remove the mpctx->initialized check from the property/option bridge, since it's in use strictly only after initialization. Likewise, the apply-profile command doesn't need to check this.
* player: minor changes in init codewm42016-09-191-0/+2
| | | | | | | | | | | | 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: litter code with explicit wakeup callswm42016-09-161-0/+2
| | | | | | | | | | | | | 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/+1
| | | | | | | | | | | | | 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).
* osd: slightly simplify update logicwm42016-09-151-1/+0
| | | | | | | | | | | | | | | | Remove the per-part force_redraw flags, and instead make the difference between flagging dirty state and returning it to the player frontend more explicit. The big issue is that 1. the OSD needs to know the dirty state, and it should be cleared strictly when it is re-rendered (force_redraw flag), and 2. the player core needs to be notified once, and the notification must be reset (want_redraw flag). The call in loadfile.c is replaced by making osd_set_sub() set the change flag. Increasing the change flag on dirty state (the force_redraw check in render_object()) should not be needed, because OSD part renderers set it correctly (at least now). Doing this just because someone pointed this out.
* stream, demux, config: remove some dead/unneeded option-related codewm42016-09-091-3/+1
| | | | | | | | | | 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.
* player: don't directly access demuxer->streamwm42016-08-261-2/+2
| | | | | | | | | | Cleaner and makes it easier to change the underlying stream. mp_property_stream_capture() still directly accesses it directly via demux_run_on_thread(). This is evil, but still somewhat sane and is not getting into the way here. Not sure if I got all field accesses.
* player: allow passing flags to queue_seek()wm42016-08-151-1/+1
| | | | | | | | | | | | 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 --no-autoload-files optionwm42016-08-101-0/+6
| | | | Allt his auto-loading is getting annoying especially for testing.
* player: improve instant track switchingwm42016-08-061-24/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When switching tracks, we normally have the problem that data gets lost due to readahead buffering. (Which in turn is because we're stubborn and instruct the demuxers to discard data on unselected streams.) The demuxer layer has a hack that re-reads discarded buffered data if a stream is enabled mid-stream, so track switching will seem instant. A somewhat similar problem is when all tracks of an external files were disabled - when enabling the first track, we have to seek to the target position. Handle these with the same mechanism. Pass the "current time" to the demuxer's stream switch function, and let the demuxer figure out what to do. The demuxer will issue a refresh seek (if possible) to update the new stream, or will issue a "normal" seek if there was no active stream yet. One case that changes is when a video/audio stream is enabled on an external file with only a subtitle stream active, and the demuxer does not support rrefresh seeks. This is a fuzzy case, because subtitles are sparse, and the demuxer might have skipped large amounts of data. We used to seek (and send the subtitle decoder some subtitle packets twice). This case is sort of obscure and insane, and the fix would be questionable, so we simply don't care. Should mostly fix #3392.
* 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/+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: force VO reconfig when unselecting video trackwm42016-04-231-1/+1
| | | | | Switches to a black window if --force-window is used while coverart "video" is playing.
* player: simplify an aspect of buffering determinationwm42016-04-191-0/+1
| | | | | | | | | | | | | | | 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: fix --stream-dump exit codewm42016-03-261-1/+1
| | | | | Inverted condition due to weird semantics after a refactor some time ago. Fixes #2848.
* demux: remove relative seekingwm42016-02-281-1/+1
| | | | | | | | | | | | | | | | | | | 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: slightly simplify how demuxer streams are enabled/disabledwm42016-02-251-38/+29
| | | | | Instead of having reselect_demux_streams() look at all streams, make it look at the current stream that is being enabled/disabled.
* player: remove pointless callwm42016-02-231-1/+0
| | | | | This is the unfortunate video timer; it's already reset when it actually matters (after video was prepared and before video is actually started).
* player: simplify enabling demuxer threadswm42016-02-231-17/+6
| | | | | No need for this crazy loop anymore, and we can simply enable it for each demuxer when it's opened.
* player: remove unused MPContext.stream fieldwm42016-02-231-8/+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-15/+4
| | | | | | 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 initial seek on playback startwm42016-02-181-2/+0
| | | | | | Accidental leftover from commit ae55896f. (This seek ised to be done with ordered chapters, and was accidentally changed to always being done.)
* player: remove old timeline/ordered chapters supportwm42016-02-151-187/+17
|
* player: add on_preloaded hookwm42016-02-151-0/+16
| | | | (Limited usefulness.)
* player: restore old/correct --force-window behaviorwm42016-02-151-0/+3
| | | | | | | | | When playback of a video ends, and the next file has no video at all (no cover art or anything), then the window must be cleared. This also resizes the window forcibly, which is by design. Fixes #2825.
* player: abort loading if there is a problem with complex filterswm42016-02-101-5/+11
|
* player: add --external-file optionwm42016-02-081-14/+12
| | | | Mostly intended for use with --lavfi-complex.
* player: add complex filter graph supportwm42016-02-051-2/+134
| | | | | | | | | | | | | | | | 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: reduce some dependencies on current_trackwm42016-02-011-15/+11
| | | | Don't mind me.
* demux: disable stream cache if no tracks are selectedwm42016-01-181-1/+4
| | | | | | | | | Slightly helps with timeline stuff, like EDL. There is no need to keep network (or even just disk I/O) busy for all segments at the same time, because 1. the data won't be needed any time soon, and 2. will probably be discarded anyway if the stream is seeked when segment is resumed. Partially fixes #2692.
* demux: remove unused flagwm42016-01-181-3/+1
|
* player: refactor: eliminate MPContext.d_videowm42016-01-171-3/+0
| | | | | | | | | | | | | | 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-20/+12
| | | | The same is going to happen to d_video and d_audio later.
* player: simplify backsteppingwm42016-01-121-1/+0
| | | | | | | | | | | | | | 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.
* demux: merge sh_video/sh_audio/sh_subwm42016-01-121-1/+1
| | | | | | | | | | This is mainly a refactor. I'm hoping it will make some things easier in the future due to cleanly separating codec metadata and stream metadata. Also, declare that the "codec" field can not be NULL anymore. demux.c will set it to "" if it's NULL when added. This gets rid of a corner case everything had to handle, but which rarely happened.
* 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-3/+4
| | | | | | | | | | | | | | | | 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.)
* player: reset playback abort when reloading a filewm42016-01-071-0/+1
| | | | | | | | | | | | PT_RELOAD_FILE is a somewhat obscure case when using DVB or when switching Matroska editions. Both cases were broken, because the asynchronous playback abort mechanism was still triggered. This mechanism is used to force the demuxer and stream layers to exit immediately (instead of blocking on I/O possibly forever), and is normally disabled on playback start. The reopen path is a bit strange, and needs to reset it manually. Pointed out in #2568.
* player: make watch later/resume work when "playing" directorieswm42016-01-061-0/+2
| | | | | | | | | | | | | | If you do "mpv /bla/", and then branch out into sub-directories using playlist navigation, and then used quit and watch later, then playing the same directory did not resume from the previous point. This was because resuming is based on the path hash, so a path prefix can't be detected when resuming the parent directory. Solve this by writing each path prefix when playing directories is involved. (This includes all parent paths, so interestingly, "mpv /" would also resume in the above example.) Something like this was requested multiple times, and I want it too.
* player: make sure streams are selected with ordered chapterswm42016-01-031-3/+3
| | | | | | | | When using --start with timeline/ordered chapters, then the timeline_switch_to_time() function will look at playback_initialized whether to rselect the currently selected streams on the demuxer level. So we need to set this field to true at an earlier stage during initialization, and in particular before the code for --start is called.
* sub: always recreate ASS_Renderer on subtitle decoder reinitwm42015-12-261-1/+0
| | | | | | | This includes the case of switching ordered chapter boundaries. It will now be recreated on each timeline part switch. This shouldn't be much of a problem with modern libass. (Older libass versions use fontconfig for memory fonts, and will be very slow to reinitialize memory fonts.)
* sub: cache subtitle state per track instead of per demuxer streamwm42015-12-261-10/+14
| | | | | | | | | | | | Since commit 6d9cb893, subtitle state doesn't survive timeline switches (ordered chapters etc.). So there is no point in caching the state per sh_stream anymore (which would be required to deal with multiple segments). Move the cache to struct track. (Whether it's worth caching the subtitle state just for the situation when subtitle tracks get reselected is questionable. But for now, it's nice to have the subtitles immediately show up when reselecting a subtitle.)
* sub: clear subtitle list when crossing timeline boundarywm42015-12-251-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When crossing timeline boundaries (such as switching to a new segment or chapter with ordered chapters), clear the internal text subtitle list. This breaks the sub-seek command, but is otherwise not too harmful. Fixes Sub-OC-test-final7.mkv. (The internal text subtitle list is basically a cache to make subtitles show up at the right time when seeking back.) I suspect this was caused by 76fcef61. The sample file times subtitles slightly before the video frame when it should show up. This is to avoid problems with subtitles showing up a frame later than intended. It also means that a subtitle which is supposed to show up on the start of a timeline part boundary actually might first be shown in a different part. Since we now manipulate the packet timestamps, instead of manipulating timestamps after the subtitle decoder, this means this subtitle event would have 2 timestamps, which our code of course does not handle. If the two parts come one after another, this would actually work (since the subtitle would have the same timestamps in the old and new part), but it breaks if the new part (which follows the old part in the physical file) is has a completely different start time in the timeline. Essentially, the trick used to time subtitles correctly is incompatible with the way we cache subtitles (to make them survive seeks). The simple solution is just clearing the cached subtitles when crossing chapter boundaries.
* demux: remove weird tripple-buffering for the sh_stream listwm42015-12-231-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The demuxer infrastructure was originally single-threaded. To make it suitable for multithreading (specifically, demuxing and decoding on separate threads), some sort of tripple-buffering was introduced. There are separate "struct demuxer" allocations. The demuxer thread sets the state on d_thread. If anything changes, the state is copied to d_buffer (the copy is protected by a lock), and the decoder thread is notified. Then the decoder thread copies the state from d_buffer to d_user (again while holding a lock). This avoids the need for locking in the demuxer/decoder code itself (only demux.c needs an internal, "invisible" lock.) Remove the streams/num_streams fields from this tripple-buffering schema. Move them to the internal struct, and protect them with the internal lock. Use accessors for read access outside of demux.c. Other than replacing all field accesses with accessors, this separates allocating and adding sh_streams. This is needed to avoid race conditions. Before this change, this was awkwardly handled by first initializing the sh_stream, and then sending a stream change event. Now the stream is allocated, then initialized, and then declared as immutable and added (at which point it becomes visible to the decoder thread immediately). This change is useful for PR #2626. And eventually, we should probably get entirely of the tripple buffering, and this makes a nice first step.
* player: minor simplificationwm42015-12-231-4/+2
| | | | This tmp thing had not much of a purpose anymore.
* player: init playback speed correctlywm42015-12-101-0/+2
| | | | | Usually not a problem, but could not be initialized early enough in some corner cases.
* player: make timeline switching slightly nicerwm42015-11-181-20/+21
| | | | But not much.
* player: use demuxer ts offset to simplify timeline ts handlingwm42015-11-161-19/+7