summaryrefslogtreecommitdiffstats
path: root/player/main.c
Commit message (Collapse)AuthorAgeFilesLines
* mac/apphub: migrate remaining events functionality to new AppHubder richter2024-03-241-1/+1
| | | | | | | | add new app_bridge objc file for bridging between mpv core and app functionality. replace old EventsResponder singleton with AppHub. another step to clean up all App functionality and have one central place for it.
* player/main: move terminal_uninit to the endKacper Michajłow2024-03-191-5/+6
| | | | | It is strange to do terminal_uninit() and still use terminal after. Even tho it has no side-effects.
* osdep/mac: make mac naming of files, folders and function consistentder richter2024-02-281-2/+2
| | | | | rename all macOS namings (osx, macosx, macOS, macos, apple) to mac, to make naming consistent.
* player/main: don't set the main thread nameDudemanguy2024-02-261-1/+0
| | | | | | | 98a27b3cd1e6af743af67699318df1946ce5bf8f changed this to mpv but that's kind of pointless since the binary is already named mpv so that will be the default thread name. Evidently, people rename/symlink the binary to something else so might as well make them happier. Fixes #13469.
* ALL: use new mp_thread abstractionKacper Michajłow2023-11-051-7/+6
|
* player/main: set main thread name as mpvKacper Michajłow2023-11-011-1/+1
| | | | | Now that we don't prepend `mpv/` to all thread names, `main` is too ambiguous and since it is main thread it can be seen as process name.
* mp_threads: rename threads for consistent naming across all of themKacper Michajłow2023-10-271-0/+2
| | | | | | | | I'd like some names to be more descriptive, but to work with 15 chars limit we have to make some sacrifice. Also because of the limit, remove the `mpv/` prefix and prioritize actuall thread name.
* meson: make libplacebo a required dependencyllyyr2023-10-231-4/+0
| | | | | | | Make it not possible to build mpv without the latest libplacebo anymore. This will allow for less code duplication between mpv and libplacebo, and in the future also let us delete legacy ifdefs and track libplacebo better.
* osdep: drop atomic fallbackNRK2023-10-201-4/+0
| | | | | even msvc (which mpv apparently doesn't support) supports C11 atomics now. no need to carry around fallback with subtle semantic differences.
* player/main: do not print build time, if it is unknownKacper Michajłow2023-08-021-2/+3
|
* build: remove outdated generated directoryDudemanguy2023-07-311-1/+1
| | | | | | | | | | | | | | | | This only existed as essentially a workaround for meson's behavior and to maintain compatibility with the waf build. Since waf put everything in a generated subdirectory, we had to put make a subdirectory called "generated" in the source for meson so stuff could go to the right place. Well now we don't need to do that anymore. Move the meson.build files around so they go in the appropriate place in the subdirectory of the source tree and change the paths of the headers accordingly. A couple of important things to note. 1. mpv.com now gets made in build/player/mpv.com (necessary because of a meson limitation) 2. The macos icon generation path is shortened to TOOLS/osxbundle/icon.icns.inc.
* options: read config file as streamThomas Weißschuh2023-04-291-1/+1
| | | | | This aligns the possible sources of config files other loaded data. For example `--input-conf`.
* player: remove unittest optionDudemanguy2023-03-021-6/+0
| | | | | | | | | Since meson has its own unit testing system, let's rework mpv's tests so they integrate nicely with this. To prepare for this, start off by dropping the unittest option. Of course, this means that tests will no longer be supported in the waf build at all but it will be dropped anyway. Note that the tests option is preserved for the meson build. We will still make use of this in the future commits.
* msg: log-file set at mpv.conf: don't ignore early messagesAvi Halachmi (:avih)2023-01-231-2/+6
| | | | | | | | | | | | | | | | | Previously, if log-file was set not via a CLI option (e.g. set via mpv.conf or other config file, or set from a script init phase), then meaningful early log messages were thrown away because the log file name was unknown initially. Such early log messages include the command line arguments, any options set from mpv.conf, and possibly more. Now we store up to 5000 early messages before the log file name is known, and flush them once/if it becomes known, or destroy this buffer once mpv init is complete. The implementation is similar and adjacent, but not identical, to an existing early log system for mpv clients which request a log buffer.
* player/main: log libplacebo version if built with itJan Ekström2022-11-151-0/+8
| | | | | As we start basing more and more functionality on it, it makes sense to start logging it more visibly as part of --version.
* audio: try to use playback AO as hotplug AO firstThomas Weißschuh2022-09-111-1/+1
| | | | | | | | | | | | | | | | | | | | | When a platform has multiple valid AOs that can provide hotplug events we should try to use the one that also provides playback. Concretely this will help when introducing hotplug support for ao_pipewire. Currently ao_pulse is probed by ao_hotplug_get_device_list() before ao_pipewire and on the common setups where both AOs could work pulse will be selected for hotplug handling. This means that hotplug_init() of ao_pipewire will never be called and list_devs() has to do its own initialization. But if ao_pulse is non-functional or not compiled-in suddenly ao_pipewire *must* implement hotplug_init() for hotplugging events to work for all. Also if the hotplug ao_pulse connects to a PulseAudio instance that is not emulated by the same PipeWire instance as the playback ao_pipewire the hotplug events are useless.
* player: check for argv before printing help textDudemanguy2022-05-161-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Both mpv's main function and the client API use mp_initialize to start up. In general, these work the same however the client API had one slight, unnecessary limitation: you can't start it up with idle=no. In practice, the libmpv profile (used with the client API) sets idle to yes, so it's rarely encountered, but there's no particular reason why this policy needs to be enforced. It turns out that mp_initialize does a quick check to see if there are any entries in the playlist and if idle mode is set. If not, it prints the help message and exits. Basically, it's just the part that handles the terminal message when you type "mpv" with no arguments. Unfortunately with idle=no, the client API also hits this code path, exits prematurely with 1 and thus returns an API error. Fortunately, the fix is very simple. If the client API is used instead of the "normal" mpv executable, then the mp_initialize function gets a NULL for the options argument. When starting mpv from the terminal (when you would want to see the before mentioned help text), there will always be at least an argv[0] (the mpv executable name itself) so we can reliably distinguish between the two. The other case where there could be no argv is if the pseudo-gui profile is used, but this always enforces idle so we don't have to worry about it either. In other words, with this combination of conditions (options, no idle, and no playlist entries), we can be sure this is from a user calling mpv in the terminal with no arguments. Therefore, other cases can be allowed which means client API users can initialize with idle=no. Fixes #10162.
* options: add watch-later-optionsGuido Cella2021-07-211-1/+4
| | | | | | | | | | This allows configuring which options are saved by quit-watch-later. Fixes #4126, #4641 and #5567. Toggling a video or audio filter twice would treat the option as changed because the backup value is NULL, and the current value of vf/af is a list with one empty item, so obj_settings_list_equal had to be changed.
* demux: Move demuxer help to new standard mechanismPhilip Langdale2021-03-281-8/+0
| | | | | Previously, demux help was handled as a special case in main.c and this is no longer necessary.
* build: change filenames of generated fileswm42020-06-041-1/+1
| | | | Force them into a more consistent naming schema.
* player, ta: remove use of an old macrowm42020-04-131-1/+1
| | | | | I thought that would make a nice idiom, but it ended up being useless or clunky.
* player, stats: more silly debug stuffwm42020-04-101-0/+2
| | | | | In addition to stats.c being gross, I don't think master branch code should be littered with debug code. But it's a helpful abomination.
* stats: some more performance graphswm42020-04-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an infrastructure for collecting performance-related data, use it in some places. Add rendering of them to stats.lua. There were two main goals: minimal impact on the normal code and normal playback. So all these stats_* function calls either happen only during initialization, or return immediately if no stats collection is going on. That's why it does this lazily adding of stats entries etc. (a first iteration made each stats entry an API thing, instead of just a single stats_ctx, but I thought that was getting too intrusive in the "normal" code, even if everything gets worse inside of stats.c). You could get most of this information from various profilers (including the extremely primitive --dump-stats thing in mpv), but this makes it easier to see the most important information at once (at least in theory), partially because we know best about the context of various things. Not very happy with this. It's all pretty primitive and dumb. At this point I just wanted to get over with it, without necessarily having to revisit it later, but with having my stupid statistics. Somehow the code feels terrible. There are a lot of meh decisions in there that could be better or worse (but mostly could be better), and it just sucks but it's also trivial and uninteresting and does the job. I guess I hate programming. It's so tedious and the result is always shit. Anyway, enjoy.
* player: fix subtle idle mode differences on early program startwm42020-03-211-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the user manages to run a "loadfile x append" command before the loop in mp_play_files() is entered, then the player could start playing these. This isn't expected, because appending files to the playlist in idle mode does not normally start playback. It could happen because there is a short time window where commands are processed before the loop is entered (such as running the command when a script is loaded). The idle mode semantics are pretty weird: if files were provided in advance (on the command line), then these should be played immediately. But if idle mode was already entered, and something is appended to the playlist using "append", i.e. without explicitly triggering playback, then it should remain in idle mode. Try to follow this by redefining PT_STOP to strictly mean idle mode. Remove the playlist->current check from idle_loop(), since only the stop_play field counts now (cf. what mp_set_playlist_entry() does). This actually introduces the possibility that playlist->current, and with it playlist-pos, are set to something, even though playback is not active or being started. Previously, this was only possible during state transitions, such as when changing playlist entries. Very annoyingly, this means the current way MPV_EVENT_IDLE was sent doesn't work anymore. Logically, idle mode can be "active" even if idle_loop() was not entered yet (between the time after mp_initialize() and before the loop in mp_play_files()). Instead of worrying about this, redo the "idle-active" property, and deprecate the event. See: #7543
* player: remove additional newline before exit messagewm42020-03-211-1/+1
| | | | | | What was this even for? Also, most times, the cleared status line will show up as an empty new line anyway, so this commit reduces the empty new lines from 2 to 1.
* build: make libass non-optionalwm42020-03-181-5/+0
| | | | | | | | | | | | | | Using mpv without libass isn't really supported, since it's not only used to display ASS subtitles, but all text subtitles, and even OSD. At least 1 user complained that the player printed a warning if built without libass. Avoid trying to create the impression that using this software without libass is in any way supported or desirable, and make it fully mandatory. (As far as making dependencies optional goes, I'd rather make ffmpeg optional, which is an oversized and bloated library, rather than something tiny like libass.)
* player: rearrange libav* library checkwm42020-03-081-12/+2
| | | | No need to be nice. Also hopefully breaks idiotic distro patches.
* options: make decoder options local to decoder wrapperwm42020-03-011-16/+0
| | | | | | | | | | | | | | | Instead of having f_decoder_wrapper create its own copy of the entire mpv option tree, create a struct local to that file and move all used options to there. movie_aspect is used by the "video-aspect" deprecated property code. I think it's probably better not to remove the property yet, but fortunately it's easy to work around without needing special handling for this option or so. correct_pts is used to prevent use of hr-seek in playloop.c. Ignore that, if you use --no-correct-pts you're asking for trouble anyway. This is the only behavior change.
* player: make failure to load scripts non-fatal againwm42020-01-201-2/+1
| | | | | Restore the behavior from a few commits ago. I decided that it's strange that this is fatal, since e.g. config file errors are also non-fatal.
* scripting: make player error when attempting to load unknown scriptswm42020-01-191-1/+2
| | | | | | It's ridiculous that --script=something.dumb does not cause an error. Make it error, and extend this behavior to the scripts/ sub-dir in the mpv config dir.
* playlist: change from linked list to an arraywm42019-12-281-1/+1
| | | | | | | | | | | | | | | | | | | Although a linked list was ideal at first, there are cases where it sucks, and became increasingly awkward (with the mpv command API preferring integer indexes to access the list). In future, we probably want to add more playlist-related functionality, so better change it to an array now. An array isn't always ideal either. Since playlist entries are still separate objects (because in some cases you need a stable "iterator" to it), but you still need to efficiently get the next/previous playlist entry, there's a pl_index field, that needs to be maintained. E.g. adding an entry at the start of the playlist => update the pl_index field for all other entries. Well, it's not really worth to do something more complicated to avoid these things. This commit is probably buggy as shit. It's not like I bothered to test everything. That's _your_ role.
* player: add comment to clarify FFmpeg ABI handlingwm42019-12-131-0/+3
| | | | Don't patch it out.
* player: change m_config to use new option handling mechanismswm42019-11-291-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of making m_config a special-case, it more or less uses the underlying m_config_cache/m_config_shadow APIs properly. This makes the player core a (relatively) equivalent user of the core option API. In particular, this means that other threads can change core options with m_config_cache_write_opt() calls (before this commit, this merely led to diverging option values). An important change is that before this commit, mpctx->opts contained the "master copy" of all option data. Now it's just another copy of the option data, and the shadow copy is considered the master. This is why whenever mpctx->opts is written, the change needs to be copied to the master (thus why this commits add a bunch of m_config_notify... calls). If another thread (e.g. a VO) changes an option, async_change_cb is now invoked, which funnels the change notification through the player's layers. The new self_notification parameter on mp_option_change_callback is so that m_config_notify... doesn't trigger recursion, and it's used in cases where the change was already "processed". It's still needed to trigger libmpv property updates. (I considered using an extra m_config_cache for that, but it'd only cause problems with no advantages.) I think the recent changes actually forgot to send libmpv property updates in some cases. This should fix this anyway. In some cases, property updates are reworked, and the potential for bugs should be lower (probably). The primary point of this change is to allow external updates, for example by a VO writing the fullscreen option if the window state is changed by the window manager (rather than mpv changing it). This is not used yet, but the following commits will.
* options: get rid of GLOBAL_CONFIG hackwm42019-11-291-2/+1
| | | | | | | Just an implementation detail that can be cleaned up now. Internally, m_config maintains a tree of m_sub_options structs, except for the root it was not defined explicitly. GLOBAL_CONFIG was a hack to get access to it anyway. Define it explicitly instead.
* options: remove options-to-property bridgewm42019-11-251-2/+0
| | | | | | | | The previous bunch of commits made this unnecessary, so this should be a purely internal change with no user impact. This may or may not open the way to future improvements. Even if not, at least the property/option interaction should now be much less buggy.
* player: remove mechanisms for better logging with repl.luawm42019-11-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | As preparation for making repl.lua part of the core (maybe), add some mechanisms which are supposed to improve its behavior. Add a silent mode. Calling mpv_request_log_messages() with the log level name prefixed with "silent:" will disable logging from the API user's perspective. But it will keep the log buffer, and record new messages, without returning them to the user. If logging is enabled again by requesting the same log level without "silent:" prefix, the buffered log messages are returned to the user at once. This is not documented, because it's far too messy and special as that I'd want anyone to rely on this behavior, but it will be perfectly fine for an internal script. Another thing is that we record early startup messages. The goal is to make the repl.lua script show option and config parsing file errors. This works only with the special "terminal-default" log level. In addition, reduce the "terminal-default" capacity to only 100 log messages. If this is going to be enabled by default, it shouldn't use too much resources.
* test: merge test_helpers.c and index.cwm42019-11-081-1/+1
| | | | | No need to keep them separate. Originally I thought index.c was only going to contain the list of tests, but that didn't happen.
* player: do not require dummy file arguments to use --unittestwm42019-11-081-5/+5
| | | | | Move the test execution above the point where it checks for an empty playlist and exits if that's the case.
* wscript: add --enable-ta-leak-report optionwm42019-11-081-1/+3
| | | | Kind of more convenient because I'm lazy.
* test: make tests part of the mpv binarywm42019-11-081-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now, each .c file in test/ was built as separate, self-contained binary. Each binary could be run to execute the tests it contained. Change this and make them part of the normal mpv binary. Now the tests have to be invoked via the --unittest option. Do this for two reasons: - Tests now run within a "properly" initialized mpv instance, so all services are available. - Possibly simplifying the situation for future build systems. The first point is the main motivation. The mpv code is entangled with mp_log and the option system. It feels like a bad idea to duplicate some of the initialization of this just so you can call code using them. I'm also getting rid of cmocka. There wouldn't be any problem to keep it (it's a perfectly sane set of helpers), but NIH calls. I would have had to aggregate all tests into a CMUnitTest list, and I don't see how I'd get different types of entry points easily. Probably easily solvable, but since we made only pretty basic use of this library, NIH-ing this is actually easier (I needed a list of tests with custom metadata anyway, so all what was left was reimplement the assert_* helpers). Unit tests now don't output anything, and if they fail, they'll simply crash and leave a message that typically requires inspecting the test code to figure out what went wrong (and probably editing the test code to get more information). I even merged the various test functions into single ones. Sucks, but here you go. chmap_sel.c is merged into chmap.c, because I didn't see the point of this being separate. json.c drops the print_message() to go along with the new silent-by-default idea, also there's a memory leak fix unrelated to the rest of this commit. The new code is enabled with --enable-tests (--enable-test goes away). Due to waf's option parser, --enable-test still works, because it's a unique prefix to --enable-tests.
* player: accept compatible later FFmpeg library runtime versionswm42019-10-111-10/+2
| | | | | | | | | | | | | | | | | | mpv warned if the FFmpeg runtime library version was not exactly the same as the build version. This seemed to cause frequent conflicts. At this point, most mpv code probably adheres to the FFmpeg ABI rules, and FFmpeg stopped breaking ABI "accidentally". Another source of problems were mixed FFmpeg/Libav installations, something which nobody does anymore. It's not "our" job to check and enforce ABI compatibility either. So I guess this behavior can be removed. OK, still check for incompatible libraries (according to FFmpeg versioning rules), i.e. different major versions, or if the build version is newer than the runtime version. For now. The comment about ABI problems is still true. In particular, the bytes_read field mentioned in the removed comment is still accessed, and is still an ABI violation. Have fun.
* player: "subprocess" command should stop immediately in idle modewm42019-10-041-0/+2
| | | | | | | | | | | | The description of the "playback_only" field in the "subprocess" command says "you can't start it outside of playback". This did not work correctly: if the player was started in idle mode in the first place, the subprocess was allowed to run even with playback_only=yes. This is a bug, and this change fixes it. Add a test for this to command-test.lua. For #7025.
* player: document FFmpeg ABI rules we intentionally violatewm42019-09-261-0/+2
| | | | | | | | | | That's just a single one. It used to be more, when FFmpeg still required using pointless accessors for tons of fields, which historically broke compatibility with Libav. (I think I wrote the patch to deprecate that crap and to allow direct access myself.) There may be more exceptions, but I forgot about them. Another point is that we don't really trust FFmpeg ABI stability, though.
* m_config: remove m_config_create_shadowwm42019-09-191-1/+1
| | | | | | | A previous commit changed m_config so that it always creates the shadow thing, and the function's only remaining purpose was to initialize mpv_global. It makes much more sense to do that at the caller, and it's only 1 line of code too.
* Implement backwards playbackwm42019-09-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See manpage additions. This is a huge hack. You can bet there are shit tons of bugs. It's literally forcing square pegs into round holes. Hopefully, the manpage wall of text makes it clear enough that the whole shit can easily crash and burn. (Although it shouldn't literally crash. That would be a bug. It possibly _could_ start a fire by entering some sort of endless loop, not a literal one, just something where it tries to do work without making progress.) (Some obvious bugs I simply ignored for this initial version, but there's a number of potential bugs I can't even imagine. Normal playback should remain completely unaff