summaryrefslogtreecommitdiffstats
path: root/osdep
Commit message (Collapse)AuthorAgeFilesLines
* cocoa: move handleFilesArray: to macosx_eventsFRAU KOUJIRO2014-08-064-17/+18
|
* cocoa: move set_input_context to macosx_eventsFRAU KOUJIRO2014-08-064-9/+9
|
* cocoa: sync inputContext inside EventsResponderFRAU KOUJIRO2014-08-063-12/+28
|
* cocoa: decouple events from application somewhatFRAU KOUJIRO2014-08-064-64/+118
|
* Remove the last remains of slave modewm42014-08-013-32/+2
| | | | | | | | | | | Almost nothing was left of it. The only thing this commit actually removes is support for reading input commands from stdin. But you can emulate this via: --input-file=/dev/stdin --input-terminal=no However, this won't work on Windows. Just use a named pipe.
* cocoa: fix key equivalent dispatchingStefano Pigozzi2014-07-302-22/+7
| | | | | | | | | | Prior to this commit we had a list of key modifiers and checked against that. Actually, the Cocoa framework has a built in way to do it and it involves calling performKeyEquivalent: on the menu instance. Fixes #946 cc @mpv-player/stable: this should apply with no conflicts
* osdep: don't assume errno is positivewm42014-07-251-2/+2
| | | | | Apparently this is not necessarily the case, so just drop the silly idea that depended on this assumption.
* cocoa: fix compilation on OS X 10.8Stefano Pigozzi2014-07-142-4/+30
|
* build: deal with endian messwm42014-07-101-0/+31
| | | | | | | | | | | | | | | | | | | | There is no standard mechanism for detecting endianess. Doing it at compile time in a portable way is probably hard. Doing it properly with a configure check is probably hard too. Using the endian definitions in <sys/types.h> (usually includes <endian.h>, which is not available everywhere) works under circumstances, but the previous commit broke it on OSX. Ideally all code should be endian dependent, but that is not possible due to the dependencies (such as FFmpeg, some video output APIs, some audio output APIs). Create a header osdep/endian.h, which contains various fallbacks. Note that the last fallback uses libavutil; however, it's not clear whether AV_HAVE_BIGENDIAN is a public symbol, or whether including <libavutil/bswap.h> really makes it visible. And in fact we don't want to pollute the namespace with libavutil definitions either. Thus it's only the last fallback.
* config: use the same signature for win32/OSX specific path functionswm42014-06-263-8/+12
| | | | | | | | Seems like a good idea, even if it's basically unused (yet). Also document requirements on the functions (they're not obvious). OSX changes untested.
* config: make passing talloc context optional for some functionswm42014-06-262-14/+7
| | | | | | | | | | | | | | | | Until now, the config functions added various allocations to the user- provided talloc context. Make it so that they're all under the returned allocation instead. This allows avoiding having to create an extra temporary context for some callers, and also avoids adding random memory leaks by accidentally passing a NULL context. mp_find_all_config_files() has to be changed not to return a pointer into the middle array for this to work. Make it add paths in order (instead of reverse), and then reverse the array entries after that. Also remove the declarations for the win-specific private functions. Remove STRNULL(); it's barely needed anymore and the functions are not called with NULL filenames anymore.
* Basic xdg directory implementationKenneth Zhou2014-06-263-40/+39
| | | | | | | | | | 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>
* win32: implement --priority differentlywm42014-06-122-94/+0
| | | | | | | 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).
* input: separate wakeup pipe creation into a separate functionwm42014-05-302-0/+26
| | | | | Error handling is slightly reduced: we assume that setting a pipe to non-blocking can never fail.
* timer: remove unneeded time_t overflow checkwm42014-05-241-12/+1
| | | | | | | This is mostly covered by the OSX workaround, if the timeout is very high. It also means that with systems using 32 bit time_t, the time will overflow 2036 already, instead of 2037, but we don't consider this a problem.
* timer: workaround for crappy operating systemswm42014-05-231-0/+1
| | | | | | | | | | Some operating systems apparently can't deal with really long timeouts in pthread_cond_timedwait(). Passing a time about 300000 in the future makes the call return immediately. (tv_sec/time_t doesn't overflow in this situation.) Reduce the wait time to about 100 days, which seems to work fine. The list of affected OSes follows: OSX
* timer: fix previous commitwm42014-05-221-1/+1
| | | | | Sigh... of course the type of the (?:) exprsssion is double, so INT64_MAX was converted to double, which is a problem.
* timer: improve overflow checkswm42014-05-221-4/+5
| | | | | | | Probably more correct and better readable. Although the special-casing of 0x1p63 is weird in terms of readability (the value itself is INT64_MAX+1, so it's already outside of range, but INT64_MAX is not exactly representable with double precision).
* timer: fix (usually impossible) timespec.tv_sec overflowwm42014-05-221-1/+13
| | | | | | | This usually can't happen, because even if time_us (first input value) is INT64_MAX, the value added to tv_sec will be about 2^43, and tv_sec will be <2^31, far below a possible overflow in 64 bits. But should time_t be 32 bits (32 bit Linux/Windows?), an overflow could happen.
* osdep: silence a -Wshadow warningwm42014-05-211-2/+2
|
* timer: account for negative time valueswm42014-05-181-2/+6
| | | | | | | | It can easily happen that mp_time_us_to_timespec() gets a time in the past, and then the time difference will be negative. Regression introduced in commit f47a4fc3. Also fix an underflow check in mp_add_timeout().
* threads: use mpv time for mpthread_cond_timedwait wrapperwm42014-05-184-53/+87
| | | | | | Use the time as returned by mp_time_us() for mpthread_cond_timedwait(), instead of calculating the struct timespec value based on a timeout. This (probably) makes it easier to wait for a specific deadline.
* terminal: always use SA_RESTART with sigaction()wm42014-04-261-1/+1
| | | | | | | One problem is that for example stdio functions won't restart syscalls manually, and instead treat EINTR as an error. So passing SA_RESTART is the only sane thing to do, unless you have special requirements, which we don't.
* threads: fix function namewm42014-04-232-4/+4
| | | | Closer to the corresponding standard function pthread_cond_timedwait.
* dispatch: move into its own source filewm42014-04-232-249/+0
| | | | | | | This was part of osdep/threads.c out of laziness. But it doesn't contain anything OS dependent. Note that the rest of threads.c actually isn't all that OS dependent either (just some minor ifdeffery to work around the lack of clock_gettime() on OSX).
* glob-win: support UnicodeJames Ross-Gowan2014-04-213-103/+151
| | | | | | | | | | | | | | | | glob-win.c wasn't big, so it was easier to rewrite it. The new version supports Unicode, handles directories properly, sorts the output and puts all its allocations in the same talloc context to simplify the implementation of globfree. Notably, the old glob had error checking code, but didn't do anything with the errors since the error reporting code was commented out. The new glob doesn't copy this behaviour. It just treats errors as if there were no more matching files, which shouldn't matter for mpv, since it ignores glob errors too. To match the other Windows I/O helper functions, the definition is moved to osdep/io.h.
* Kill all tabswm42014-04-132-1865/+1865
| | | | | | | | | | | I hate tabs. This replaces all tabs in all source files with spaces. The only exception is old-makefile. The replacement was made by running the GNU coreutils "expand" command on every file. Since the replacement was automatic, it's possible that some formatting was destroyed (but perhaps only if it was assuming that the end of a tab does not correspond to aligning the end to multiples of 8 spaces).
* client API: add mpv_get_wakeup_pipe convenience functionwm42014-04-122-1/+4
| | | | Should make integreating with some event loops easier. Untested.
* terminal-unix: reject overlong termcap stringswm42014-04-101-0/+3
| | | | | | | | Our own tables have size for only 8 chars, so these sequences must be rejected. It seems strings of length 8 are still ok, because the code uses memcmp and not strcmp, so still allow these. Based on mplayer-svn commit r37129.
* timer: reduce ifdef headsplitting-factorwm42014-03-091-3/+8
| | | | | I'd rather duplicate some trivial code, rather than split functions in the middle with ifdefs.
* timer: switch to CLOCK_MONOTONICwm42014-03-091-0/+10
| | | | | | | | | | | | | | | | | | | | | | | Apparently, this is always _really_ monotonic, despite what the Linux manpages say. So this should be much better than gettimeofday(). (At times there were kernel bugs which broke the monotonic property.) From the perspective of the player, time can still be discontinuous (you could just stop the process with ^Z), but at least it's guaranteed to be monotonic without further hacks required. Also note that clock_gettime() returns the time in nanoseconds. We want microseconds only, because that's the unit we chose internally. Another problem is that nanoseconds can wrap pretty quickly (less than 300 years in 63 bits), so it's just better to use microseconds. The devision won't make the code that much slower (compilers can avoid a real division). Note: this expects that the system provides clock_gettime() as well as CLOCK_MONOTONIC. Both are optional according to POSIX. The only system I know which doesn't have these, OSX, has seperate timer code anyway, but I still don't know whether more obscure (yet supported) platforms have a problem with this, so I'm playing safely. But this still expects that CLOCK_MONOTONIC always works at runtime if it's defined.
* timer: add utility function to get relative timewm42014-02-282-0/+17
|
* threads: fix wait time overflow checkwm42014-02-261-2/+2
| | | | | | | | | | | | | When passing a very large timeout to mpthread_cond_timed_wait(), the calculations could overflow, setting tv_sec to a negative value, and making the pthread_cond_timed_wait() call return immediately. This accidentally made Lua support poll and burn CPU for no reason. The existing overflow check was ineffective on 32 bit systems. tv_sec is usually a long, so adding INT_MAX to it will usually not overflow on 64 bit systems, but on 32 bit systems it's guaranteed to overflow. Simply fix by clamping against a relatively high value. This will work until 1 week before the UNIX time wraps around in 32 bits.
* win32: restore support for exe directory as config directoryelevengu2014-02-141-1/+5
| | | | | | | | Same rationale as b2c2fe7a but updated to work with path-win.c Signed-off-by: wm4 <wm4@nowhere> Merges/closes #543.
* cocoa: fix deadlock during initialization [2]Stefano Pigozzi2014-02-131-6/+3
| | | | Fixup commit for 20fa191ad.
* cocoa: fix deadlock during initializationStefano Pigozzi2014-02-131-1/+2
| | | | | | Thanks to @wm4 for catching the bug. Fixes #405
* timer: init only oncewm42014-02-102-3/+18
| | | | | | | | | | This avoids trouble if another mpv instance is initialized in the same process. Since timeBeginPeriod/timeEndPeriod are hereby not easily matched anymore, use an atexit() handler to call timeEndPeriod, so that we can be sure these calls are matched, even if we allow multiple initializations later when introducing the client API.
* threads: add a dispatch queue thingwm42014-02-102-0/+250
| | | | | | Makes working with the (still) single-threaded playback thread easier. Might be reusable for other stuff.
* threads: avoid timeout calculation overflowwm42014-02-101-0/+3
| | | | | | | | | It's quite possible to overflow the calculation by setting the timeout to high values. Limit it to INT_MAX, which should be safe. The issue is mainly the secs variable. timespec.tv_sec will normally be 64 bit on sane systems, and we assume it can't overflow by adding INT_MAX to it.
* io: make MP_PATH_MAX private to win32 codewm42014-02-032-12/+10
| | | | | The win32 code is the only thing which actually needs this (and it's used to make emulation of UTF-8 filename APIs easier).
* threads: add function to calculate deadline for timed waitswm42014-01-312-3/+14
| | | | | | | | | | | | Usually, you have to call pthread_cond_timedwait() in a loop (because it can wake up sporadically). If this function is used by another higher level function, which uses a relative timeout, we actually have to reduce the timeout on each iteration - or, simpler, compute the "deadline" at the beginning of the function, and always pass the same absolute time to the waiting function. Might be unsafe if the system time is changed. On the other hand, this is a fundamental race condition with these APIs.
* threads: add wrapper for initializing recursive mutexeswm42014-01-312-0/+13
| | | | Damn this overly verbose pthread API.
* cocoa: sort files opened from Finder the same way Finder doesBilal Syed Hussain2014-01-201-1/+2
| | | | Fixes #497
* w32: use the w32_common keymap in terminal-win tooJames Ross-Gowan2014-01-193-40/+130
|
* io/win32: move mp_attach_console to terminal-win.cMartin Herkt2014-01-163-23/+17
| | | | Why didn't I put it there from the start?
* cocoa: add application icon to the Dock when run from CLIStefano Pigozzi2014-01-141-0/+16
| | | | | | | | | | Application icon was added to the Dock only when run inside of a bundle. That was handled automatically by OS X using the Info.plist definition. To add the Application icon when run as a CLI program, I used the samme approach in the X11 code and loaded the icon as a static binary blob inside of mpv's binary. This is the simplest approach as it avoid headackes when relocating the binary and such.
* terminal-unix: fix terminfo/termcap name for cursor upwm42014-01-141-1/+1
| | | | | "ku" is for input, not output. This happened to work on urxvt, but broke on xterm (and probably a dozen of other terminals).
* terminal-unix: add fallback for enter keywm42014-01-131-0/+3
| | | | This worked just fine if terminfo or termcap was available.
* terminal-unix: fix fallbacks in case terminfo/termcap are disabledwm42014-01-131-2/+2
| | | | | These two escape sequences were swapped. (They are used only if terminfo/termcap are not available.)
* terminal-unix: add termcap/terminfo documentation linkswm42014-01-131-0/+4
| | | | | | | Apparently, some people are not clever enough to google this information. Proper googling to find these links done by Kovensky.
* player: redo terminal OSD and status line handlingwm42014-01-133-8/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The terminal OSD code includes the handling of the terminal status line, showing player OSD messages on the terminal, and showing subtitles on terminal (the latter two only if there is no video window, or if terminal OSD is forced). This didn't handle some corner cases correctly. For example, showing an OSD message on the terminal always cleared the previous line, even if the line was an important message (or even just the command prompt, if most other messages were silenced). Attempt to handle this correctly by keeping track of how many lines the terminal OSD currently consists of. Since there could be race conditions with other messages being printed, implement this in msg.c. Now msg.c expects that MSGL_STATUS messages rewrite the status line, so the caller is forced to use a single mp_msg() call to set the status line. Instead of littering print_status() all over the place, update the status only once per playloop iteration in update_osd_msg(). In audio- only mode, the status line might now be a little bit off, but it's perhaps ok. Print the status line only if it has changed, or if another message was printed. This might help with extremely slow terminals, although in audio+video mode, it'll still be updated very often (A-V sync display changes on every frame). Instead of hardcoding the terminal sequences, use terminfo/termcap to get the sequences. Remove the --term-osd-esc option, which allowed to override the hardcoded escapes - it's useless now. The fallback for terminals with no escape sequences for moving the cursor and clearing a line is removed. This somewhat breaks status line display on these terminals, including the MS Windows console: instead of querying the terminal size and clearing the line manually by padding the output with spaces, the line is simply not cleared. I don't expect this to be a problem on UNIX, and on MS Windows we could emulate escape sequences. Note that terminal OSD (other than the status line) was broken anyway on these terminals. In osd.c, the function get_term_width() is not used anymore, so remove it. To remind us that the MS Windows console apparently adds a line break when writint the last column, adjust screen_width in terminal- win.c accordingly.
* terminal: don't initialize termcap etc. if stdout is not a terminalwm42014-01-071-2/+6
| | | | | Otherwise, it seems one of the term* libraries will write escape sequences to stdout, for whatever reason.
* Windows: use roaming AppData instead of localMartin Herkt2014-01-061-1/+1
| | | | Whatever. Fixes #458.
* win32-console-wrapper: use child process exit codeMartin Herkt2014-01-061-4/+6
|
* win32-console-wrapper: remove command line manglingMartin Herkt2014-01-061-11/+2
| | | | This wasn't really necessary and caused a lot of problems.
* win32-console-wrapper: Fix heap corruptionMartin Herkt2014-01-061-1/+1
| | | | FUCK the Windows API.
* cocoa: handle files drag and drop on the player video viewStefano Pigozzi2014-01-041-0/+1
|
* cocoa: refactor files drag and drop on the Dock iconStefano Pigozzi2014-01-041-24/+16
| | | | | Use the newly added `mp_event_drop_files` core function instead of having logic in the platform dependent code.
* Add Windows console wrapper program (mpv.com)Martin Herkt2014-01-021-0/+83
|
* Windows: use the GUI subsystem, attach to consoleMartin Herkt2014-01-022-0/+23
| | | | | | | | This is necessary to start mpv without forcing a console window, but also breaks console usability. A workaround is to call mpv from a wrapper process that uses the console subsystem and helps redirecting the standard streams and WriteConsole output to where they belong.
* osdep/io, mp_vfprintf: split out console detectionMartin Herkt2014-01-021-42/+43
|
* Update copyright yearwm42014-01-011-1/+1
|
* path-macosx: attempt to fix buildwm42013-12-221-1/+1
| | | | Untested... no OSX here.
* macosx_application: replace mp_msg with stderr for semi-fatal errorwm42013-12-211-3/+4
| | | | Apparently this should never be run anyway.
* path lookup functions: mp_msg conversionswm42013-12-212-3/+7
| | | | | | | | | | | | | | | | | There's a single mp_msg() in path.c, but all path lookup functions s