summaryrefslogtreecommitdiffstats
path: root/misc
Commit message (Collapse)AuthorAgeFilesLines
* bstr: remove unused bstr_splitlines() functionwm42019-12-232-23/+0
|
* misc: add jni helpersAman Gupta2019-11-192-0/+590
|
* Use mp_log2() instead of av_log2()wm42019-10-311-3/+1
|
* Replace uses of FFMIN/MAX with MPMIN/MAXwm42019-10-312-12/+13
| | | | And remove libavutil includes where possible.
* json: write NaN/Infinity float values as stringswm42019-10-251-2/+4
| | | | | | | | | | | | | JSON doesn't support these for some god-awful reason. (JSON would have been so much better if it weren't based on JavaScript, the plague of this world.) We don't really care whether these specific values "round trip", so we might as well write them in a standard-compliant way. Untested. I was too lazy to even run this, but it probably works. See #6691.
* demux: sort filenames naturally when playing a directory / archivePhilip Sequeira2019-09-292-0/+90
|
* rendezvous: fix a typowm42018-08-311-1/+1
|
* player: some further cleanup of the mp_cancel crapwm42018-05-242-30/+23
| | | | | | | | | | Alway give each demuxer its own mp_cancel instance. This makes management of the mp_cancel things much easier. Also, instead of having add/remove functions for mp_cancel slaves, replace them with a simpler to use set_parent function. Remove cancel_and_free_demuxer(), which had mpctx as parameter only to check an assumption. With this commit, demuxers have their own mp_cancel, so add demux_cancel_and_free() which makes use of it.
* thread_pool: add a helper functionwm42018-05-242-10/+30
| | | | | The behavior of mp_thread_pool_queue() doesn't or shouldn't change, but the new helper function requires touching its logic.
* thread_pool: move comments to .h filewm42018-05-242-17/+17
|
* thread_tools: unify mp_cancel POSIX/win32 paths, add featureswm42018-05-242-52/+153
| | | | | | | | | | | | | | | The OS specifics are merged because the resulting ifdeffery is not much worse than the old ifdeffery, but the logic that is now shared is becoming more complex. Create all objects lazily. The intention is to make mp_cancel instances cheaper. POSIX pipes and win32 Events are pretty heavy weight, and are only needed in special situations. Add a mechanism to "chain" mp_cancel instances. Needed by the later commits for whatever reasons. Untested on win32.
* misc: add linked list helperswm42018-05-241-0/+107
| | | | | | | | | | | | | | | | This provides macros for managing intrusive doubly linked lists. There are many ways how to do those in a "generic" way in C. For example Solaris style lists are pretty nice: https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/sys/list.h https://github.com/illumos/illumos-gate/blob/master/usr/src/common/list/list.c I even have an independent implementation of this, which could be ISC licensed. But I think it's easier to vomit ~100 lines of preprocessor garbage, which has a lower footprint, and I think it wins slightly on the side of type safety, simplicity, and ease of use, even if it doesn't look as magically nice.
* thread_tools: minor simplificationwm42018-05-241-3/+1
|
* misc: move mp_cancel from stream.c to thread_tools.cwm42018-05-242-0/+158
| | | | | | | | | | | | It seems a bit inappropriate to have dumped this into stream.c, even if it's roughly speaking its main user. At least it made its way somewhat unfortunately to other components not related to the stream or demuxer layer at all. I'm too greedy to give this weird helper its own file, so dump it into thread_tools.c. Probably a somewhat pointless change.
* json: add some non-standard extensionswm42018-05-241-3/+33
| | | | | Also clarify this and previously existing differences to standard JSON in ipc.rst.
* json: format slightly nicer escape sequenceswm42018-05-241-5/+18
| | | | | | Make use the escape sequences allowed by JSON. Also update the linked RFC to the newest one.
* misc: move some helper code from client.cwm42018-05-242-0/+54
| | | | | (Slightly oddly function names, because I want to avoid starting them with mpv_*, which is reserved for public API.)
* node: move a mpv_node helper from ipc.c to shared codewm42018-05-242-0/+14
| | | | This particular one is needed in a following commit.
* thread_pool: set thread namewm42018-05-241-0/+3
|
* thread_pool: make it slightly less dumbwm42018-05-242-42/+141
| | | | | | | | | | | | The existing thread pool code is the most primitive thread pool possible. That's fine, but one annoying thing was that it used a static number of threads. Make it dynamic, so we don't need to "waste" idle threads. This tries to add threads as needed. If threads are idle for some time, destroy them again until a minimum number of threads is reached. Also change the license to ISC.
* misc: add a synchronization helperwm42018-05-242-0/+101
| | | | | | | | | | | | | | | | | This is almost like rendezvous(), except it allows async wakeup, and does not require global state. It will be used by a later commit. struct mp_waiter is intended to be allocated on the stack, and uses an initializer including PTHREAD_MUTEX_INITIALIZER. This is the first case in mpv that it uses PTHREAD_MUTEX_INITIALIZER for stack-allocated mutexes. It seems POSIX still does not allow this formally, but since POSIX is worth less than used toilet paper, I don't really care. Modern OSes use futexes, which means you can make _every_ memory location a lock, and this code tries to make use of it, without using OS specific code. The name of the source file is rather generic, because I intend to dump further small helpers there (or maybe move mp_rendezvous() to it).
* dispatch: add an assert()wm42018-05-241-0/+1
|
* player: remove in_dispatch fieldwm42018-04-182-8/+30
| | | | (Not sure if worth the trouble, but it does seem less awkward.)
* dispatch: simplify, disallow recursive invocationwm42018-04-181-75/+60
| | | | | | | | | Recursive invocation was needed up until the previous commit. Drop this feature, and simplify the code. It's more logical, and easier to detect miuses of the API. This partially reverts commit 3878a59e. The original reason for it was removed.
* command: use mpv_node helpers instead of duplicated codewm42018-03-261-1/+4
| | | | | | They didn't exist yet when this code was added. Completely untested.
* m_option: pretty print mpv_node for OSDwm42017-10-302-6/+30
| | | | | | Somewhat useful for debugging. Unfortunately libass (or something else) strips leading whitespace, making it look slightly more ugly than necessary. Still an improvement.
* command: change demuxer-cache-state property to return multiple rangeswm42017-10-262-0/+18
| | | | | | | | | | | | | | | | | | Even if the demuxer cache does not multiple ranges yet. This is to reduce the pain should caching of multiple ranges ever be implemented. Also change it from the sub properties stuff to return a mpv_node directly, which is less roundabout. Sub-property access won't work anymore, though. Remove the seekable-start/-end fields as well, as they're redundant with the ranges. All this would normally be considered an API change, but since it's been only a few days with no known users, change it immediately. This adds some node.c helpers as well, as the code would be too damn fugly otherwise.
* options: add a thread-safe way to notify option updateswm42017-08-222-0/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far, we had a thread-safe way to read options, but no option update notification mechanism. Everything was funneled though the main thread's central mp_option_change_callback() function. For example, if the panscan options were changed, the function called vo_control() with VOCTRL_SET_PANSCAN to manually notify the VO thread of updates. This worked, but's pretty inconvenient. Most of these problems come from the fact that MPlayer was written as a single-threaded program. This commit works towards a more flexible mechanism. It adds an update callback to m_config_cache (the thing that is already used for thread-safe access of global options). This alone would still be rather inconvenient, at least in context of VOs. Add another mechanism on top of it that uses mp_dispatch_queue, and takes care of some annoying synchronization issues. We extend mp_dispatch_queue itself to make this easier and slightly more efficient. As a first application, use this to reimplement certain VO scaling and renderer options. The update_opts() function translates these to the "old" VOCTRLs, though. An annoyingly subtle issue is that m_config_cache's destructor now releases pending notifications, and must be released before the associated dispatch queue. Otherwise, it could happen that option updates during e.g. VO destruction queue or run stale entries, which is not expected. Rather untested. The singly-linked list code in dispatch.c is probably buggy, and I bet some aspects about synchronization are not entirely sane.
* bstr: short-circuit bstr_equals on pointer equalityNiklas Haas2017-08-031-1/+4
| | | | | More efficient in cases where we're comparing a bstr against itself, which can happen in e.g. the ICC profile code.
* vo_opengl: support loading custom user texturesNiklas Haas2017-07-272-0/+41
| | | | | | | | | | | Parsing the texture data as raw strings makes the textures the most portable and self-contained. In order to facilitate different types of shaders, the parse_user_shader interaction has been changed to instead have it loop through blocks and call the passed functions for each valid block parsed. This is more modular and also cleaner, with better code separation. Closes #4586.
* misc/ring: fix comment typoKevin Mitchell2017-07-091-2/+2
|
* bstr: short-circuit bstr_equals()wm42017-07-021-2/+2
|
* misc/json: avoid redundant conditionRaúl Peñacoba2017-07-011-1/+1
| | | | Closes #4415
* ring: use 64 bit counterswm42017-06-281-3/+3
| | | | | | | | | Apparently, this messes up on wraparound (although it shouldn't). After 2^32 bytes an audio "blip" happens with AOs that use this ringbuffer. Whatever, we can fix this by switching to a 64 bit counter. There's also a good chance the ringbuffer will be dropped completely, so don't waste more time on this.
* misc: add a thread poolwm42017-04-012-0/+135
| | | | To be used by the following commits.
* osx: consistent normalisation when searching for external filesAkemi2017-02-022-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | several unicode characters can be encoded in two different ways, either in a precomposed (NFC) or decomposed (NFD) representation. everywhere besides on macOS, specifically HFS+, precomposed strings are being used. furthermore on macOS we can get either precomposed or decomposed strings, for example when not HFS+ formatted volumes are used. that can be the case for network mounted devices (SMB, NFS) or optical/removable devices (UDF). this can lead to an inequality of actual equal strings, which can happen when comparing strings from different sources, like the command line or filesystem. this makes it mainly a problem on macOS systems. one case that can potential break is the sub-auto option. to prevent that we convert the search string as well as the string we search in to the same normalised representation, specifically we use the decomposed form which is used anywhere else. this could potentially be a problem on other platforms too, though the potential of occurring is very minor. for those platforms we don't convert anything and just fallback to the input. Fixes #4016
* charset_conv: fallback to interpreting subs as latin1 if iconv failswm42017-01-221-1/+1
| | | | | | | | | | | | | | | For display purposes, it's better to show scrambled text - at least that's a more actionable failure mode than spamming the terminal with FFmpeg nonsense error messages. This avoids the obnoxious and pointless "Invalid UTF-8 in decoded subtitles text; maybe missing -sub_charenc option" FFmpeg error, which will be spammed on every single subtitle event. We don't even have a -sub-charenc option, fuck FFmpeg. Did I mention fuck FFmpeg yet? Because fuck FFmpeg.
* charset_conv: support minimum compatibility to utf8:... syntaxwm42017-01-221-1/+5
| | | | Because it's the most commonly used one, and trivial to support.
* options: drop deprecated --sub-codepage syntaxwm42017-01-191-70/+5
|
* charset_conv: fix "auto" fallback with uchardet not compiledwm42016-12-281-1/+3
| | | | | | | | | Tried to open iconv with "auto" as source codepage, instead of using the latin1 fallback. This also neutralizes the libavcodec dumbass UTF-8 check, which discards subtitles not in UTF-8 and shows an error message for ffmpeg CLI instead. Fixes #3954.
* bstr: change to LGPLwm42016-12-112-14/+14
| | | | | | | | Was started by Uoti Urpala in commit 5f631d1c. Although it was made part of demux_mkv.c, it's quite obvious that it's not based on any pre-existing demux_mkv.c code (or ebml.c/.h for that matter). Anyone else who has touched this code every since has already agreed to LGPL relicensing.
* charset_conv: simplify and change --sub-codepage optionwm42016-12-092-45/+49
| | | | | | | As documented in interface-changes.rst. This makes it much easier to follow what the heck is going on. Whether this is adequate for real-world use is unknown.
* charset_conv: drop enca and libguess supportwm42016-12-091-67/+0
| | | | | | | | Enca is dead. libguess is relatively useless due to not having an universal detection mode. On the other hand, libuchardet is actively developed. Manpages changes in the following commit.
* player: don't enter playloop for client API requestswm42016-09-161-0/+4
| | | | | | | | | | | This _actually_ does what commit 8716c2e8 promised, and gives a slight performance improvement for client API users which make a lot of requests (like reading properties). The main issue was that mp_dispatch_lock() (which client.c uses to get exclusive access to the core) still called the wakeup callback, which made mp_dispatch_queue_process() exit. So the playloop got executed again, and since it does a lot of stuff, performance could be reduced.
* dispatch: fix a race condition triggering an assert()wm42016-09-161-1/+1
| | | | | | | | | | | If we were waiting, and then exiting due to timeout, we still have to recheck the condition protected by the condition variable/mutex in order to get back to a consistent state. In this case, the queue was locked with mp_dispatch_lock(), and mp_dispatch_queue_process() got to return without waiting for unlock. Also caused commit 8716c2e8. Probably an argument for replacing the dispatch queue by a simple mutex.
* player: use better way to wait for input and dispatching commandswm42016-09-162-7/+26
| | | | | | | | | | | | | | | | | | | Instead of using input_ctx for waiting, use the dispatch queue directly. One big change is that the dispatch queue will just process commands that come in (e.g. from client API) without returning. This should reduce unnecessary playloop excutions (which is good since the playloop got a bit fat from rechecking a lot of conditions every iteration). Since this doesn't force a new playloop iteration on every access, this has to be enforced manually in some cases. Normal input (via terminal or VO window) still wakes up the playloop every time, though that's not too important. It makes testing this harder, though. If there are missing wakeup calls, it will be noticed only when using the client API in some form. At this point we could probably use a normal lock instead of the dispatch queue stuff.
* osdep: rename atomics.h to atomic.hwm42016-09-071-1/+1
| | | | | The standard header is stdatomic.h, so the extra "s" freaks me out every time I look at it.
* dispatch: improve recent locking changes slightlywm42016-09-051-14/+20
| | | | | | | | | | | | | | Instead of adding a lock_frame to the list when mp_dispatch_lock() is called, just set a simple flag. This uses the fact that the lock is not recursive, and can happen once per mp_dispatch_queue_process(). It avoids the dynamic allocation, and makes error checking slightly stricter. Again, this is actually redundant and exists only for error-checking. It'd actually need only a counter, because the actual locking is done by "parking" the target thread in mp_dispatch_queue_process() and then setting queue->idling=false. Only when mp_dispatch_unlock() sets it to true again other work can proceed again. Document this too.
* dispatch: redo locking, and allow reentrant processingwm42016-09-041-70/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | A deadlock bug was reported with the following test program: mpv_handle *mpv = mpv_create(); mpv_set_option_string(mpv, "ytdl", "yes"); mpv_initialize(mpv); mpv_terminate_destroy(mpv); The cause of this is loading the ytdl.lua script, which triggers a certain code path that calls mp_dispatch_queue_process() recursively. It does so to wait until the script is loaded, and we want to keep that. Reentrancy was not supported by mp_dispatch, which leads to the deadlock. Rewrite the locking so that it does. We mainly get rid of the "exclusive_lock" mutex. Instead we use the existing lock/condition variable to wait until we can grab a logical lock. Note that the lock_frame business can be replaced with a simple counter. Instead of checking the lock_frame address, it'd simply increment and store the counter when entering mp_dispatch_queue_process(), and then compare the counter to decide whether or not to wait. But I think the additional error checking done by the lock_frame list is valuable. Fixes #3489.
* client API: implement mpv_suspend/resume slightly differentlywm42016-09-042-4/+2
| | | | | | | | Why do these API calls even still exist? I don't know, and maybe they don't make any sense anymore. But whether they should be removed or not is not a decision I want to make now. I want to get rid of mp_dispatch_suspend/resume(), though. So implement the client APIs slightly differently.
* charset_conv: Use CP949 instead of EUC-KRJeong Woon Choi2016-09-021-0/+5
| | | | | | | | | | iconv distinguishes between euc-kr and cp949, while libguess and libuchardet doesn't (only returns euc-kr). EILSEQ occurs when the input encoding of iconv is set to euc-kr and if the subs contain letters not included in euc-kr. Since cp949 is a extension of euc-kr, choose cp949 instead. Signed-off-by: wm4 <wm4@nowhere>
* misc: add some annoying mpv_node helperswm42016-08-282-0/+76
| | | | | | | Sigh. Some parts of mpv essentially duplicate this code (with varrying levels of triviality) - this can be fixed "later".
* Fix misspellingsstepshal2016-06-261-1/+1
|
* vo_opengl: use RPN expressions for user hook sizesNiklas Haas2016-05-152-8/+28
| | | | | | | | | This replaces the previous TRANSFORM by WIDTH, HEIGHT and OFFSET where WIDTH and HEIGHT are RPN expressions. This allows for more fine-grained control over the output size, and also makes sure that overwriting existing textures works more cleanly. (Also add some more useful bstr functions)
* bstr: avoid redundant vsnprintf callswm42016-03-231-3/+9
| | | | | | | | | | | | | | | | | Until now, bstr_xappend_vasprintf() called vsnprintf() always twice: once to determine how much output the call would produce, and a second time to actually output the data to the (possibly resized) target memory. Change this so that it tries to output to the already allocated memory first, and repeat the call only if allocation is required. This is especially helpful, as bstr_xappend_vasprintf() is designed to avoid reallocation when building strings. Usually, the second vsnprintf() will happen only at the beginning, when the buffer hasn't been extended to his largest needed size yet. Not sure if there is a need to optimize this; but see the next commit.
* dispatch: clarify lifetime issueswm42016-02-261-4/+9
|
* Relicense some non-MPlayer source files to LGPL 2.1 or laterwm42016-01-196-42/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* mpv_talloc.h: rename from talloc.hDmitrij D. Czarkoff2016-01-113-3/+3
| | | | This change helps avoiding conflict with talloc.h from libtalloc.
* charset_