Commit Graph

27 Commits

Author SHA1 Message Date
wm4 8a9b64329c Relicense some non-MPlayer source files to LGPL 2.1 or later
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.
2016-01-19 18:36:06 +01:00
wm4 41101c2996 win32: revert wchar_t changes
Revert "win32: more wchar_t -> WCHAR replacements"
Revert "win32: replace wchar_t with WCHAR"

Doing a "partial" port of this makes no sense anymore from my
perspective. Revert the changes, as they're confusing without
context, maintenance, and progress. These changes were a bit
premature anyway, and might actually cause other issues
(locale neutrality etc. as it was pointed out).
2015-08-01 21:09:11 +02:00
wm4 0b52ac8a78 win32: replace wchar_t with WCHAR
WCHAR is more portable. While at least MinGW, Cygwin, and MSVC actually
use 16 bit wchar_t, Midipix will have 32 bit wchar_t. In that context,
using WCHAR instead is more portable.

This affects only non-MinGW parts, so not all uses of wchar_t need to
be changed. For example, terminal-win.c won't be used on Midipix at
all. (Most of io.c won't either, so the search & replace here is more
than necessary, but also not harmful.)

(Midipix is not useable yet, so this is just preparation.)
2015-07-29 00:01:32 +02:00
Marcin Kurczewski f43017bfe9 Update license headers
Signed-off-by: wm4 <wm4@nowhere>
2015-04-13 12:10:01 +02:00
James Ross-Gowan ac7ecbe30c win32: use a platform-specific unicode entry-point
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.
2015-04-11 14:27:25 +10:00
wm4 3fdb6be316 win32: add mmap() emulation
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.
2014-12-26 17:30:10 +01:00
wm4 6f88bc7761 osdep: add helper for creating a sane pipe()
Or in other words, a pipe that has the CLOEXEC flag set. Needed since
Linux' pipe2() is not in POSIX yet.
2014-10-26 01:40:36 +02:00
wm4 76af31b0eb win32: remove an unneeded mechanism
Instead of relying on the macro-defined lseek(), just use _lseeki64
directly, and avoid a minor mess.
2014-10-19 05:51:25 +02:00
wm4 2458f0628e win32: remove outdated comment 2014-10-19 05:51:24 +02:00
wm4 201a656350 win32: get rid of mp_stat in the normal source code
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.)
2014-10-17 22:15:19 +02:00
wm4 a7eb363ac1 win32: make lseek() fail on pipes
On MingGW seeking on pipes succeeds.

This fix is quite similar to Gnulib's (lib/lseek.c).
2014-10-17 21:43:18 +02:00
James Ross-Gowan 5c3f3fd3da win32: add tmpfile() replacement
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.
2014-09-05 17:51:44 +02:00
wm4 ec18df8466 input: separate wakeup pipe creation into a separate function
Error handling is slightly reduced: we assume that setting a pipe
to non-blocking can never fail.
2014-05-30 02:16:20 +02:00
James Ross-Gowan 0cef033d48 glob-win: support Unicode
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.
2014-04-21 02:57:16 +02:00
wm4 4e5cea86c2 client API: add mpv_get_wakeup_pipe convenience function
Should make integreating with some event loops easier. Untested.
2014-04-12 20:13:07 +02:00
wm4 8edf2cda4b io: make MP_PATH_MAX private to win32 code
The win32 code is the only thing which actually needs this (and it's
used to make emulation of UTF-8 filename APIs easier).
2014-02-03 22:12:30 +01:00
Martin Herkt 26d6eb4a8a io/win32: move mp_attach_console to terminal-win.c
Why didn't I put it there from the start?
2014-01-16 11:25:52 +01:00
Martin Herkt e9f577eb9a Windows: use the GUI subsystem, attach to console
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.
2014-01-02 05:30:49 +01:00
wm4 5e0424f17f stream: move O_BINARY dummy definition 2013-12-18 17:12:16 +01:00
wm4 95cfe58e3d Use O_CLOEXEC when creating FDs
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.
2013-11-30 22:40:51 +01:00
wm4 1cb55cebf9 path, win32: redo user configfile path handling
Remove the ifdef hell from mp_find_user_config_file(). Move the win32
specific code (for MinGW and Cygwin) to path-win.c. The behavior should
be about the same, but I can't be sure due to lack of testing and
because the old path.c code was hard to follow. (I expect those who care
about windows will fix things, should issues pop up - sorry.)

One difference is that the new code will always force MPV_HOME. It looks
like the old code preferred the mpv config dir in the exe dir if it
exists.

Also, make sure MP_PATH_MAX has enough space, even if the equivalent
wchar_t string is not 0-terminated with PATH_MAX (because apparently the
winapi doesn't require this). (Actually, maybe we should just kill all
uses of PATH_MAX/MP_PATH_MAX.)
2013-09-18 19:08:51 +02:00
wm4 12372298a2 win32: add getenv() UTF-8 variant
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.)
2013-09-18 19:08:51 +02:00
wm4 cbdee50f29 windows support: fix _wstat misusage
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.
2013-01-13 17:32:39 +01:00
Kovensky bc63957551 windows support: include io.h when building on Cygwin 2012-09-30 15:16:53 +02:00
wm4 a659429f86 win32: use more unicode functions
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().
2012-04-06 23:56:30 +02:00
Martin Herkt f891939b4d windows: terminal: unicode, --msgcolor, size change
Make mp_msg() support unicode output, --msgcolor and variable screen
sizes.

Patch reintegrated by wm4.
2012-03-09 20:48:54 +02:00
wm4 a1244111a7 windows support: unicode filenames
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.
2012-03-09 20:48:54 +02:00