Commit Graph

776 Commits

Author SHA1 Message Date
Akemi 41d559c4a9 cocoa-cb: fix a warning with swift 4.1 and slight cleanup
the icc profile data is mutated to an UnsafeMutablePointer and could
possibly changed. therefore the size of it should be accessed before a
possible change.
2018-04-17 21:20:35 +03:00
Akemi b2dc69e347 HIDRemote: fix volume buttons on macOS 10.13
this is a backport of line 1039 to 1046 from
33a32ab613 (diff-8a4d13f0849b3beffa4267954ca28517R1039)

Fixes #5721
2018-04-17 20:10:17 +03:00
Akemi af7b412d1c
cocoa-cb: fix shutdown when fullscreen animation is running
commit 2edf00f changed the MPV_EVENT_SHUTDOWN behaviour slightly, such
that it will only be sent once. cocoa-cb relied on it being sent
continuously till all mpv_handles are destroyed. now it manually shuts
down and destroys the mpv_handle after the animation instead of relying
on this removed behaviour.
2018-03-18 12:11:10 -07:00
wm4 03791fae16 all: replace mpv_detach_destroy() with mpv_destroy() 2018-03-15 00:00:04 -07:00
Akemi ef2225c4a2 cocoa-cb: fix usage of wrong fbo when off-screen
when we transitioned to the new libmpv API with commit ae29725 i
reintroduced an old bug that was fixed with 7f714c6 because of a dumb
rebasing error on my part. the branch i based the libmpv changed on was
originally without the fbo fix and on rebasing i forgot to change the
variable to the proper one, basically deactivating the fix.
2018-03-11 22:44:26 -07:00
Akemi ae2972557f cocoa-cb: use new libmpv API instead of opengl-cb
a new replacement API was introduced with b037121 and the old one was
deprecated. porting cocoa-cb to the new API.
2018-03-04 16:26:35 -08:00
Akemi d7b6ebf643 cocoa-cb: move the GL dummy function to swift
it's possible to get a function pointer through a closure after all in
swift. remove the GL dummy function from the c header and do it in the
swift code instead.
2018-03-04 16:26:35 -08:00
wm4 b6c7d899ca osdep/atomic: add emulation for atomic_exchange() 2018-02-28 00:55:06 -08:00
wm4 74c3c2ccb4 osdep/atomic: fix potential shadowing warnings
The stdatomic emulation adds "_" to each variable used inside the
macros, to avoid that compilers print -Wshadow warnings for identifiers
that are also used in surrounding code. Do this more consistently,
because new warnings have been showing up.
2018-02-28 00:55:06 -08:00
Akemi aa974b2aa7 cocoa-cb: make fullscreen resize animation duration configurable 2018-02-28 00:48:44 -08:00
Akemi 938ad6ebc0 cocoa-cb: change border and borderless window styling
the title bar is now within the window bounds instead of outside. same
as QuickTime Player. it supports several standard styles, two dark and
two light ones. additionally we have properly rounded corners now and
the borderless window also has the proper window shadow.

Also make the earliest supported macOS version 10.10.

Fixes #4789, #3944
2018-02-28 00:48:44 -08:00
Akemi 7f714c6984 cocoa-cb: fix invalid framebuffer operation error
in certain circumstances the returned fbo for drawing is 0, but that
fbo is solely used internally by the CAOpenGLLayer for its drawing and
should never be used. in that case we fallback to 1 or the last used fbo
instead if it was not 0.

Fixes #5546
2018-02-21 22:30:46 -08:00
sfan5 8f9785d128 lua+js: Implement utils.getpid()
Usable for uniquely identifying mpv instances from
subprocesses, controlling mpv with AppleScript, ...

Adds a new mp_getpid() wrapper for cross-platform reasons.
2018-02-13 20:16:01 -08:00
Akemi c5e4538bc4 cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.

- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations

all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.

this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.

this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.

some credit goes to @pigoz for the initial swift build support which
i could improve upon.

Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 04:49:15 -08:00
Akemi 0d964471b8 osx: add some more menu bar items as suggested by Apples's HIG
this adds the standard menu bar items Services, Hide Others, Show All
and Close, as suggested by Apple's HIG.
https://developer.apple.com/macos/human-interface-guidelines/menus/menu-bar-menus/#app-menu

- Services are useful to add custom actions and shortcuts via the
System Preferences to mpv
- Close is important since the menu bar can open secondary windows, like
About or the Open dialogue. those couldn't be closed with the standard
system shortcut before. this is now possible.
2018-01-20 17:30:00 -08:00
Akemi db08e28304 osx: code cleanups and cosmetic fixes 2018-01-20 14:43:49 -08:00
Akemi 45ce4ba877 osx: fix macOS 10.13 deprecation warning
NSFileHandlingPanelOKButton is deprecated with macOS 10.13, but the
replacement NSModalResponseOK is not available on 10.8 and earlier.

added a declaration for 10.8 and earlier since i only officially
dropped support for 10.7 and earlier. this is untested.
2018-01-20 14:43:49 -08:00
Ricardo Constantino d7188ce753
mpv.rc: readd actual version info 2018-01-01 21:44:01 +00:00
wm4 49e704cb19
build: move copyright statement to a shared location
Now macosx_menubar.m and mpv.rc (win32) use the same copyright string.
(This is a bit roundabout, because mpv.rc can't use C constants. Also
the C code wants to avoid rebuilding real source files if only version.h
changed, so only version.c includes version.h.)
2018-01-01 21:05:09 +00:00
wm4 a90abe0546
Update copyright year 2018-01-01 21:05:07 +00:00
pavelxdd 74c6e7ba1d subprocess-win: don't change the mouse cursor in CreateProcess
By default the CreateProcess changes the mouse cursor to
IDC_APPSTARTING. The new flag added to STARTUPINFOEXW prevents
changing the cursor from default arrow on creating a new process.
2017-12-14 21:35:55 +11:00
Drew DeVault f60bfd1ad5 terminal-unix: fix race condition with tty reset
Calling do_deactivate_getch2 before joining the terminal thread could
lead to breakage if the terminal thread got another interation in before
it was signaled to stop.

This also addresses a minor error with the order in which things are
initialized - getch2_poll would previously call tcgetpgrp(tty_in) before
tty_in was initialized, which did not lead to broken behavior, but was
not correct either.

