Commit Graph

1477 Commits

Author SHA1 Message Date
wm4 a4f3df5970 x11: attempt to make initial fullscreening more reliable
It appears some WMs have a problem with out method of setting initial
fullscreen mode. We assume that if the window's _NET_WM_STATE includes
_NET_WM_STATE_FULLSCREEN before mapping the window, the WM will show it
as fullscreen at mapped. EWMH doesn't say anything that this should
work, although one could argue that it's implied.

In any case, since it's not standard behavior without at least some
doubt, it's probably a good idea to try the "old" method as well.
Fortunately, it should be idempotent.

See #1937, #1920.
2015-05-15 13:50:44 +02:00
wm4 372b85b9d2 vo: remove suspicious line
pts can never be 0 or negative. If there is no frame, some code below
catches this case by checking hasframe.
2015-05-15 13:40:43 +02:00
Michael Vetter 9251fa125f Remove trailing whitespaces 2015-05-15 11:02:44 +02:00
wm4 bad932e8ed vo_opengl: hardcode rquested GL version in backends
The requested version field didn't make much sense anymore, and was even
partially ignored by some backends.
2015-05-14 13:07:00 +02:00
wm4 fa39dadb05 x11: use new OpenGL backend API 2015-05-14 00:05:54 +02:00
wm4 df97c30e0e vo_opengl: create new API for OpenGL VO backends
An attempt to get rid of the weird mix of callbacks that take either
struct vo or MPGLCopntext as parameter. This is not perfect, and the
API will probably change a bit until all other code is ported to it.
the main question is how to separate struct vo completely from the
windowing code, which actually needs vo for very little.

In the end, the legacy callbacks will be dropped.
2015-05-14 00:05:43 +02:00
wm4 10de9b091a vo_opengl: change user options for requesting GLES
Instead of having separate backends, make use of GLES a flag. This
reduces the number of backends and the resulting annoyances.

Also, nobody cares about using GLES, so there's no backward
compatibility either.
2015-05-14 00:05:39 +02:00
wm4 27da344e6f vo_opengl: merge GL backend creation/initialization
The final goal is to remove the nonsense separation between the 3
backend init/vo_init/GL context creation calls.
2015-05-13 22:56:44 +02:00
wm4 5ab05f61ca vo_opengl: remove mpgl_lock calls
Awkward stuff not needed anymore.
2015-05-13 22:03:24 +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 7e21f6fd00 vo_opengl: remove some more Cocoa resize leftovers 2015-05-13 21:58:37 +02:00
Stefano Pigozzi 5258c012fe vda: add support for nv12 image formats
The hardware always decodes to nv12 so using this image format causes less cpu
usage than uyvy (which we are currently using, since Apple examples and other
free software use that). The reduction in cpu usage can add up to quite a bit,
especially for 4k or high fps video.

This needs an accompaning commit in libavcodec.
2015-05-13 19:57:39 +02:00
wm4 0bdef9979f vo: avoid burning CPU when paused
Some code always calls vo_event(), even with event==0, which leads to
immediate wakeup, which in turn causes the function to be called again.
This would burn CPU, which was especially noticeable when paused.
2015-05-13 09:28:59 +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 434343d634 vo: use pthread_cond_timedwait() for video timing
Will be used to make video waiting interruptible with Cocoa (see the
following commit).

One worry was that this could cause hangs if the system clock jumps
backwards. Normally we don't support such behavior, because it's
almost impossible to handle it reasonably. E.g. we would have to
change the default clock type for condition variables, which in turn
would require a custom function for creating condition variables,
or so. If the OS even supports different clocks.

But it turns out that this is no issue, because other events seem
to wakeup the wait call anyway, and mpv internal absolute times use
a monotonic clock.
2015-05-12 22:30:45 +02:00
wm4 6b7155c05b vo_opengl_cb: add support for interpolation
This uses the OpenGL frame interpolation code, which before could be
used by vo_opengl only.

Some effort was made to make it behave like vo_opengl, for the better or
the worse. As a consequence, there is a minor duplication of code and
mechanism. Hopefully this can all be wiped as soon as the VO frame
queue/timing mechanism is cleaned up.

This also attempts to use mpv_opengl_cb_report_flip() (as called by the
API user) to determine the vsync interval. This might need refinement as
well.

(In general, we simply expect the API user to work in vsync-blocking
manner.)
2015-05-12 22:16:38 +02:00
wm4 ee3de1a063 vo_opengl_cb: add a "block" framedrop mode and make it default
(I have no idea why there are different modes.)

Instead of risking to drop frames too early, give it some margin. Since
there are situations this could deadlock, wait with a timeout. This can
happen if e.g. the API user is refusing to render anything, or if
uninitialization is happening.
2015-05-12 22:16:19 +02:00
wm4 4d9255a5e1 vo_opengl_cb: actually set requested options
Quite an oversight.
2015-05-12 22:16:07 +02:00
wm4 af157db7e5 vo: always call draw_image_timed() if available
Gives the VOs more flexibility.

gl_video.c already ignores the timing info if no interpolation is
active, so this requires no further changes.
2015-05-12 22:15:04 +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 e5573728c7 cocoa: remove unused declaration 2015-05-11 22:56:20 +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 04c02796bd path: make mp_path_join accept normal C strings
Instead of bstr. Most callers of this function do not need bstr. The
bstr version of this function is now mp_path_join_bstr().
2015-05-09 15:26:47 +02:00
wm4 5631060569 vo_drm: allow changing video rectangle settings
Now among other things panscan can be changed during playback.

