Commit Graph

351 Commits

Author SHA1 Message Date
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
Diogo Franco (Kovensky) 19b1279bb3 getch2: Remove unused function, fix possible crash
If we still haven't read the full key from the input but it's regardless a
unique match in the database, we could receive a NULL keycode from
keys_search (it's not a full match after all) and proceed to use it.

Don't disable the keycode matching code if we don't have termcap as we can
still match against the hardcoded sequences.
2013-07-25 12:21:22 -03:00
Diogo Franco (Kovensky) 057467f6b3 getch2: Refactor/rewrite
Still uses termcap, but uses terminfo for loading the termcap database if
possible. Adds configure test to find terminfo; skips the termcap test
if terminfo is found since terminfo provides termcap.

Use termcap completely for special keys; if we can't get it from termcap
and it isn't one of the known fallbacks, we ignore its specialness and
treat as a sequence of UTF-8 codes.

Further hardcoded fallbacks can be added by calling keys_push_once in
load_termcap; there is no limit to the amount of keys pushed.

Uses the "ke" and "ks" capabilities to start / exit application mode, which
is necessary on vt100 emulators (including screen, xterm and all terminals
that emulate either of those) to correctly receive arrow keys.

It's now possible to compile getch2 even without termcap, though it won't
be of much use since it'll be unable to detect special keys.

Converted to 4 spaces per tab, prettified some statements.
2013-07-25 00:01:51 -03:00
Stefano Pigozzi 5f265d5930 cocoa_common: handle keyboard modifiers for mouse events 2013-07-21 10:49:27 +02:00
James Ross-Gowan 3e7d483ac8 w32: update manifest for high DPI and Windows 8.1
Since Windows Vista, when running at 144 DPI or higher with composition
switched on, applications that don't declare themselves to be DPI aware
are stretched by the window manager, kind of like low resolution apps in
OSX.

To avoid this, declare DPI awareness in the manifest. Since mpv is
practically resolution independent this shouldn't cause any trouble. The
'True/PM' value declares per-monitor DPI awareness in Windows 8.1, so
that the mpv isn't shrunk when moved from a high DPI screen to one with
a lower DPI.

Also, avoid compatibility shims by declaring compatibility with all
Windows versions from Vista to 8.1 and add the missing uiAccess
attribute to the requestedExecutionLevel element.
2013-07-14 16:10:23 +02:00
wm4 5e6b96f1ff getch2-win: uncrustify 2013-07-14 16:08:27 +02:00
wm4 659a314a19 osdep: remove unused mmap compatibility hacks
Not sure how this worked. Only af_export.c and tvi_v4l2.c were
using mmap, but they didn't include osdep/mmap.h or mmap_anon.h. In
any case, we trust that the target system is sufficiently POSIX
compliant if mmap is actually defined (as checked by configure).
2013-07-07 21:44:37 +02:00
Stefano Pigozzi 8af51bd3fe cocoa: remove usage of mp_fifo
Update Cocoa parts to remove usage of the mp_fifo internal API to send events
to the core and use the input context directly. This is to follow commits the
work in commits 70a8079c and d603e73c.
2013-07-03 22:25:45 +02:00