Fixes #5195
2017-12-09 21:37:44 +02:00
Drew DeVault a0fc195112 terminal-unix: switch back to poll(3)
This leverages the new polldev shim which lets us "poll" device files on
macOS with select and use the genuine article on other platforms.
2017-12-09 21:11:46 +02:00
Drew DeVault ba418132cd osdep: add poll shim for macOS
This implements a poll-compatible interface, backed by select on macOS,
suitable for polling on device files - which are not supported by
macOS's implementation of poll. This is a (long-standing) bug in macOS,
so hopefully we can eventually remove this shim.
2017-12-09 21:11:46 +02:00
Drew DeVault 0f9a690eba terminal-unix: fix busy looping on Linux
POSIX permits select() to modify the timeout, which can happen on the
Linux implementation. This can reset the timeout, which spins this into
a tight loop. A timeout isn't necessary in the first place, so just use
NULL instead.
2017-12-08 19:58:36 +02:00
Drew DeVault 8977fe5ed9 Use /dev/tty instead of stdin for terminal input
Fixes #4190

This allows you to use terminal input even if you've piped something
into mpv.
2017-12-08 01:30:42 +02:00
wm4 7bc48f7843 build: remove nanosleep() check
Also guaranteed by POSIX.
2017-12-02 23:29:40 +01:00
wm4 0601e48ef4 build: remove termios check
Also should be fully covered by POSIX.
2017-12-02 23:27:23 +01:00
wm4 6f8cf73f54 ao: simplify hack for float atomics
stdatomic.h defines no atomic_float typedef. We can't just use _Atomic
unconditionally, because we support compilers without C11 atomics. So
just create a custom atomic_float typedef in the wrapper, which uses
_Atomic in the C11 code path.
2017-11-30 01:20:03 +01:00
James Ross-Gowan 0bdbe2bc53 win32: fix semantics of POSIX 2008 locale stubs
This sliences some warnings about unused values and statements with no
effect, but it also fixes a logic error with freelocale(), since
previously it would not work as expected when used in the body of an if
statement without braces.

Uses real functions, because with macros, I don't think there is a way
to silence the "statement with no effect" warnings in the case where the
return value of uselocale() is ignored.

As for replacing the these functions with working implementations, I
don't think this is possible for mpv's use-case, since MSVCRT does not
support UTF-8 locales, or any locale with multibyte characters that are
three or more bytes long. See:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale
2017-11-19 21:10:56 +11:00
wm4 41cefe3e1f stream_libarchive, osdep: use stubs for POSIX 2008 locale on MinGW 2017-11-12 16:43:34 +01:00
Akemi 007cd24c2b osx: fix the bundle $PATH yet again
we have 5 parameters for the string but only 4 were being used.
2017-11-11 19:21:21 +01:00
James Ross-Gowan 257a2b9646 win32: add more-POSIXy versions of open() and fstat()
Directory-opening never worked on Windows because MSVCRT's open()
doesn't open directories and its fstat() doesn't recognise directory
handles. These are just MSVCRT restrictions, and the Windows API itself
has no problem with opening directories as file objects, so reimplement
mpv's mp_open and mp_stat to use the Windows API directly. This should
fix directory playback.

This also populates the st_dev and st_ino fields of struct stat, so
filesystem loop checking in demux_playlist.c should now work on Windows.

Fixes #4711
2017-10-25 22:37:20 +11:00
Akemi 318e2e53f0 osx: add right MacPorts paths to our bundle $PATH
also add another path for homebrew.
2017-10-07 22:18:22 +02:00
Akemi 6132323911 osx: add some common paths to our $PATH when started from bundle
with the previous commit we removed the ability of loading the standard
shell environment. this exact behaviour can only be re-added by either
invoking the standard shell in a background process and reading it's
environment vars or by manually reading all the various shell configs.
both ways are kinda dirty and the former was already rejected before.
for now we will just add some commonly used paths, when started from the
bundle, so it can find the binaries used by mpv again. for example the
youtube-dl one for our youtube-dl hook.
2017-10-03 11:30:56 +02:00
Akemi 77021cf6fe osx: fix bundle on macOS High Sierra (10.13)
Apple slightly changed the App bundle mechanism which broke wrapper
scripts that invoke the actual binary. it caused the bundle to always
open a new instance of mpv instead of reusing the currently running one.

just removing the wrapper script would lead to several regressions, so
it was replaced with a symlink to the bundle binary. detection if mpv
was started from the bundle was replaced by comparing the execution name
of the binary, eg the name of the symlink "mpv-bundle". additionally,
because we load a standard config from the Resources folder of the
bundle again, we prevent that config from being loaded if mpv wasn't
started via the bundle. the psn argument has to be removed manually
again.

the ability of loading your standard shell environment has been removed
with the wrapper. a substitution will be added with another commit. as a
side effect this fixes an issues when zsh was used with common NodeJS
configuration scripts.

Fixes #4926 #4866
2017-10-03 11:30:56 +02:00
sfan5 acfd1a1929 android: posix_spawn(p) replacement
Signed-off-by: wm4 <wm4@nowhere>
2017-09-22 09:24:19 +02:00
Jan Ekström f4c80d4402 osdep/io: add android related bullshit
This fixes >2GiB files with at least API level 21.
See: https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md
for the gritty details.

* Based on libavformat's things, except we do not care about API
  versions or NDKs without unistd.h, which contains all sorts of
  things that we utilize.
* Redefines lseek to always point to the 64bit version.
* Redefines fseeko to always point towards an inlined static
  implementation that utilizes the 64bit version of lseek underneath.
2017-09-18 20:28:46 +03:00
Akemi 9cb7f87b86 osx: fix media keys input when other Apps steal the priority
other Apps do the same as mpv and tap into the global event chain.
events that are handled are not being propagated down the event chain.
that can lead to mpv not getting any media key events anymore when they
are held back by other Apps. we will just move mpv back to the top of
the event list when mpv is refocused and is not at the top of the list
any more.

Fixes #4834
2017-09-07 20:42:26 +02:00
Akemi d355cb618c osx: fix build on macOS 10.11 and earlier
98f5579 added a safeguard for the deactivation of the automatic tab bar
but it still needs a compile time guard. add a forward declaration for
the setAllowsAutomaticWindowTabbing method of NSWindow.

