summaryrefslogtreecommitdiffstats
path: root/osdep/io.c
Commit message (Collapse)AuthorAgeFilesLines
* Update license headersMarcin Kurczewski2015-04-131-4/+6
| | | | Signed-off-by: wm4 <wm4@nowhere>
* win32: use a platform-specific unicode entry-pointJames Ross-Gowan2015-04-111-26/+0
| | | | | | | | | | Add a platform-specific entry-point for Windows. This will allow some platform-specific initialization to be added without the need for ugly ifdeffery in main.c. As an immediate advantage, mpv can now use a unicode entry-point and convert the command line arguments to UTF-8 before passing them to mpv_main, so osdep_preinit can be simplified a little bit.
* win32: add mmap() emulationwm42014-12-261-0/+59
| | | | | | | | Makes all of overlay_add work on windows/mingw. Since we now don't explicitly check for mmap() anymore (it's always present), this also requires us to make af_export.c compile, but I haven't tested it.
* win32: silence some warningsJames Ross-Gowan2014-11-081-1/+1
| | | | Signed-off-by: wm4 <wm4@nowhere>
* osdep: add helper for creating a sane pipe()wm42014-10-261-4/+20
| | | | | Or in other words, a pipe that has the CLOEXEC flag set. Needed since Linux' pipe2() is not in POSIX yet.
* win32: remove an unneeded mechanismwm42014-10-191-3/+1
| | | | | Instead of relying on the macro-defined lseek(), just use _lseeki64 directly, and avoid a minor mess.
* win32: get rid of mp_stat in the normal source codewm42014-10-171-2/+27
| | | | | | | | | | | 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.)
* win32: make lseek() fail on pipeswm42014-10-171-0/+11
| | | | | | On MingGW seeking on pipes succeeds. This fix is quite similar to Gnulib's (lib/lseek.c).
* win32: add tmpfile() replacementJames Ross-Gowan2014-09-051-0/+35
| | | | | | | | | | | The Windows version of tmpfile is actually pretty broken. It tries to create the file in the root directory of the current drive, which means on Vista and up, it normally fails due to insufficient permissions. Replace it with a version that uses GetTempPath. Also remove the Windows-specific note about automatic deletion of the cache file. FILE_FLAG_DELETE_ON_CLOSE is available in NT, and it should be pretty reliable.
* win32: correct HANDLE typeJames Ross-Gowan2014-08-241-2/+2
| | | | | The correct type is HANDLE, not HANDLE*, though this change shouldn't affect functionality.
* win32: emulate some ANSI terminal escape codeswm42014-08-211-6/+4
| | | | | | | | | | | | | | We already redirect all terminal output through our own wrappers (for the sake of UTF-8), so we might as well use it to handle ANSI escape codes. This also changes behavior on UNIX: we don't retrieve some escape codes per terminfo anymore, and just hardcode them. Every terminal should understand them. The advantage is that we can pretend to have a real terminal in the normal player code, and Windows atrocities are locked away in glue code.
* 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.
* input: separate wakeup pipe creation into a separate functionwm42014-05-301-0/+25
| | | | | Error handling is slightly reduced: we assume that setting a pipe to non-blocking can never fail.
* osdep: silence a -Wshadow warningwm42014-05-211-2/+2
|
* client API: add mpv_get_wakeup_pipe convenience functionwm42014-04-121-1/+1
| | | | Should make integreating with some event loops easier. Untested.
* io: make MP_PATH_MAX private to win32 codewm42014-02-031-0/+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).
* io/win32: move mp_attach_console to terminal-win.cMartin Herkt2014-01-161-22/+0
| | | | Why didn't I put it there from the start?
* Windows: use the GUI subsystem, attach to consoleMartin Herkt2014-01-021-0/+22
| | | | | | | | 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
|
* Merge mp_talloc.h into ta/ta_talloc.hwm42013-12-171-4/+2
|
* osdep/io: also include unistd.hwm42013-11-301-0/+2
| | | | Might be needed by fcntl() usage.
* Use O_CLOEXEC when creating FDswm42013-11-301-1/+17
| | | | | | | | | | | | | | 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.)
* 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.
* configure: uniform the defines to #define HAVE_xxx (0|1)Stefano Pigozzi2013-11-031-2/+2
| | | | | | | | | | | | | | | | | | | | | 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
* win32: add getenv() UTF-8 variantwm42013-09-181-0/+60
| | | | | | | This is a bit "hard", because getenv() returns a static string, and we can't just return an allocated string. We also want getenv() to be thread-safe if possible. (If the mpv core is going to be more threaded, we sure do want the lower layers to be thread-safe as well.)
* windows support: fix _wstat misusagewm42013-01-131-1/+1
| | | | | | | I have no idea when or how this broke, but _wstati64() is the function we want anyway (64 bit filesize). Possibly this was a mingw-w64 bug. It's unknown why "wstat()" just doesn't work in this case, as it's not defined by MSDN and could be defined by mingw as it needs.
* win32: use more unicode functionswm42012-04-061-5/+20
| | | | | | | | Use the *W variants instead of the implicit *A functions. (One could define the UNICODE macro to switch the functions without suffix from A to W, but I'm too lazy to figure out how portable that is, etc.) Also make sure io.h defines a unicode aware printf().
* windows: terminal: unicode, --msgcolor, size changeMartin Herkt2012-03-091-0/+58
| | | | | | | Make mp_msg() support unicode output, --msgcolor and variable screen sizes. Patch reintegrated by wm4.
* windows support: unicode filenameswm42012-03-091-0/+185
Windows uses a legacy codepage for char* / runtime functions accepting char *. Using UTF-8 as the codepage with setlocale() is explicitly forbidden. Work this around by overriding the MSVCRT functions with wrapper macros, that assume UTF-8 and use "proper" API calls like _wopen etc. to deal with unicode filenames. All code that uses standard functions that take or return filenames must now include osdep/io.h. stat() can't be overridden, because MinGW-w64 itself defines "stat" as a macro. Change code to use use mp_stat() instead. This is not perfectly clean, but still somewhat sane, and much better than littering the rest of the mplayer code with MinGW specific hacks. It's also a bit fragile, but that's actually little different from the previous situation. Also, MinGW is unlikely to ever include a nice way of dealing with this.