0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 20:03:10 +02:00
Commit Graph

210 Commits

Author SHA1 Message Date
Stefano Pigozzi
bc1dce5d5b cocoa: get fps only from dislaylink
In my tests, CGDisplayModeGetRefreshRate returns 24.0 even though the nominal
one is set to 24000/1001. This is obviously not good for video.
2016-01-14 11:11:43 +01:00
Stefano Pigozzi
0fad73862c cocoa: add an observer for screenmode change 2016-01-14 11:11:43 +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
d2baaaa7df vo_opengl: cocoa: implement alpha window support
With --vo=opengl:alpha=yes, the Cocoa backend will now render alpha
video without background.
2015-12-19 10:24:03 +01:00
wm4
aaa64b879e cocoa: fix recent regression
Commit 9db50c67 changed it so that the window title can now be a NULL
string.

Completely untested. Probably fixes #2570.
2015-12-07 00:49:36 +01:00
wm4
9db50c6760 vo: get rid of vo_get_window_title()
It always was a weird artifact - VOCTRLs are meant _not_ to require
special handling in the code that passes them through (like in vo.c).
Removing it is also interesting to further reduce the dependency of
backends on struct vo. Just get rid of it.

Removing it is somewhat inconvenient, because in many situations the UI
window is created after the first VOCTRL_UPDATE_WINDOW_TITLE. This means
these backends have to store it in a new field in their own context.
2015-12-06 18:41:31 +01:00
wm4
2e401201ad vo: remove VOCTRL_GET_RECENT_FLIP_TIME
It doesn't have any real purpose anymore. Up until now, it was still
implemented by vo_wayland, but since we changed how the frame callbacks
work, even that appears to be pointless.

Originally, the plan was to somehow extend this mechanism to all
backends and to magically fix frame scheduling, but since we can't hope
for proper mechanisms even on wayland, this idea looks way less
interesting.
2015-11-23 16:54:53 +01:00
wm4
94b6a1054e cocoa: set application policy before creating window
This fixes a regression since commit f4d62da8. The original code run
vo_cocoa_config_window() once without creating the window, which had the
effect that the last part of the function was run at least once before
the actual window was created. Fix the regression by moving it to before
the window is created.

The regression itself is hard to describe. One test case: start mpv from
a fullscreened terminal window. It should switch to another desktop,
with the mpv window visible. This didn't happen anymore.
2015-10-11 16:19:08 +02:00
wm4
f4d62da8f0 vo_opengl: cocoa: switch to new internal API 2015-10-01 22:42:25 +02:00
Rodger Combs
533e151feb cocoa: hide cursor using a blank image instead of a system-wide API
Fixes #503
2015-08-11 08:02:58 +02:00
Stefano Pigozzi
34875413fa cocoa: don't load hardcoded icon if running from bundle
Makes ricers happy.
2015-05-25 08:58:32 +02:00
wm4
d89eb74cb7 cocoa: redo synchronization
Before this change, Cocoa state was accessed from both the VO and the
Cocoa main thread. This was probably not a good idea. There was some
locking as well as implicit synchronization using the dispatch
mechanism, but it wasn't watertight.

Change this completely. Now Cocoa things are always accessed from the
main thread only. The old mutex falls away, as well as the
vo_cocoa_set_current_context() function, which implicitly used the lock
to coordinate VO accesses. With the new code, the VO thread generally
has to wait for the main thread, while the main thread never waits for
the VO and rarely accesses it. Fortunately, this is rather straight
forward, and most of this is achieved by making vo_cocoa_control() run
on the main thread. The logic of the code does generally not change.

Some aspects are trickier. Apparently we can't access the
NSOpenGLContext from the VO thread, because this object is not thread-
safe. We use some CGLContextObj functions instead, such as for making
the context current and swapping the buffers.
2015-05-13 22:00:34 +02:00
wm4
29eb764fe0 cocoa: make live-resizing as fast as before
Interrupt video timing. This means the Cocoa event loop does not have
to up to 2 video frame durations until redrawing the frame finally has
finished.

We abuse the VO event flags for this. Eventually this should use
wait_vo() or so in the video timing wait function, but for now the
interaction this would require with the code of other VOs/backends
would cause too much of a mess.
2015-05-12 22:42:06 +02:00
wm4
7735b29732 cocoa: handle live-resizing differently
Instead of requiring a complicated mechanism to share the entire OpenGL
and renderer state between VO and Cocoa thread just to do the redrawing
during live-resize on the Cocoa thread, let the Cocoa thread wait on the
VO thread. This wil allow some major simplifications and cleanups in the
future.

One problem with this is that it can enter a deadlock whenever the VO
tries to sync with the Cocoa thread. To deal with this, the Cocoa thread
waits with a timeout. This can probably be improved later, though in
general this situation can always happen, unless the Cocoa thread waits
in a reentrant way.