Fixes #4783
2017-08-26 11:42:50 +02:00
wm4 0bfeba2d9a win32: fix massive memory corruption (take 2)
As pointed out by uau on IRC, the pointer to info is still used outside
of the lock. An extremely small race condition window, but still a race
condition.
2017-08-21 18:42:04 +02:00
wm4 d431111b06 win32: fix massive memory corruption
The struct m_thread_info pointer is part of an array, that will be
reallocated if another thread is created while the run_thread is just
being called. In previous versions of this code, the pointer was stable
(as long as the thread existed), so this was overlooked.

Fixes #4770. I'm not sure why this triggers it so reliably, while it
remained undetected otherwise.
2017-08-21 17:47:00 +02:00
Akemi 98f5579c02 osx: remove the standard "Show Tab Bar" menu item
it's unused and added automatically. we need to guard the deactivation
since it's a 10.12+ feature.
2017-08-18 21:44:33 +02:00
Akemi 344b75f52d osx: code cleanups and cosmetic fixes
silence build warnings, clean up code style and remove unused code.
2017-08-18 19:47:47 +02:00
Akemi e0a2d15216 osx: refactor menu bar creation
make the menu bar look more like a standard macOS menu bar, with all the
standard menu items like About, Help, Open, etc.
2017-08-18 19:20:41 +02:00
Akemi 48ab72b478 osx: move menu bar creation into its own file 2017-08-18 19:20:41 +02:00
Jan Ekström 0389852db0 {demux_mf,osdep/io}: disable glob usage when it is not available
This currently is only limited to Android. Its stdlib contains the
things that mpv's POSIX check checks for, but unfortunately not
glob().

This fixes Android compilation broken in 70a70b9da .
2017-08-05 01:51:29 +03:00
James Ross-Gowan 037c7a9279 w32_common: handle media keys
This was attempted before in fc9695e63b, but it was reverted in
1b7ce759b1 because it caused conflicts with other software watching
the same keys (See #2041.) It seems like some PCs ship with OEM software
that watches the volume keys without consuming key events and this
causes them to be handled twice, once by mpv and once by the other
software.

In order to prevent conflicts like this, use the WM_APPCOMMAND message
to handle media keys. Returning TRUE from the WM_APPCOMMAND handler
should indicate to the operating system that we consumed the key event
and it should not be propogated to the shell. Also, we now only listen
for keys that are directly related to multimedia playback (eg. the
APPCOMMAND_MEDIA_* keys.) Keys like APPCOMMAND_VOLUME_* are ignored, so
they can be handled by the shell, or by other mixer software.
2017-08-05 02:38:44 +10:00
James Ross-Gowan 28e3618e79 subprocess-win: fix swprintf usage
The count parameter refers to the number of wide-characters to write to
the buffer (including the terminating NUL character, which is always
added,) not the number of bytes. See C99 7.24.2.3 or
https://msdn.microsoft.com/en-us/library/ybk95axf.aspx
2017-07-29 21:13:07 +10:00
James Ross-Gowan 5453604606 subprocess-win: don't leak pipe handle on error 2017-07-28 23:00:46 +10:00
James Ross-Gowan 7097b6f81c subprocess-win: remove VLA usage
This only ever waits on four handles at most anyway.
2017-07-26 00:20:11 +10:00
Pedro Pombeiro 4637b029cd Universal Windows Plaform (UWP) support
libmpv only. Some things are still missing.

Heavily reworked.

Signed-off-by: wm4 <wm4@nowhere>
2017-06-29 10:36:16 +02:00
wm4 cd25d98bfa Avoid calling close(-1)
While this is perfectly OK on Unix, it causes annoying valgrind
warnings, and might be otherwise confusing to others.

On Windows, the runtime can actually abort the process if this is
called.

push.c part taken from a patch by Pedro Pombeiro.
2017-06-29 10:31:13 +02:00
wm4 7eca787571 build: change how some OS specific source files are selected
In a bunch of cases, we emulate highly platform specific APIs on a
higher level across all OSes, such as IPC, terminal, subprocess
handling, and more. We have source files for each OS, and they implement
all the same mpv internal API.

Selecting which source file to use on an OS can be tricky, because there
is partially overlapping and emulated APIs (consider Cygwin on Windows).
Add a pick_first_matching_dep() function to make this slightly easier
and more structured.

Also add dummy backends in some cases, to deal with APIs not being
available.

Clarify the Windows dependency identifiers, as these are the most
confusing.
2017-06-29 10:30:16 +02:00
wm4 70a70b9da3 build: replace glob() check and assume it's always in POSIX
POSIX requires glob(), so no need to check for it. Together with the
fact that we can emulate glob() on Windows, glob() is always available.
2017-06-29 10:30:13 +02:00
wm4 dd87ce6f4b terminal: remove unused return value 2017-06-27 18:08:56 +02:00
wm4 6b303d5c3c osx: change license of OSX and cocoa files to LGPL
All authors of the current code have agreed.
2017-06-24 16:29:22 +02:00
wm4 c9696a1b14 w32_common, w32_keyboard: change license to LGPL
All authors agreed.
2017-06-24 12:54:45 +02:00
wm4 9f461b85bf Revert "osdep: NetBSD pthread_setname_np()"
This reverts commit 2e81698d28.

Seems like this was a patch applied from someone who can't agree to LGPL
relicensing (see previous commit), with the author field not properly
set.

This is not so important anyway, so just revert it.
2017-06-22 13:17:40 +02:00
wm4 fa929eb0d0 win32: pthread: avoid using TLS, simplify pthread_t
Don't use __thread, which requires heavy runtime in some cases (such as
MinGW-w64, at least under some configurations, forcing you to link to
its pthread runtime DLL).

The pthread_t struct was needed over a simple thread ID, because
pthread_join() needed to access some sort of context from pthread_t.
Further, pthread_exit() and pthread_detach() need the context of the
current thread, for which we relied on TLS.

Replace these uses by a global thread array. This includes all threads
created by the thread wrapper. Hopefully the number of threads created
by mpv is low (say, below 20), and threads are not that often created or
destroyed. So just keeping them in an array with linear search lookup
should be reasonable.
2017-06-15 16:33:42 +02:00
wm4 5b3ca8ed41 terminal: change license to LGPL
All authors of the current code have agreed.

