summaryrefslogtreecommitdiffstats
path: root/player/scripting.c
Commit message (Collapse)AuthorAgeFilesLines
* scripting: don't attempt to load builtin scripts twicewm42016-09-261-1/+0
| | | | | | | | | During init it will first call mp_load_builtin_scripts(), and then again via mp_load_scripts(). This was harmless (a second attempt won't load it again if the first one was successful), but it's unnecessary, and also looks confusing if the scripts failed to load the first time.
* command: add a load-script commandwm42016-09-221-5/+5
| | | | | | | The intention is to give libmpv users as much flexibility to load scripts as using mpv from CLI, but without restricting libmpv users from having to decide everything on creation time, or having to go through hacks like recreating the libmpv context to update state.
* player: make --osc/--ytdl settable during playbackwm42016-09-201-4/+32
| | | | | | | | | Setting the osc or ytdl properties will now load/unload the associated scripts. (For ytdl this does not mean the currently played URL will be reloaded.) Also add a changelog entry for this, which also covers the preceding work for --terminal.
* player: litter code with explicit wakeup callswm42016-09-161-0/+1
| | | | | | | | | | | | | 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.
* Relicense some non-MPlayer source files to LGPL 2.1 or laterwm42016-01-191-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* path: make mp_path_join accept normal C stringswm42015-05-091-1/+1
| | | | | Instead of bstr. Most callers of this function do not need bstr. The bstr version of this function is now mp_path_join_bstr().
* lua: remove deprecated "lua" sub directorieswm42015-05-091-19/+5
| | | | | The compatibility code and the deprecation warning were at least in releases 0.8 and 0.9 - time to get rid of them.
* player: properly destroy client context if thread can't be createdwm42015-04-301-1/+4
| | | | Minor leak in an obscure out of memory case.
* scripting: fix/improve deprecation messagewm42014-12-151-3/+6
| | | | | | | | | The message was missing a '\n', so it was merged with the next line, which also typically caused it not to be printed with the colors for warnings. Print the full new path in the warning message. (Normally, cfg should never be NULL, so accounting for this case is just for robustness.)
* options: deprecate 'lua' based options/dirs for 'script'Avi Halachmi (:avih)2014-12-151-7/+18
| | | | | | | | | | | | - --lua and --lua-opts change to --script and --script-opts - 'lua' default script dirs change to 'scripts' - DOCS updated - 'lua-settings' dir was _not_ modified The old lua-based names/dirs still work, but display a warning. Signed-off-by: wm4 <wm4@nowhere>
* player: integrate ytdl_hook.luawm42014-11-191-0/+2
|
* osdep: limit thread names to 16 characterswm42014-10-201-1/+1
| | | | | | | | | | | | | | | | It turns out the glibc people are very clever and return an error if the thread name exceeds the maximum supported kernel length, instead of truncating the name. So everyone has to hardcode the currently allowed Linux kernel name length limit, even if it gets extended later. Also the Lua script filenames could get too long; use the client name instead. Another strange thing is that on Linux, unrelated threads "inherit" the name by the thread they were created. This leads to random thread names, because there's not necessarily a strong relation between these threads (e.g. script command leads to filter recreation -> the filter's threads are tagged with the script's thread name). Unfortunate.
* Set thread name for debuggingwm42014-10-191-0/+5
| | | | | | | | | | Especially with other components (libavcodec, OSX stuff), the thread list can get quite populated. Setting the thread name helps when debugging. Since this is not portable, we check the OS variants in waf configure. old-configure just gets a special-case for glibc, since doing a full check here would probably be a waste of effort.
* win32: get rid of mp_stat in the normal source codewm42014-10-171-1/+1
| | | | | | | | | | | mp_stat() instead of stat() was used in the normal code (i.e. even on Unix), because MinGW-w64 has an unbelievable macro-mess in place, which prevents solving this elegantly. Add some dirty workarounds to hide mp_stat() from the normal code properly. This now requires replacing all functions that use the struct stat type. This includes fstat, lstat, fstatat, and possibly others. (mpv currently uses stat and fstat only.)
* player: open stream and demuxer asynchronouslywm42014-10-061-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Run opening the stream and opening the demuxer in a separate thread. This should remove the last code paths in which the player can normally get blocked on network. When the stream is opened, the player will still react to input and so on. Commands to abort opening can also be handled properly, instead of using some of the old hacks in input.c. The only thing the user can really do is aborting loading by navigating the playlist or quitting. Whether playback abort works depends on the stream implementation; with normal network, this will depend on what libavformat (via "interrupt" callback) does. Some pain is caused by DVD/BD/DVB. These want to reload the demuxer sometimes. DVB wants it in order to discard old, inactive streams. DVD/BD for the same reason, and also for reloading stream languages and similar metadata. This means the stream and the demuxer have to be loaded separately. One minor detail is that we now need to copy all global options. This wasn't really needed before, because the options were accessed on opening only, but since opening is now on a separate thread, this obviously becomes a necessity.
* lua: synchronously wait until scripts are loadedwm42014-09-061-5/+17
| | | | | | | | | | | | | | | | | This makes the player wait until each script is loaded. Do this to give the script a chance to setup all its event handlers. It might also be useful to allow a script to change options that matter for playback. While waiting for a script to be loaded, the player actually accepts input. This is needed because the scripts can execute player commands anyway while they are being "loaded". The player won't react to most commands though: it can't quit or navigate the playlist in this state. For deciding whether a script is finally loaded, we use a cheap hack: if mpv_wait_event() is called, it's considered loaded. Let's hope this is good enough. I think it's better than introducing explicit API for this. Although I'm sure this will turn out as too simplistic some time in the future, the same would probably happen with a more explicit API.
* Move compat/ and bstr/ directory contents somewhere elsewm42014-08-291-1/+1
| | | | | | | | | 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.
* 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.
* build: include <strings.h> for strcasecmp()wm42014-07-101-0/+1
| | | | | | | 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.
* 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).
* Basic xdg directory implementationKenneth Zhou2014-06-261-4/+4
| | | | | | | | | | 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>
* Add more constwm42014-06-111-1/+1
| | | | | | | While I'm not very fond of "const", it's important for declarations (it decides whether a symbol is emitted in a read-only or read/write section). Fix all these cases, so we have writeable global data only when we really need.
* client API: rename mpv_destroy() to mpv_detach_destroy()wm42014-06-071-1/+1
| | | | | | A bit verbose, but less misleading. In most cases, the API user probably actually wants mpv_terminate_destroy() instead, so the less-useful function shouldn't have a simnpler name anyway.
* lua: make warning about unknown scripts -v onlywm42014-06-041-1/+1
|
* player: reorganize how lua scripts are loadedwm42014-05-131-0/+179
Make loading of scripts independent of Lua. Move some of the loading code from lua.c to scripting.c, and make it easier to add new scripting backends.