summaryrefslogtreecommitdiffstats
path: root/osdep
Commit message (Collapse)AuthorAgeFilesLines
* 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 seem to depend on it, so we get a rat-tail of stuff we have to change. This is probably a good thing though, because we can have the path lookup functions also access options, so we could allow overriding the default config path, or ignore the MPV_HOME environment variable, and such things. Also take the chance to consistently add talloc_ctx parameters to the path lookup functions. Also, this change causes a big mess on configfiles.c. It's the same issue: everything suddenly needs a (different) context argument. Make it less wild by providing a mp_load_auto_profiles() function, which isolates most of it to configfiles.c.
* input: rework how input sources are addedwm42013-12-213-20/+48
| | | | | | | | | | | | | | Until now, there were two functions to add input sources (stuff like stdin input, slave mode, lirc, joystick). Unify them to a single function (mp_input_add_fd()), and make sure the associated callbacks always have a context parameter. Change the lirc and joystick code such that they take store their state in a context struct (probably worthless), and use the new mp_msg replacements (the point of this refactoring). Additionally, get rid of the ugly USE_FD0_CMD_SELECT etc. ifdeffery in the terminal handling code.
* osdep/priority: drop message output when setting prioritywm42013-12-211-2/+0
|
* terminal: abstract terminal color handlingwm42013-12-203-9/+75
| | | | | | | | Instead of making msg.c an ifdef hell for unix vs. windows code, move the code to separate functions defined in terminal-unix.c/terminal- win.c. Drop the code that selects random colors for --msgmodule prefixes.
* terminal: move SIGTTOU signal handler setup codewm42013-12-191-0/+2
| | | | | | This comes with a real change in behavior: now the signal handler is set only when the terminal input code is active (e.g. not with --no-consolecontrols), but this should be ok.
* Rename getch2....c/h to terminal....c/hwm42013-12-193-2/+2
| | | | | "getch2" really tells nothing about what the heck this code does. It'd be even worse when moving the rest of terminal handling code there.
* Reduce recursive config.h inclusions in headerswm42013-12-182-3/+0
| | | | | | In my opinion, config.h inclusions should be kept to a minimum. MPlayer code really liked including config.h everywhere, though, even in often used header files. Try to reduce this.
* stream: move O_BINARY dummy definitionwm42013-12-181-0/+4
|
* Fix OSX build; remove all remaining mpvcore references11rcombs2013-12-173-5/+5
|
* Split mpvcore/ into common/, misc/, bstr/wm42013-12-173-4/+4
|
* Merge mp_talloc.h into ta/ta_talloc.hwm42013-12-171-4/+2
|
* Move options/config related files from mpvcore/ to options/wm42013-12-171-1/+1
| | | | | | | | | Since m_option.h and options.h are extremely often included, a lot of files have to be changed. Moving path.c/h to options/ is a bit questionable, but since this is mainly about access to config files (which are also handled in options/), it's probably ok.
* Move mpvcore/input/ to input/wm42013-12-173-5/+5
|
* Replace mp_tmsg, mp_dbg -> mp_msg, remove mp_gtext(), remove set_osd_tmsgwm42013-12-161-1/+1
| | | | | | | | | The tmsg stuff was for the internal gettext() based translation system, which nobody ever attempted to use and thus was removed. mp_gtext() and set_osd_tmsg() were also for this. mp_dbg was once enabled in debug mode only, but since we have log level for enabling debug messages, it seems utterly useless.
* macosx_events: fix null dereference on uninitStefano Pigozzi2013-12-071-1/+4
| | | | | | | Bug introduced by commit 6fb020f5. It doesn't always happen, since it is caused by the playloop and cocoa UI code running in separate threads. Fixes #398.
* options: add option to disable using right Alt key as Alt GrVivek Jain2013-12-021-2/+8
| | | | | | | | | mpv was hardcoded to always consider the right Alt key as Alt Gr, but there are parituclar combinations of platforms and keyboard layouts where it's more convenient to treat the right Alt as a keyboard modifier just like the left one. Fixes #388
* osdep/io: also include unistd.hwm42013-11-301-0/+2
| | | | Might be needed by fcntl() usage.
* Use O_CLOEXEC when creating FDswm42013-11-302-1/+28
| | | | | | | | | | | | | | This is needed so that new processes (created with fork+exec) don't inherit open files, which can be important for a number of reasons. Since O_CLOEXEC is relatively new (POSIX.1-2008, before that Linux specific), we #define it to 0 in io.h to prevent compilation errors on older/crappy systems. At least this is the plan. input.c creates a pipe. For that, add a mp_set_cloexec() function (which is based on Weston's code in vo_wayland.c, but more correct). We could use pipe2() instead, but that is Linux specific. Technically, we have a race condition, but it won't matter.
* build: make pthreads mandatorywm42013-11-281-7/+0
| | | | | | | | | | | pthreads should be available anywhere. Even if not, for environment without threads a pthread wrapper could be provided that can't actually start threads, thus disabling features that require threads. Make pthreads mandatory in order to simplify build dependencies and to reduce ifdeffery. (Admittedly, there wasn't much complexity, but maybe we will use pthreads more in the future, and then it'd become a real bother.)
* switch the build system to wafStefano Pigozzi2013-11-211-1/+0
| | | | | | | | | | | | | | | | | | | | | | | This commit adds a new build system based on waf. configure and Makefile are deprecated effective immediately and someday in the future they will be removed (they are still available by running ./old-configure). You can find how the choice for waf came to be in `DOCS/waf-buildsystem.rst`. TL;DR: we couldn't get the same level of abstraction and customization with other build systems we tried (CMake and autotools). For guidance on how to build the software now, take a look at README.md and the cross compilation guide. CREDITS: This is a squash of ~250 commits. Some of them are not by me, so here is the deserved attribution: - @wm4 contributed some Windows fixes, renamed configure to old-configure and contributed to the bootstrap script. Also, GNU/Linux testing. - @lachs0r contributed some Windows fixes and the bootstrap script. - @Nikoli contributed a lot of testing and discovered many bugs. - @CrimsonVoid contributed changes to the bootstrap script.
* osdep/io.c: include config.hwm42013-11-201-0/+2
| | | | | This possibly enables code that has never been tested before (accidentally), so let's hope this works out ok.
* stream: split out pthread helper functionwm42013-11-172-0/+66
| | | | Also split the function itself into 3.
* osdep: handle SIGTERMwm42013-11-061-0/+2
| | | | | | There's no reason why we should e.g. handle SIGQUIT, but not SIGTERM. Note that sending SIGTERM twice still kills the player.
* osx: fix -Wshadow warnings on platform specific codeStefano Pigozzi2013-11-041-4/+4
|
* configure: uniform the defines to #define HAVE_xxx (0|1)Stefano Pigozzi2013-11-033-16/+17
| | | | | | | | | | | | | | | | | | | | | The configure followed 5 different convetions of defines because the next guy always wanted to introduce a new better way to uniform it[1]. For an hypothetic feature 'hurr' you could have had: * #define HAVE_HURR 1 / #undef HAVE_DURR * #define HAVE_HURR / #undef HAVE_DURR * #define CONFIG_HURR 1 / #undef CONFIG_DURR * #define HAVE_HURR 1 / #define HAVE_DURR 0 * #define CONFIG_HURR 1 / #define CONFIG_DURR 0 All is now uniform and uses: * #define HAVE_HURR 1 * #define HAVE_DURR 0 We like definining to 0 as opposed to `undef` bcause it can help spot typos and is very helpful when doing big reorganizations in the code. [1]: http://xkcd.com/927/ related
* getch2: assume EOF when input file descriptor is invalidwm42013-10-281-2/+5
| | | | | | | | | | | | | When starting mpv with nohup, file descriptor 0 seems to be invalid for some reason. (I'm not quite sure why it should be... /proc/pid/fd/0 seems to indicate it's just /dev/null, and using /dev/null explicitly shows that it works just fine.) select() will always immediately return, and this causes mpv to burn CPU without reason. Fix this by treating it as EOF when read() returns EBADF. Also add EINVAL to this condition, because it seems like a good idea.
* getch2: move global state to file scope variableswm42013-10-281-6/+5
| | | | | Using static variables for mutable state inside functions is a bad idea, because it's not immediately obvious that it is what it is.
* cocoa: fix opening quarantined files on 10.9 with the bundle [2]Stefano Pigozzi2013-10-251-2/+2
| | | | Fixup commit for bbc146927
* cocoa: fix opening quarantined files on 10.9 with the bundleStefano Pigozzi2013-10-241-2/+7
| | | | | | | It looks like on Mavericks the Finder is passing different arguments to mpv depending on whether the opened file is quarantined or not. Fixes #285
* cocoa: fix race condition with input context creationStefano Pigozzi2013-10-242-0/+14
| | | | | | | | | | This seems to be a problem only in OS X 10.9. I guess they improved the general speed of the Cocoa startup and suddenly mpv core takes more time than the Cocoa thread to initialize. Fixes #285 (hopefully!)
* getch2: remove pointless ifdefferywm42013-10-171-8/+0
| | | | | Apparently this was for MorphOS. If you really want to use that, ask the devs to provide dummy headers and declarations for ioctl() instead.
* Copyright, LICENSE: switch to GPL version 2 or laterwm42013-10-131-1/+1
| | | | | | | | | | | | | | | Now that talloc has been removed, the license can be switched back to GPLv2+. Actually, there never was a GPLv2+ licensed MPlayer (fork or not) until now, but removal of some GPLv2-only code makes this possible now. Rewrite the Copyright file to explain the reasons for the licenses MPlayer and forks use. The old Copyright file didn't contain anything interesting anymore, and all information it contained is available at other places in the source tree. The reason for the license change itself is that it should improve interoperability with differently licensed code in general. This essentially reverts commit 1752808.
* osx: fix buildwm42013-09-271-2/+2
| | | | | | Or at least I hope it fixes it, since I can't test. Broken by commit 0d90dd0.
* win32: edit resource files, in particular set CompanyNamewm42013-09-232-5/+5
|