Some other details aren't completely clean either. For example,
pending_events should be accessed atomically. This will also be fixed
later.
2015-05-12 22:31:03 +02:00
wm4
10149f68a5 cocoa: add missing break statements in switch
The first one (for VOCTRL_GET_DISPLAY_FPS) could have led to undefined
behavior if the FPS was unknown. The second is for general symmetry.
2015-05-11 22:56:18 +02:00
wm4
a7ecb11ddd cocoa: remove unused macro 2015-05-11 22:56:15 +02:00
wm4
f58d3591d9 cocoa: remove an unused parameter 2015-05-06 21:48:39 +02:00
wm4
e777756301 cocoa: lock cocoa main thread on uninit
This should fix some crashes due to dangling pointers.

The problem was that with_cocoa_lock_on_main_thread() is asynchronous.
It will not wait until it is finished. In the uninit case, this means
the VO could be deallocated and destroyed while cocoa was still running
uninit code.

So simply wait until it is done by using dispatch_sync(). There were
concerns that this could introduce a deadlock by the main thread trying
to wait for something on the VO thread. But from what I can see, this
never happens, and even if it does, it would crash anyway since the VO
is already gone.

One remaining worry is the video_resize_redraw_callback. From what I can
see, it still can mess things up, and will need a more elaborate fix.
2015-05-06 00:36:33 +02:00
wm4
19a5b20752 cocoa: always compile OSX application code with cocoa
This unbreaks compiling command line player and libmpv at the same
time. The problem was that doing so silently disabled the OSX
application thing - but the command line player can not use the
vo_opengl Cocoa backend without it.

The OSX application code is basically dead in libmpv, but it's not
that much code anyway.

If you want a mpv binary that does not create an OSX application
singleton (and creates a menu etc.), you must disable cocoa
completely, as cocoa can't be used anyway in this case.
2015-05-02 18:09:56 +02:00
wm4
e23e4c7c60 cocoa: don't accidentally drop initial screen drawing
With --idle --force-window, or when started from the bundle, the cocoa
code dropped the first frame. This resulted in a black frame on start
sometimes.

The reason was that the live resizing/redrawing code was invoked, which
simply set skip_swap_buffer to false, blocking redrawing whatever was
going to be rendered next. Normally this is done so that the following
works:

1. vo_opengl draw a frame, releases GL lock
2. live resizing kicks in, redraw the frame
3. vo_opengl wants to call SwapBuffers, drawing a stale buffer
   overwritten by the live resizing code

This is solved by setting skip_swap_buffer in 2., and querying it in 3.

Fix this by resetting the skip_swap_buffer at a known good point: when
vo_opengl starts drawing a new frame.

The start_frame function returns bool, so that it can be merged with
is_active in a following commit.
2015-05-01 18:26:58 +02:00
Stefano Pigozzi
efe0fb75bc cocoa: signal VO_EVENT_WIN_STATE on fps change
Fixes #1686
2015-03-14 12:33:09 +01:00
Stefano Pigozzi
735bf48496 cocoa: fix minimized state getter 2015-03-09 12:01:55 +01:00
Jaime Marquínez Ferrándiz
d7f04e2085 cocoa: support the "window-minimized" property
Signed-off-by: Stefano Pigozzi <stefano.pigozzi@gmail.com>
2015-03-08 22:00:47 +01:00
Stefano Pigozzi
8ec9bce2d3 cocoa: fix autohide in fullscreen 2015-03-08 15:19:17 +01:00
Stefano Pigozzi
ce239f1577 cocoa: fix mouse hiding with launchpad and dock folders
Some UI elements in OS X – like Launchpad and Dock folders – are implemented
using borderless windows in background demonized applications.
When we use these elements, mpv doesn't stop to be the active application, but
the mpv window leaves keyWindow state while we use the OS controls.

This commit just keeps track of window state to update the cursor visibility
accordingly.

Fixes #513
2015-03-08 11:56:56 +01:00
torque
bce753060e cocoa: update mouse coordinates when window is initialized.
Make MpvEventsView -signalMousePosition a public method so it can be
called without a compiler warning. Previously, the mouse position would
be reported as (0,0) until the cursor was moved.
2015-03-07 19:31:52 +01:00
Stefano Pigozzi
678cd30904 cocoa: don't uninit light sensor if not present 2015-03-07 19:28:00 +01:00
Stefano Pigozzi
5cddd4ccca cocoa: remove possible use after free 2015-03-07 09:13:05 +01:00
Stefano Pigozzi
c66b51dab0 cocoa: fix some crashes caused by async uninit
Always keep around our private state and destroy it when we are really done in
the async uninit callback.

Fixes #1657
2015-03-07 08:54:05 +01:00
Stefano Pigozzi
89306818bb cocoa: add support for querying ambient lighting
This will be pretty useful to let mpv automatically change VO parameters based
on ambient lighting conditions.