The code probably originates from a software named GySmail (as the
copyright header indicates). As far as I can tell, it was written by
Arpi (who has agreed), possibly with unknown co-authors. This is most
likely OK, as none of the original code is around anymore anyway. I
could not find a working download of GySmail, that actually contained
the original getch2.c code.

This also has a wild history of random people adding ifdef guards to
control ioctl() vs. tcgetattr() calls. (See for example 2b1310abba4c1.)
Later, the ioctl() was removed in favor of the POSIX tcgetattr(), and
the ifdeffery was removed. So these people were not contacted.
2017-06-14 14:28:05 +02:00
wm4 a3be4cf2ab mpv.rc, mpv.exe.manifest: change license to LGPL
All authors have agreed.

mpv.exe.manifest probably can't have a copyright header, so it doesn't.

These files don't add license info to the executables. And of course the
executable license is still GPL.
2017-06-12 17:06:03 +02:00
James Ross-Gowan bc381dd05e win32: pthread: use the new thread naming API
Windows, as of the Creators Update, finally has a sane API for giving a
name to a thread that can be used by debuggers. This is similar to
pthread_setname_np on Linux and some Unixes. Expose it in the pthread
wrapper and use it for mpthread_set_name().
2017-05-18 00:11:14 +10:00
wm4 c64d40bad7 osdep/compiler.h: change license to LGPL
This didn't have a header and this was implied LGPL, but this was not
entirely correct. It turns out the printf attribute code was leaked in
from talloc, which is "LGPL v3 or later". talloc was added to the
mplayer2 code base in 27a30e310e. This remaining code was an oversight.

Since we want to reduce LGPL v3 code, replace this code with the one
from ta/ta.h. This code was explicitly written newly to get rid of
talloc and its license in 0933f12d28.
2017-05-08 13:11:46 +02:00
wm4 cf0bce19bb osdep/timer*: change license to LGPL
All authors have agreed, with the following exceptions:

e68d7f6858: wight wasn't asked (I think...), but even if he modified the
patch he applied, all code added by it was removed again later.

cb7768f9bb: nick could not be reached, but the declarations he added as
well as the full timer.c file were deleted again in cff81fe498 and
f800a42e45 (did it really take 6 years to remove unused declarations?).

ffaf4af230: it looks like this person wasn't contacted, but the code
added was removed again in f544bcf105.
2017-05-05 12:35:57 +02:00
wm4 dcb5800357 osx: fix deadlock on exit with libmpv on OSX
There is explicit code to handle the libmpv case, but it expects that
a dispatch queue is running. This is not necessarily the case. E.g.
edit the simple.c mpv example not to do any playback and to destroy
the mpv handle immediately. It will freeze on exit, because nothing
will release the mpv_handle.

I'm not sure how this should be fixed, so disable it for now in
library mode.
2017-04-19 12:55:44 +02:00
wm4 bbfafb5614 Fix use of ISC license
The license text refers a "above copyright notice", so I guess it'd be
good to actually provide such a notice.

Add the license to some files that were missing it (since in theory, our
Copyright file says that such files are LGPL by default).

Remove the questionable remarks about the license in the client API.
2017-04-15 16:20:00 +02:00
wm4 dc5dfa5c92 win32: fix mismatched free/talloc_free
Might fix #4315.
2017-04-12 14:12:41 +02:00
wm4 7497b633e9 win32: rewrite getcwd() using GetFullPathNameW
_wgetcwd is apparently not available in all runtimes. Well, whatever.
2017-04-11 13:54:10 +02:00
wm4 e0d93178b9 win32: add UTF-8 getcwd() wrapper 2017-04-11 12:19:41 +02:00
Akemi 13160530f2 osx: fix Touch Bar access on systems without Touch Bar support
when building with a deployment target older than an SDK with Touch Bar
support we still tried to access the TouchBar, since the compile time
checks are positive. to prevent this we add two runtime checks.
2017-04-02 21:02:33 +02:00
Akemi 265547eb94 osx: fix event propagation of menu bar item key shortcuts
a small logic error in 063ca8f broke the filtering of the menu bar item
key shortcuts. they where called several times per event because the
propagation wasn't stopped properly.
2017-03-27 01:29:45 +02:00
Akemi 063ca8f0fe osx: fix key input in certain circumstances
for a reason i can just assume some key events can vanish from the
event chain and mpv seems unresponsive.

after quite some testing i could confirm that the events are present at
the first entry point of the event chain, the sendEvent method of the
Application, and that they vanish at a point afterwards. now we use
that entry point to grab keyDown and keyUp events. we also stop
propagating those key events to prevent the no key input' error sound.
if we ever need the key events somewhere down the event chain we need
to start propagating them again. though this is not necessary currently.
2017-03-26 20:38:26 +02:00
Akemi f8a223b7ac osx: initial Touch Bar support 2017-03-26 20:26:18 +02:00
Akemi ca1dd7cc61 osx: add key mappings for previous and next Media Keys
Fixes #4204
2017-03-09 18:00:16 +01:00
Akemi b5ca8c41cc osx: drop support for OS X 10.7 and earlier 2017-02-27 23:53:53 +01:00
Akemi c824a023c4 cocoa: fix dragging out of focus window
fffab30 introduced a small regression where the cursor couldn't be
unhidden after refocusing. the problem is that no mouseUp event was
reported in our events_view. work around this with a separate event
monitor. this also fixes another regression when the window is being
dragged from the title bar.

#4174
2017-02-21 19:26:33 +01:00
Akemi a5b97104cf osx: improve bundle handling
we have two problems here. first when mpv is started from the bundle it
uses its own environment variables and possibly can't find for example
the youtube-dl binary for our youtube-dl hook. second we couldn't
reliable determine when mpv was started from the bundle, which led to
the pseudo-gui usage even when the binary was invoked from a shell.

to prevent this we will wrap the bundle binary with a shell script,
which will only be called when we start mpv from the bundle. this way
we can get the same environment variables, like $PATH, for our bundle
and additional we can set the pseudo-gui only when started through this
script. it is also possible to detect the bundle usage properly and
accurately through the usage of another environment var.

