Commit Graph

358 Commits

Author SHA1 Message Date
Stefano Pigozzi b454cc0ca3 macosx_events: fix null dereference on uninit
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.
2013-12-07 15:29:53 +01:00
Vivek Jain 6fb020f5de options: add option to disable using right Alt key as Alt Gr
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
2013-12-02 09:03:31 +01:00
wm4 fafa2f4b85 osdep/io: also include unistd.h
Might be needed by fcntl() usage.
2013-11-30 23:17:20 +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 0d255f07bf build: make pthreads mandatory
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.)
2013-11-28 19:28:38 +01:00
Stefano Pigozzi 7e2edad8ef switch the build system to waf
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.
2013-11-21 21:22:36 +01:00
wm4 31fc48f0a8 osdep/io.c: include config.h
This possibly enables code that has never been tested before
(accidentally), so let's hope this works out ok.
2013-11-20 18:12:58 +01:00
wm4 b78d11d328 stream: split out pthread helper function
Also split the function itself into 3.
2013-11-17 16:42:57 +01:00
wm4 d445147be9 osdep: handle SIGTERM
There's no reason why we should e.g. handle SIGQUIT, but not SIGTERM.

Note that sending SIGTERM twice still kills the player.
2013-11-06 20:29:16 +01:00
Stefano Pigozzi 78a9bc4a7d osx: fix -Wshadow warnings on platform specific code 2013-11-04 08:33:35 +01:00
Stefano Pigozzi 37388ebb0e configure: uniform the defines to #define HAVE_xxx (0|1)
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
2013-11-03 21:59:54 +01:00
wm4 dceccaf169 getch2: assume EOF when input file descriptor is invalid
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.
2013-10-28 23:32:57 +01:00
wm4 e10b362bdb getch2: move global state to file scope variables
Using static variables for mutable state inside functions is a bad idea,
because it's not immediately obvious that it is what it is.
2013-10-28 23:29:08 +01:00
Stefano Pigozzi 96432241bd cocoa: fix opening quarantined files on 10.9 with the bundle [2]
Fixup commit for bbc146927
2013-10-25 09:10:50 +02:00
Stefano Pigozzi bbc1469272 cocoa: fix opening quarantined files on 10.9 with the bundle
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
2013-10-24 21:37:55 +02:00
Stefano Pigozzi c54a1f3e41 cocoa: fix race condition with input context creation
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!)
2013-10-24 00:07:05 +02:00
wm4 4a4d2155d8 getch2: remove pointless ifdeffery
Apparently this was for MorphOS. If you really want to use that, ask
the devs to provide dummy headers and declarations for ioctl() instead.
2013-10-17 23:16:18 +02:00
wm4 a550731209 Copyright, LICENSE: switch to GPL version 2 or later
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.
2013-10-13 01:36:10 +02:00
wm4 1b3fbfc183 osx: fix build
Or at least I hope it fixes it, since I can't test.

Broken by commit 0d90dd0.
2013-09-27 19:21:30 +02:00
wm4 ee57f7fdae win32: edit resource files, in particular set CompanyName
Setting CompanyName (probably) helps with issue #256.

Update some other fields as well, because why not. (They're full of
MPlayer remnants.)
2013-09-23 01:44:09 +02:00
Stefano Pigozzi 061b6ab3aa macosx_application: fix regression causing crash
95a2151d1 introduced a crash on systems lower than 10.9 when opening files
with a single argument.
2013-09-19 22:03:49 +02:00
wm4 1298dbdf01 osdep/path: remove ifdefs
They're not really needed, so kill them.
2013-09-18 19:42:19 +02:00
Stefano Pigozzi af018f7e4f macosx: move bundle path stuff to path-macosx.m
This makes the code uniform to how stuff was handled for Windows in 1cb55ceb.
2013-09-18 19:30:11 +02: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
Stefano Pigozzi fc74574df0 HIDRemote: remove OS X version checks
Turns out that these checks were for versions of OS X that mpv doesn't even
support anymore. So just remove the checks since they cause a deprecation
warning.
2013-09-17 20:44:54 +02:00
Nyx0uf 95a2151d19 macosx_application: remove deprecation warning on OS X 10.9
GetCurrentProcess() is deprecated on 10.9. Make a universal solution by
checking OS version number.

get_system_version() function is the recommended Apple way of getting the
OS version, since Gestalt is also deprecated (and does pretty much the same
thing anyway)

Updating HIDRemote.m to use a similar function would allow to get rid of the
2 other warnings.
2013-09-16 21:51:08 +02:00
Stefano Pigozzi ddd3ade023 macosx_application: fix file opening on 10.9 (for real this time)
I did commit 86c05655d by thinking `mpv` already removed the `mpv` from
argc/argv. It actually is still there, so the argc must be 1 to check for no
arguments.

Thanks to @Nyx0uf for pointing out the bug and for testing on 10.9!
2013-09-13 19:55:15 +02:00
Stefano Pigozzi 86c05655d4 macosx_application: fix file opening on OS X 10.9 (hopefully)
File opening through Finder, apparently drops `--psn` arguments on Mavericks
and just uses no args. Modify the code to account for that case.