The conversion code and polinomial equation from Apple LMU values to Lux is
taken from Firefox: their license, MPL is GPL compatible and allows
relicensing to GPL (MPL is more liberal).
2015-03-04 10:06:08 +01:00
Stefano Pigozzi
03a69bac95 cocoa: remove the setNextKeyView hack
Just use makeFirstResponder on the mpv events view from client code
if you need the built in keyboard events (this is easier for dealing with view
nesting).
2015-02-28 14:55:32 +01:00
Stefano Pigozzi
eacf22e42a cocoa: improve refresh rate fallback code
Apparently CoreGraphics reports the actual refresh rate. DisplayLink can also
query the nominal refresh rate of the display so we use that as fallback
instead of the fugly 60fps hardcode added in aeb1fca0d.

Props to people on https://github.com/glfw/glfw/issues/137
2015-02-03 22:59:54 +01:00
Stefano Pigozzi
aeb1fca0d4 cocoa: automatically fetch display-fps from the monitor
Comment explains why I have been so doubtful at adding this. The Apple docs
say CGDisplayModeGetRefreshRate is supposed to work only for CRTs, but it
doesn't, and actually works for LCD TVs connected over HDMI and external
displays (at least that's what I'm told, I don't have the hardware to test).
Maybe Apple docs are incorrect.

Since AFAIK Apple doesn't want to give us a better API – maybe in the fear we
might be able to actually write some useful software instead of "apps" –
I decided not to care as well and commit this.
2015-02-03 22:07:37 +01:00
wm4
f47b14b717 video/out: cosmetics: rename VO_EVENT_ICC_PROFILE_PATH_CHANGED
Remove the "PATH" bit, because VOCTRL_GET_ICC_PROFILE returns an in-
memory profile, and not a path. (This was changed a while ago.)
2015-01-26 02:21:00 +01:00
wm4
78e3821bd5 cocoa: fix fullscreen handling
Fixes #1483, if it even compiles.
2015-01-17 02:45:17 +01:00
wm4
fc524e8a07 command: unify handling of fullscreen and other VO flags
The "ontop" and "border" properties already used a common
mp_property_vo_flag() function, and the corresponding VOCTRLs used the
same conventions. "fullscreen" is pretty similar, but was handled
slightly similar. Change how VOCTRL_FULLSCREEN behaves, and use the same
helper function for "fullscreen" as the other flags.
2015-01-16 23:07:13 +01:00
Stefano Pigozzi
730db25b1b cocoa: don't set application icon in libmpv 2015-01-16 19:24:25 +01:00
Stefano Pigozzi
f811348d0c vo_opengl: add support for in memory icc profiles
Previously we just forced loading a profile from file, but that has poor
integration for querying the OS / display server for an ICC profile, and
generating profiles on the fly (which we might use in the future for creating
preset 3dluts).

Also changed the previous icc-profile-auto code to use this mechanism, and
moved gl_lcms to be an opaque type with state instead of just providing pure
functions.
2015-01-07 18:47:27 +01:00
Stefano Pigozzi
64b6b2ea45 cocoa: fix uninitialization while in fullscreen
This is only needed for switching video track with `_`, since Cocoa
automatically handles cleaning up the application's presentation options when
quitting the process.

Fixes #1399
2015-01-01 14:38:08 +01:00
Stefano Pigozzi
f987625d5a cocoa: move the gl function loader to gl_cocoa.c 2014-12-28 19:10:44 +01:00
Stefano Pigozzi
e80d233fd4 cocoa: mark window for redraw after title change
This used to work correctly without the call to displayIfNeeded. I think this
may only be needed for Yosemite.

Fixes #1330
2014-12-20 11:45:51 +01:00
Stefano Pigozzi
f93e8bb490 cocoa: fix crash
fixes #1323

Doesn't leak unless we switch video tracks on and off while in fullscreen.
2014-12-08 23:02:09 +01:00
Stefano Pigozzi
2833670b71 cocoa: fix view leak in uninit when fullscreen 2014-12-06 21:55:36 +01:00
Stefano Pigozzi
685b8b7a00 cocoa: use --idle when running inside bundle
Previously when using the bundle we used a custom bizarro thing to wait for
events. Just use `--idle` and greatly simplify the code.
2014-12-06 14:16:13 +01:00
Stefano Pigozzi
73b7d4516b cocoa: don't change app activation policy in libmpv
/cc @mpv-player/stable
2014-12-06 10:13:11 +01:00
Stefano Pigozzi
ed76d22b22 cocoa: don't create Dock icon for audio only files
fixes #635
2014-12-05 23:13:21 +01:00
Stefano Pigozzi
bc1b9aa984 cocoa: don't async redraw when waiting for VO redraw
This fixes the very annoying glitch where the black bars disappear for
a single frame when going fullscreen.
2014-12-04 22:53:50 +01:00
Stefano Pigozzi
82afc0f343 vda: use implicit current GL context
Removes the dependency from the Cocoa backend in case we are not using
it but still wanna use VDA GL introp.
2014-12-03 20:40:06 +01:00
Stefano Pigozzi
586c9e7155 cocoa: allow to black out other display when going fs
fixes #1302
2014-12-01 18:05:30 +01:00
Stefano Pigozzi
4590c198e6 cocoa: don’t hand over view memory ownership to libmpv clients 2014-11-25 14:45:13 +01:00