Unfortunately, it flickers. The issue is that reconfig() clears the
framebuffer. Removing the clearing shows that the "unused" parts of
the picture are not cleared - even though OSD could render there. As
such, this is a separate issue.
2015-05-08 22:38:42 +02:00
wm4 859ddc9906 vo_drm: don't mutate the current frame when clamping for panscan
When running with --panscan=1, this could crash - because the current
frame was reduced in size each time the image was redrawn, which would
result in a failed assertion the second time it's drawn.
2015-05-08 22:36:04 +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 cf210c4ffc vo_opengl: change default FBO format
Reduces (but likely does not remove) the danger of rounding intermediate
values down to 8 bit. This is important for cscale, or any other
processing that might store raw YUV values in framebuffers.

Fixes #1918.
2015-05-05 14:41:33 +02:00
wm4 e25ecdd09a vo_opengl: gl_lcms: fix cache dir creation with path expansion
Path expansion (like "~/dir/" in config file) was used inconsistently,
so the cache directory wasn't always created correctly. Fix this by
moving the path expansion from load_file() to its callers.
2015-05-03 14:58:18 +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 f509a2badb vo_opengl: gl_lcms: create cache dir
Minor user convenience.
2015-05-02 16:36:31 +02:00
wm4 dce941b99c vo_opengl: gl_lcms: make sure win32 unicode fopen() wrapper is enabled 2015-05-02 16:35:53 +02:00
wm4 aeea250ab3 vo_opengl: gl_lcms: minor simplification 2015-05-02 16:34:52 +02:00
wm4 ff1b5432e7 vo_opengl: gl_lcms: use mp_path_join()
Maybe this fixes the win32 problems a user had, or maybe not.

Also, check if cache_dir is set at all. An empty string should be
equivalent to "unset".
2015-05-02 16:29:30 +02:00
Niklas Haas 01b793f117 vo_opengl: gl_lcms: make ICC loading less verbose
Especially with the new ICC cache rework, you get a lot of ugly output
messages that don't really contain any meaningful content.
2015-05-01 21:52:08 +02:00
Niklas Haas 1153f13bee vo_opengl: gl_lcms: replace icc-cache by icc-cache-dir
This now stores caches for multiple ICC profiles, potentially all the
user has ever used. The big use case for this is for users with multiple
monitors. The old logic would mandate recomputing the LUT and discarding
the cache whenever dragging mpv from one screen to another.

This also avoids having to save and check the ICC profile itself, since
the file name already uniquely determines it.
2015-05-01 21:52:08 +02:00
Niklas Haas 47d46ec487 vo_opengl: attach target-prim/target-csp to window screenshots
This will essentially make screenshot-tag-colorspace also affect the
"screenshot window" command, where possible.

Unfortunately, it's completely incompatible with icc-profile, due to API
limitations of ffmpeg (we can only give it an enum of well-known
primaries, rather than an actual ICC profile or primaries).
2015-05-01 21:52:07 +02:00
wm4 94a3a76ee3 vo_rpi: update renderer size on display size changes too
(Not sure why it worked without this when I tested the previous
changes.)

Untested, but should be fine. This is equivalent what is done on e.g.
panscan changes.
2015-05-01 19:22:35 +02:00
wm4 e185887ba0 video/out: remove VOFLAG_FLIPPING
I think this used to be quite important, because the ancient VfW support
in MPlayer used to output flipped frames. This code has been dead in mpv
for quite some time (because VfW decoders were removed, and the --flip
option was dropped too), so get rid of it.
2015-05-01 18:47:27 +02:00
wm4 0a7abbda6b vo_opengl: refactor wayland frame skipping
Currently, the wayland backend needs extra work to avoid drawing more
often than the wayland frame callback allows. (This is not ideal, but
will be fixed at a later time.)

Unify this with the start_frame callback added for cocoa. Some details
change for the better. For example, if a frame is dropped, and a redraw
is done afterwards, the actually correct frame is redrawn, instead
whatever was in the textures from before the dropped frame.
2015-05-01 18:44:45 +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
Avi Halachmi (:avih) ffcad1a72b vo: improve frame drop logic on high playback rate
Commit f1746741de changed the drop
logic to have more slack (drop more frames but less frequent) to prevent
drops due to timing jitter when the clip and screen have similar rates.

However, if the clip has higher rate than the screen (or just higher
playback rate), then that policy hurts smoothness since these "chunked
drops" look worse than one frame drop at a time.

This patch restores the old drop logic when the playback frame rate is
higher than ~5% above the screen refresh rate, and solves this issue.

Fixes #1897
2015-05-01 19:11:44 +03:00
wm4 8c7f3adb41 vo_rpi: update display size on display mode switches 2015-04-30 21:56:16 +02:00
wm4 6ae66e717f vo_rpi: actually draw a black background
Also factor the display size initialization into a separate function.

For some reason this seems to work, although setting the background
color using this 1x1 pixel bitmap does not work. I blame the RPI
beign a terrible piece of hardware with even worse drivers.
2015-04-30 21:56:13 +02:00
Niklas Haas daf4334697
x11: query ICC profile based on center of window
Right now, the default behavior is to pick the numerically lowest screen
ID that overlaps the window in any way - but this means that mpv will
decide to pick an ICC profile in a pretty arbitrary way even if the
window only overlaps another screen by a single pixel.

The new behavior is to query it based on the center of the window
instead.
2015-04-29 14:01:27 +02:00
akemi-san 1e2e504349 vo_drm: zero screen buffers in reconfig function. 2015-04-27 09:22:10 +02:00
Marcin Kurczewski 5f21a68ce9 vo_drm: add window screenshots support 2015-04-26 20:09:26 +02:00
wm4 72e505a944 player: add --window-scale option
Requested. Works similar to the property with the same name.
2015-04-24 23:27:12 +02:00