This wasn't tested on 10.9 itself (I don't have a paid dev account), but it
*should* work if I understood the problem correctly.
2013-09-12 18:42:59 +02:00
Stefano Pigozzi 494d408583 macosx_application: handle mpv:// links
Pretty useful for people writing userscripts for web browsers. Links starting
with 'mpv://' are forwarded to the mpv OSX bundle. The leading 'mpv://' is
stripped from the recived url and the rest of the string is inserted as is in
the playlist.
2013-09-07 15:37:02 +02:00
Stefano Pigozzi b0797e8fe9 macosx_application: handle URL events as fileopen events
This allows to open URLs directly with mpv. This is useful for streaming and
libquvi supported sites.
2013-09-07 12:10:29 +02:00
Stefano Pigozzi 00a08af9f6 macosx_events: fix modifiers handling with media keys
This was caused by a typo. Regression from add7c2955d.

Fixes #213
2013-09-05 07:38:37 +02:00
Stefano Pigozzi d57e1aa599 macosx_events: send a `release all` after key up events
This prevents keys to become stuck due to changing keyboard modifiers during
the key down. Not the prettiest approach but event `x11_common` does it like
this.

Fixes #210
2013-09-02 21:13:56 +02:00
Stefano Pigozzi add7c2955d macosx_events: remove duplication
refactoring: extract method `handleMPKey:withMask:`
2013-09-02 21:11:05 +02:00
Stefano Pigozzi 04caddb7c8 cocoa: enqueue events only if input context is present 2013-09-01 23:51:36 +02:00
Stefano Pigozzi 134c3e148c osx: use MP_KEY_* instead of MK_* for media keys
In 213ad5d6c I added `MK_*` key bindings overlooking the fact that mpv already
has `MP_KEY_*` for media keys.
2013-09-01 20:57:40 +02:00
Stefano Pigozzi 462e6f281a cocoa: let the core handle key repeats
Report key down and key up modifiers to the core so that it can issue it's
own key repeats (instead of relying on Cocoa's ones).
2013-08-30 19:49:30 +02:00
Stefano Pigozzi 11dad6d44b macosx: remove platform specific input queue
Since last commit the input queue in the core is thread safe, so there is no
need for all this platform specific stuff anymore.
2013-08-13 23:02:43 +02:00
Stefano Pigozzi 406241005e core: move contents to mpvcore (2/2)
Followup commit. Fixes all the files references.
2013-08-06 22:52:31 +02:00
James Ross-Gowan 103fbf043f mpv.rc: update Windows icon
Based on the OSX bundle icon.
2013-07-30 16:15:37 +02:00
Diogo Franco (Kovensky) fac2d9097e getch2: Load the "ce", "ks" and "ke" caps into a static buffer
Fixes reports of printing of garbage (or anything else) other than clearing
the status line to the end of line: the buffer returned by termcap_get
could get moved, and if that happened then these 3 caps pointed to garbage.
2013-07-26 16:03:56 -03:00
Diogo Franco (Kovensky) 630edc0637 getch2: Deactivate getch2 on SIGINT; also handle SIGQUIT 2013-07-26 15:51:48 -03:00
Diogo Franco (Kovensky) 15742504d0 getch2: Only send ESC if it was typed twice
Avoids quitting mpv if any unknown escape is entered.
2013-07-26 11:30:10 -03:00
Diogo Franco (Kovensky) 3928b39988 getch2: Handle setupterm errors
setupterm abort()s if it can't initialize the terminal and the last
parameter is NULL; handle setupterm errors and retry with "ansi" if
the TERM env var was unset.
2013-07-26 11:29:34 -03:00
wm4 ca039d42bb getch2: fix compilation 2013-07-26 02:13:35 +02:00
Diogo Franco (Kovensky) fb67770ed6 getch2: Support ESC keypresses again
Due to the termcap matching and the hardcoded fallbacks, the ESC keypress
has to be followed by another non-matching keypress (such as another ESC)
for it to be accepted. We drop the second ESC in case it was typed twice.
2013-07-25 21:10:06 -03:00
Diogo Franco (Kovensky) 0cfc382355 getch2: Doing it right this time
getch2_pos should be set to 1, not 0, when backtracking. Avoids the
possible infinite loop but correctly.
2013-07-25 13:29:10 -03:00
Diogo Franco (Kovensky) c36a5e0f36 Revert "getch2: Avoid possible infinite loop"
This reverts commit ba95aed6f1.
2013-07-25 13:26:19 -03:00
Diogo Franco (Kovensky) ba95aed6f1 getch2: Avoid possible infinite loop
If the first character is not a valid UTF-8 start code nor is in termcap,
getch2 would enter an infinite loop. Always walk 1 byte in the UTF-8 case
unless it's a valid start code.
2013-07-25 13:24:22 -03:00
Diogo Franco (Kovensky) 5586b02931 getch2, mplayer: Always call load_termcap
getch2 now deals with the cases where we don't have termcap. Add a dummy
load_termcap to getch2-win so we don't get linking errors on mingw.
2013-07-25 12:23:40 -03:00