Fixes #2061
2017-02-16 22:21:03 +01:00
Akemi 05eb42f6e1 cocoa: gracefully quit from the Dock's context menu
quitting mpv from the Dock's context menu leaves the shell in a bad
state where you can't see your input any more and other weirdnesses.

in a big refactor (afdc9c4) the method to handle this case was actually
copied over but the the code to register the event itself was removed or
forgotten by accident, leaving some lines of dead code. i re-added the
event and slightly adjusted the function. the function was slightly
changed so the head of it is consistent with our other events and it is
associated with this commit and functionality in the future.
2017-02-16 16:36:34 +01:00
wm4 81efe20cd7 atomic: remove __atomic builtin usage
Using these was a temporary solution while some compilers implemented
the underlying atomic mechanisms, but not the C11 language parts (or
that's what I guess). Not really useful for us anymore. Also, there is
the slight risk of having subtly incorrect semantics by using
potentially changing compiler internals and such.
2017-02-13 06:45:40 +01:00
James Ross-Gowan e0250b9604 vo_opengl: angle: rewrite with custom swap chain
This replaces the old backend that exclusively used EGL windowing with
one that can also use ANGLE's ability to render to directly to a
texture. The advantage of this is that it allows mpv to create the swap
chain itself and this allows mpv to use a flip-mode swap chain on a HWND
(which avoids problems with DirectComposition) and to use a longer swap
chain that has six backbuffers by default (which reportedly fixes
problems with rendering 24fps video on 24Hz monitors.)

Also, "screenshot window" should now work on DXGI 1.2 and up (Windows 8
and up.)
2017-02-07 22:45:07 +11:00
James Ross-Gowan 9692814502 win32: add COM-specific SAFE_RELEASE to windows_utils.h
See: https://msdn.microsoft.com/en-us/library/windows/desktop/dd743946.aspx

Microsoft example code often uses a SAFE_RELEASE macro like the one in
the above link. This makes it easier to avoid errors when releasing COM
interfaces. It also reduces noise in COM-heavy code.

ao_wasapi.h also had a macro called SAFE_RELEASE, though unlike the
version above, its SAFE_RELEASE macro accepted a second parameter which
allowed it to destroy arbitrary objects other than just COM interfaces.
This renames ao_wasapi's SAFE_RELEASE to SAFE_DESTROY, which should more
accurately reflect what it does and prevent confusion with the Microsoft
version.
2017-01-30 00:22:30 +11:00
wm4 c3205d294e atomic: drop __sync builtins
The correctness of the stdatomic.h emulation via the __sync builtins is
questionable, and we've been relying on exact stdatomic semantics for a
while, so just get rid of it. Compilers which support __sync but not
stdatomic.h will use to the slow mutex fallback.

Not sure about the __atomic builtins. It doesn't seem to harm either, so
leave it for now.
2017-01-27 09:15:32 +01:00
wm4 8e41f314f1 Update copyright year
What kind of bullshit forces you to do this every year anyway.
2017-01-01 19:09:05 +01:00
Akemi 2b8b17402e cocoa: cosmetic fixes 2016-12-16 16:32:26 +01:00
Akemi a8347eb9ba cocoa: fullscreen refactoring
this replaces the old fullscreen with the native
macOS fullscreen. additional the
--fs-black-out-screens was removed since the new
API doesn't support it in a way the old one did.
it can possibly be re-added if done manually.

Fixes #2857 #3272 #1352 #2062 #3864
2016-12-15 20:55:16 +01:00
Akemi 3bb06155c9 cocoa: support append file to paylist on drop
When dropping a file on mpv, either on the window
or the App bundle icon, while holding the shift
key the dropped files will be appended to the
playlist.

Fixes #2166
2016-12-14 00:34:16 +01:00
Akemi ed7e650d3a osx: update the menu and remove conflicting item
Remove 'Quit mpv & remember playback position'
from the menu because it conflicts with the global
logout shortcut. add separator between 'Hide' and
'Quit' for consistency with other Apps.
also rename the 'Movie' menu to 'Video'. it's a
bit more generic.

Fixes #3865
2016-12-12 12:10:10 +01:00
James Ross-Gowan 803e2c5f87 win32: fix some Clang warnings
- win32-console-wrapper.c was inconsistently using the explicit Unicode
  versions of some Windows API functions and structures.
- vo.c should use llabs for int64_t, since long is 32-bit on Windows.
- vo_direct3d.c had a potential use of an uninitialized variable if it
  took the first goto error_exit.
2016-11-17 23:34:20 +11:00
James Ross-Gowan 40b626fd9b build: fix compilation with mingw-w64/Clang
This fixes the build in mingw-w64/Clang on MSYS2. It also disables the
use of gnu_printf in Clang, which was what was causing most of the
warnings. The Clang-compiled mpv binary appears to work, but there are
no guarantees yet, since until now mpv has only been tested with
mingw-w64/GCC on Windows.

Fixes #3800
2016-11-17 23:34:20 +11:00
James Ross-Gowan 0af8811b15 terminal-win: support modifier keys in console input
Keyboard input in the console still isn't quite as flexible as it is in
the video window. Ctrl+<letter> and Ctrl+LEFT/RIGHT work, but
Ctrl+Alt+<letter> and Ctrl+<number> do not. Also, in the new Windows 10
console, a bunch of Ctrl keystrokes including Ctrl+UP/DOWN are handled
by the console window and not passed to the application.

Unlike in w32_common.c, we can't really translate keyboaard input
ourselves because the keyboard layout of the console window (in
conhost.exe) doesn't necessarily match the keyboard layout of mpv's
console input thread, however, using ToUnicode as a fallback when the
console doesn't return a unicode value could be a possible future
improvement.

Fixes #3625
2016-10-14 08:44:33 +11:00
James Ross-Gowan 6a8d1cdd49 terminal-win: clean up console input
The original version of this code in getch2-win.c fetched 128 console
events at once. This was probably to maximize the chance of getting a
key event if there were other events in the buffer, because it returned
the value of the first key event it found and ignored all others. Since
that code was written, it has been modified to receive console input in
an event-based way using an input thread, so it is probably not
necessary to fetch so many events at once any more. Also, I'm not sure
what it would have done if there were more than 128 events in the
console input buffer. It's possible that fetching multiple events at a
time also had performance advantages, but I can't find any other
programs that do this. Even libuv just fetches one console event at a
time.

Change read_input() to fetch only one event at a time and to consume all
available events before returning to WaitForMultipleObjects. Also remove
some outdated comments and pass the console handle through to the input
thread instead of calling GetStdHandle multiple times (I think this is
theoretically more correct because it is possible for the handles
returned by GetStdHandle to be changed by other threads.)
2016-10-14 08:44:33 +11:00
James Ross-Gowan 3751065f97 win32: build with -DINITGUID
We always want to use __declspec(selectany) to declare GUIDs, but
manually including <initguid.h> in every file that used GUIDs was
error-prone. Since all <initguid.h> does is define INITGUID and include
<guiddef.h>, we can remove all references to <initguid.h> and just
compile with -DINITGUID to get the same effect.

Also, this partially reverts 622bcb0 by re-adding libuuid.a to the
build, since apparently some GUIDs (such as GUID_NULL) are not declared
in the source file, even when INITGUID is set.
2016-09-28 21:38:52 +10:00
wm4 9eef41dec1 player: do not let pseudo-gui override user config settings
Seems like this confused users quite often.

Instead of --profile=pseudo-gui, --player-operation-mode=pseudo-gui now
has to be used to invoke pseudo GUI mode. The old way still works, and
still behaves in the old way.
2016-09-23 21:24:50 +02:00
Akemi 9df797575f cocoa: fix macOS 10.12 deprecation warnings 2016-09-22 13:46:27 +02:00
wm4 b62634c051 player: make --terminal freetly settable at runtime
So client API users don't have to care about whether to set this before
or after mpv_initialize().

We still don't enable terminal at any point before mpv_initialize(),
because reasons.

This also subtly changes some behavior how terminal options are applied
while parsing. This essentially reverts the behavior as it was reported
in issue #2588. Originally, I was hoping to get rid of the pre-parse
option pass, but it seems this is absolutely not possible due to the way
config and command line parsing are entangled. Command line options take
priority over configfile options, so they have to be applied later - but
we also want to apply logging and terminal options as specified on the
command-line, but _before_ parsing the config files. It has to be this
way to see config file error messages on the terminal, or to hide them
if --no-terminal is used. libmpv considerations also factor into this.
2016-09-19 19:54:54 +02:00
wm4 75fe626aa6 terminal-unix: don't send quit command on terminal_uninit()
Until now, the terminal thread always sent a quit command if the
terminal thread was torn down (whether it happened via terminal_uninit()
or a quit signal). This is not so good if we want to enable toggling
terminal use at runtime, since disabling the terminal would always make
the player quit. So we want terminal_uninit() not to send quit.

This can be easily fixed by using the "death byte" sent to the pipe used
for thread tear-down to indicate whether it was caused by a signal or
terminal_uninit().
2016-09-19 19:53:08 +02:00
wm4 591e21a2eb osdep: rename atomics.h to atomic.h
The standard header is stdatomic.h, so the extra "s" freaks me out every
time I look at it.
2016-09-07 11:26:25 +02:00
wm4 c6b7a4dace atomics: readd some emulation
This time it's emulation that's supposed to work (not just dummied out).
Unlike the previous emulation, no mpv code has to be disabled, and
everything should work (albeit possibly a bit slowly). On the other
hand, it's not possible to implement this kind of emulation without
compiler support. We use GNU statement expressions and __typeof__ in
this case.

This code is inactive if stdatomic.h is available.
2016-09-06 20:15:07 +02:00
wm4 d4ee5e5a8a build: always require atomics
Always require them, instead of just for some components which have hard
requirements on correct atomic semantics. They should be widely
available, and are supported by all recent gcc and clang compiler
versions. We even have the fallbacks builtins, which should keep this
working on very old gcc releases.

In particular, w32_common.c recently added a hard requirement on
atomics, but checking this properly in the build system would have been
messy. This commit makes sure it always works.

The fallback where weak atomic semantics are always fine is in theory
rather questionable as well.
2016-08-05 17:10:22 +02:00
Rostislav Pehlivanov c3e11f7b7c osdep/io: introduce mp_flush_wakeup_pipe()
Makes a fairly common occurence with wakeup_pipes easier to handle.
2016-07-30 00:02:39 +02:00
Timotej Lazar 91a1b17104 Use - as command-name separator everywhere
Old-style commands using _ as separator (e.g. show_progress) were still
used in some places, including documentation and configuration files.
This commit updates all such instances to the new style (show-progress)
so that commands are easier to find in the manual.
2016-07-14 22:37:42 +02:00
James Ross-Gowan bf2e2bf3e8 win32: mpv.rc: re-add version info
For some reason, the lack of version info was preventing mpv from
appearing in the Default Programs dialog. Re-add it, but don't set the
string version numbers from version.h, because that's what was causing
trouble when the version info was removed. Like the binary version
numbers, these are now hardcoded to 2.0.0.0, which probably doesn't
matter.

The new version info block is also slightly different to the old one. It
fills out all the binary VERSIONINFO fields and makes better use of
macros. It also removes the \000 line terminators from the string
version info, since as far as I can tell, this was just cargo-culting
for an old broken version of the Microsoft resource compiler, and
binutils' windres terminates the strings properly without them.
2016-07-12 21:05:33 +10:00
Ben Boeckel 33e72ed451 subprocess: add a callback to ignore output
This callback is equivalent to shoving data into /dev/null.
2016-07-05 19:15:59 +02:00
stepshal c5094206ce Fix misspellings 2016-06-26 13:47:21 +02:00
Niklas Haas 5b5db336e9 build: silence -Wunused-result
For clang, it's enough to just put (void) around usages we are
intentionally ignoring the result of.

Since GCC does not seem to want to respect this decision, we are forced
to disable the warning globally.
2016-06-07 14:12:33 +02:00
wm4 b9cc33de58 win32: pthread: use SRW locks by default
SRW locks are available since Windows Vista. They work essentially like
Linux futexes. In particular, they can be statically initialized, and do
not require deinitialization. This makes them ideal for implementing
PTHREAD_MUTEX_INITIALIZER.

We still need CRITICAL_SECTION for recursive mutexes.
2016-05-24 19:02:22 +02:00
wm4 3375d65bc5 mpv.rc: remove most contents
In particular remove version.h to deal with my temporary build problem.
2016-03-14 20:29:00 +01:00
James Ross-Gowan bf0801a14a glob-win: relicense to LGPL
This file was rewritten from scratch in 0cef033, so it should be okay.
As mentioned in #730, it's a complete rewrite referencing only MSDN and
POSIX, rather than the original code.
2016-02-18 22:57:28 +11:00
Kevin Mitchell 50d9a2609a windows_utils: try and use FormatMessage for errors.
This is useful in particular for GetLastError, unfortunately, it's stil pretty
dumb with regards to WASAPI or D3D specific errors, so keep the
hresult_to_string switch.
2016-02-17 06:58:56 -08:00
Kevin Mitchell 3dfb07854b dxva2: use mp_HESULT_to_str on FAILED(hr) 2016-02-16 12:36:57 -08:00
Alexis Nootens 733e0b23c8 cocoa: fix charcode retrieving for accented characters
The handler was retrieving an invalid charcode for
accented characters, thus ignoring them.
2016-02-15 18:21:50 +01:00
Jan Ekström ff0112e08d Initial Android support
* Adds an 'android' feature, which is automatically detected.
* Android has a broken strnlen, so a wrapper is added from FreeBSD.
2016-02-10 21:29:36 +01:00
wm4 c3348d86f2 build: make posix_spawn optional
OK, Android doesn't support it.
2016-02-08 20:29:08 +01:00
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
Dmitrij D. Czarkoff ea442fa047 mpv_talloc.h: rename from talloc.h
This change helps avoiding conflict with talloc.h from libtalloc.
2016-01-11 21:05:55 +01:00
wm4 31a4547187 ao_wasapi: move out some utility functions
Note that hresult_to_str() (coming from wasapi_explain_err()) is mostly
wasapi-specific, but since HRESULT error codes are unique, it can be
extended for any other use.
2016-01-11 16:24:13 +01:00
James Ross-Gowan c19f634e6c win32: fix fd://
Windows definitely supports Unix-style fd inheritance. This mostly
worked when launched from mpv.exe, though mpv should change the file
mode to O_BINARY. When launched from mpv.com, the wrapper must pass the
list of handles (stored in the undocumented lpReserved2 and cbReserved2
fields) to the mpv process.
2016-01-07 23:37:06 +11:00
wm4 de0523ba7b Update copyright year
Merry christmas, or whatever the fuck is going on right now.
2016-01-01 00:18:40 +01:00
Kevin Mitchell 48b103cad7 path-win: include initguid.h
cygwin was giving undefined reference to `FOLDERID_Desktop' at link time
2015-12-20 03:24:35 -08:00
James Ross-Gowan 0563eb914f win32: add Windows 10 compatibility GUID
This suppresses the Program Compatibility Assistant on Windows 10. mpv
is regularly tested on Windows 10, so this should be okay.
2015-12-20 21:06:02 +11:00
James Ross-Gowan 6205d87a7f win32: path: use Known Folder IDs
CSIDLs have been deprecated in Windows Vista and are not recommended for
use in new code. They have been replaced with Known Folder IDs, which
are pretty much the same thing, except they use GUIDs.
2015-12-20 21:06:02 +11:00
James Ross-Gowan 491958a724 win32: use PIPE_REJECT_REMOTE_CLIENTS
This partially reverts c670488. mpv only supports Vista and up, so this
flag is fine.
2015-12-20 21:06:02 +11:00
James Ross-Gowan 808653a9b6 win32: remove ProcThreadAttributeList dynamic loading
These are always available in supported Windows versions, as is the
EXTENDED_STARTUPINFO_PRESENT flag.
2015-12-20 21:06:02 +11:00
James Ross-Gowan d2013b3f50 win32: remove SetDllDirectoryW dynamic loading
All Windows versions we support have this API.
2015-12-20 21:06:02 +11:00
James Ross-Gowan 30bbcd6452 win32: fix console output with raw stdio functions
reopen_console_handle() was never properly tested because mpv overrides
printf in most source files. Turns out that when there's no console on
startup, the CRT sets the fds of stdout and stderr to -2, so the old
method of using dup2 to manipulate these fds didn't work. As far as I
can tell, the only way to give stdout and stderr valid fds is to use
freopen, so this uses freopen to set them both to the console output.
This also uses dup2 to change STDOUT_FILENO and STDERR_FILENO, so low-
level functions like isatty still work.

Note that this means fileno(stdout) != STDOUT_FILENO. I don't think this
will cause any problems.

This should fix MPV_LEAK_REPORT on the Windows console.
2015-12-06 02:37:38 +11:00
Kevin Mitchell c80b7eed53 input: add append argument to file drop event
This puts in place the machinery to merely append dropped file to the playlist
instead of replacing the existing playlist. In this commit, all front-ends
set this to false preserving the existing behaviour.
2015-08-30 05:28:24 -07:00
wm4 70c990cda5 atomics: cleanup HAVE_ATOMICS define
The waf build system generates this already. No point in redoing it in
the header file.

The legacy build system (which we really should drop) didn't; fix it.
2015-08-13 23:34:14 +02:00
wm4 63ade8a49c terminal: disable terminal foreground state polling
This was originally done for zsh; but zsh can manage the terminal state
correctly when foregrounding/backgrounding applications if you enable it
with "ttyctl -f". So I see no reason to wake up the mpv process once
every second anymore.
2015-08-01 21:30:16 +02: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 fefac2c941 win32: more wchar_t -> WCHAR replacements
This was essentially missing from commit 0b52ac8a.

Since L"..." string literals have the type wchar_t[], we can't use them
for UTF-16 strings. Use C11 u"..." string literals instead. These have
the type char16_t[], but we simply assume char16_t is the same
underlying type as WCHAR. In practice, they're both unsigned short.

For this reason use -std=c11 on Windows. Since Windows is a "special"
environment (we require either MinGW or Cygwin), we don't need to worry
too much about compiler compatibility.
2015-07-30 21:50: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
wm4 b3468d53c7 win32: pthread: don't play dirty tricks for mutex init
We used double-checked locking on pthread_mutex_t.requires_init in order
to lazily initialize static mutexes (since CRITICAL_SECTION has no
native way to do this). This was kind of unclean: we relied on MSVC
semantics for volatile (which apparently means all accesses are weakly
atomic), which is not such a good idea since mpv can't even be compiled
with MSVC.

Since it's too much of a pain to get weak atomics, just use INIT_ONCE
for initializing the CRITICAL_SECTION. Microsoft most likely implemented
this in an extremely efficient way. Essentially, it provides a mechanism
for correct double-checked locking without having to deal with the
tricky details. We still use an extra flag to avoid calling it at all
for normal locks.

(To get weak atomics, we could have used stdatomic.h, which modern MinGW
provides just fine. But I don't want this wrapper depend on MinGW
specifics if possible.)
2015-07-27 22:59:38 +02:00
wm4 3452f9aeac win32: add portable config mode
See manpage additions.

The main reason for adding this is that we can't guess whether the user
wants his config in his Windows profile or not. The user basically has
to tell mpv what should be done, and the "portable_config" directory
does this implicitly.

Fixes #2042 (approximately).
2015-07-27 21:48:30 +02:00
Philip Sequeira 4a4f788a68 player: use exit code 0 by default for quit, 4 for signals, etc.
Default key bindings in encoding mode also use code 4, because scripts
will probably want to fail if encoding is aborted (leaving an
incomplete file).
2015-07-11 23:46:49 +02:00
wm4 5728295dab timer: fix a corner case on clock changes
It's conceivable that the OS time source is subject to clock changes.
The time could jump back to before when mpv was started, which would
cause mp_time_us() to return values smaller than 1. This is unexpected
by the code and could trigger assertions. If there's no monotonic time
source there's not much we can do anyway, so just sanitize the return
value. It will cause strange behavior until the "lost" time offset has
passed, but if you make such huge changes to the system clock while
everything is running, you're asking for trouble anyway.

(Normally we try to get a monotonic time source, though. This problem
sometimes happened on Windows when compiled without winpthreads, when
the code was falling back to gettimeofday(). This was already fixed by
always using another method.)
2015-07-04 17:24:10 +02:00
James Ross-Gowan f544bcf105 win32: use QueryPerformanceCounter for timing
clock_gettime is implemented in winpthreads, so it's unavailable when
mpv is compiled with its internal pthreads implementation. This makes
mp_raw_time_us fall back to gettimeofday(), which can cause an assert
failure in mp_add_timeout() when the system clock is changed. Use
QueryPerformanceCounter instead.

The clock_gettime(CLOCK_MONOTONIC) implementation in winpthreads uses
QueryPerformanceCounter anyway, so there shouldn't be any change in
behaviour.
2015-07-04 15:54:14 +02:00
wm4 03c70a8d81 subprocess, lua: export whether the process was killed by us
We want to distinguish actual errors, and just aborting the program
intentionally.

Also be a bit more careful with handling the wait() exit status: do not
called WEXITSTATUS() without checking WIFEXITED() first.
2015-06-27 21:08:55 +02:00
wm4 2a67208f40 terminal-unix: set terminal mode on init
mpv usually sets the terminal to non-canonical mode (which in particular
disables line buffering). But the old mode is restored if the process is
not foregrounded. This is supposed to make mpv behave nicer when it is
backgrounded.

getch2_poll() enables canonical mode. Unfortunately, this was only
called after the poll timeout elapsed, so non-canonical mode is first
enabled after about a second after program start. Fix this by moving the
poll call before the timeout.

(As far as we're aware, there's no event-based way to determine when the
FD's process group changes, thus we're polling.)
2015-06-27 12:20:40 +02:00
wm4 1b7ce759b1 Revert "win32: add mappings for some special keys"
This reverts commit fc9695e63b.

Users were complaining that both mpv and something else (what? I don't
know) respond to some multimedia keys, such as volume change.
2015-06-24 15:14:38 +02:00
Marcin Kurczewski 797277a233 Various spelling fixes
Signed-off-by: wm4 <wm4@nowhere>
2015-06-18 19:36:58 +02:00
wm4 ed805e16fc osx: add NULL check for input context in a missing case
Fixes a crash on exit under certain circumstances.
2015-06-01 19:36:20 +02:00
wm4 bf4dd877e9 osx: synchronize access to the input_ctx
While all functions of input_ctx are inherently thread-safe, access to
the _inputContext field itself is not. It could be unset any time by
cocoa_set_input_context(). So even trivial input_ctx calls must be under
a lock, so that the input_ctx can not be destroyed while the function
call is "starting". (Even a function call in progress wouldn't be fine,
because mp_input_uninit() requires the caller to "own" the object, i.e.
no other threads can access it at this point.)
2015-05-26 22:48:04 +02:00
wm4 2dd904289d osx: never expose input_ctx from EventsResponder
Keep it internal, so we can synchronize access to it properly.
2015-05-26 22:39:04 +02:00
wm4 ac879545ad win32: do not call timeEndPeriod(1) on termination
This was called for formal reasons at best. The way it does this is
somewhat dangerous, because if libmpv is unloaded as DLL, this would
attempt to call a dangling function pointer.

(No, we don't want an extra DllMain entrypoint just for win32.)
2015-05-21 22:52:14 +02:00
Michael Vetter 9251fa125f Remove trailing whitespaces 2015-05-15 11:02:44 +02:00
wm4 fc9695e63b win32: add mappings for some special keys
Untested.
2015-05-12 23:01:32 +02:00
wm4 92b9d75d72 threads: use utility+POSIX functions instead of weird wrappers
There is not much of a reason to have these wrappers around. Use POSIX
standard functions directly, and use a separate utility function to take
care of the timespec calculations. (Course POSIX for using this weird
format for time values.)
2015-05-11 23:44:36 +02:00
wm4 ca9964a4fb ao: make better use of atomics
The main reason for this was compatibility; but some associated problems
have been solved in the previous commit.
2015-05-11 23:27:41 +02:00
wm4 cc24ec5b3c atomics: add atomic_fetch_and/atomic_fetch_or
As usual, we prefer plain C11 names and semantics, and have to emulate
them if C11 atomics are not available.

For the non-atomic fallback (which is just there to make code compile in
situations the atomic property is not overly important), we require a
gross hack to make the generic macros work without using compiler-
specific extensions.
2015-05-11 23:20:45 +02:00