Commit Graph

1425 Commits

Author SHA1 Message Date
wm4 014547bdc2 vf_lavfi: fix compilation failure
Apparently this fails to compile with clang6. Patch by someone else.

CC: @mpv-player/stable
2014-10-08 12:44:47 +02:00
wm4 f47269a074 x11: disable various features when embedding the window 2014-10-07 23:37:47 +02:00
Stefano Pigozzi f440c0626e cocoa: try to fix sizing bugs on retina displays
untested, no hardware.
2014-10-06 09:58:59 +02:00
Stefano Pigozzi ba994bc0dd cocoa: fix mouse autohide
broken in 547b62f
2014-10-05 23:49:09 +02:00
Stefano Pigozzi 69508dc507 cocoa: remove a debug commento
fixup previous commit
2014-10-05 23:41:39 +02:00
Stefano Pigozzi 547b62f45e cocoa: separate video view and events view 2014-10-05 23:38:39 +02:00
Stefano Pigozzi cb0f342ab2 cocoa: fix fullscreen with bundle 2014-10-05 23:38:12 +02:00
Stefano Pigozzi ea83a2b9bc cocoa: readd some function calls 2014-10-05 22:38:26 +02:00
Stefano Pigozzi c655fdc38f cocoa: actually reset the event flags 2014-10-05 22:32:23 +02:00
Stefano Pigozzi 62bc735c1a cocoa: remove some useless flags 2014-10-05 19:31:21 +02:00
Stefano Pigozzi 2cb97454f5 cocoa: disable some features when embedding in another window
ontop, fullscreen and window title change to be precise
2014-10-05 19:16:23 +02:00
Stefano Pigozzi c6b68c28f4 cocoa: remove --fs-missioncontrol
This is the first of a series of commits that will change the Cocoa way in a
way that is easily embeddable inside parent views. To reach that point common
code must avoid referencing the parent NSWindow since that could be the host
application's window.
2014-10-05 18:07:27 +02:00
Stefano Pigozzi 7968814470 cocoa: fix some pointer casts to be 32bit safe
credits: wm4
2014-10-05 15:22:17 +02:00
Stefano Pigozzi c8ed4736ef cocoa/libmpv: allow to embed mpv GL view in another window
This is just temporary code but is a good base for future work (and baby
steps are required for these changes). The 'final destination' is embedding
the video view into any NSView but that requires some more work (the mechanism
will be the same: pass the view's pointer casted to int64_t through -wid).

For instance we will need to remove as much usage of the window instance
as possible, and use nil guards where not possible. For this reason I will
remove stuff like the mission control fullscreen feature (it's a cute feature
but annoying to support and quite limited, go make your GUIs), and a way to
lookup the current screen directly from the NSView absolute coordinates
(this is needed for ICC detection mostly, and reporting back the screen to
mpv's core).

Moreover the current view.m will need to be separated into 2 views: the actual
video view that will be embedded, and a parent view that will not be embedded
and will be responsibile for tracking events.
2014-10-05 14:28:33 +02:00
Stefano Pigozzi 0ec14ec597 cocoa: simplify the config code and run it on the main thread
This could be dangerous because we initialize the window asynchronously and
return immediately from config, but since the OpenGL context is already
created, this seems to work correctly and doesn't cause weird deadlock cases.
2014-10-05 09:33:00 +02:00
wm4 bd169a313c options: add --no-keepaspect-window
Seems silly, but was requested.
2014-10-04 22:17:36 +02:00
Stefano Pigozzi 1651d96583 cocoa: don't reset presentation options on uninit
This doesn't look to be needed anymore. Fullscreening with both the NSView
and the NSWindow API works correctly. I guess this was forgotten in from older
code which changed presentation options directly for going fullscreen.
2014-10-04 19:10:36 +02:00
Stefano Pigozzi e75ce6c869 cocoa: only call resize for view changing frame 2014-10-04 17:39:43 +02:00
Stefano Pigozzi 0541151b40 cocoa: remove pointless drawRect
Apparently it causes deadlocks, and at the moment it does nothing.

Fixes #778
2014-10-04 17:31:18 +02:00
Stefano Pigozzi d980c30851 cocoa: make fullscreening look like an atomic operation
At the moment when you fullscreen mpv there is a very small time interval
where the fullscreen windows is semi-transparent. Apparently whem moving the
view to another parent it's better to make Cocoa not draw anything globally.

An Apple engineer said it, so it must be correct:
http://www.cocoabuilder.com/archive/cocoa/142020-preventing-flicker-on-moving-nsview-to-different-superview.html

I know I will regret this in the future.
2014-10-04 17:31:18 +02:00
Stefano Pigozzi b915852f9f cocoa: make resizing wake the vo thread 2014-10-04 17:31:18 +02:00
Stefano Pigozzi c1d5b182b4 cocoa: remove dead code 2014-10-04 17:31:18 +02:00
Alessandro Ghedini d02275d35a vf_stereo3d: fix "auto" input format with libav 2014-10-04 16:28:30 +02:00
wm4 54fd93856a x11: stupid workaround for XMonad
--x11-netwm=yes now forces NetWM fullscreen, while --x11-netwm=auto
(detect whether NetWM fullsctreen support is available) is the old
behavior and still the default.

See #888.
2014-10-04 15:03:02 +02:00
Stefano Pigozzi d1bdf9ea11 cocoa: move to a simpler threading model
Unfortunately using dispatch_sync for synchronization turned out to be really
bad for us. It caused a wide array of race conditions, deadlocks, etc.

Moving to a very simple mutex. It's not clear to me how to do liveresizing
with this, for now it just flickers with is unacceptable (maybe I'll draw
black instead).

This should fix all the threading cocoa bugs. Reopen if it's not the case!

Fixes #751
Fixes #1129
2014-10-04 11:47:17 +02:00
wm4 a74a324b98 video: return responsibility of video redraw back to playloop
When the VO was moved it its own thread, responsibility for redrawing
was given to the VO thread itself. So if there was a condition that
indicated that redrawing was required, like expose events or certain
VOCTRLs, the VO thread was redrawing itself.

This worked fine, but there are some corner cases where this works
rather badly. E.g. if I fullscreen the player and hit panscan controls
with mpv's default autorepeat rate, playback stops. This happens because
the VO redraws itself after every panscan change command. Running each
(repeated) command takes so long due to redrawing and (involuntary)
waiting on vsync, that it never leaves the input processing loop while
the key is held down. I suspect that in my case, redrawing in fullscreen
mode just gets slow enough that it takes 2 vsyncs instead of 1 on
average, and the processing time gets larger than the autorepeat delay.

Fix this by taking redraw control from the VO, and instead let the
playloop issue a "real" redraw command to the VO if needed. This
basically reverts redraw handling to what it was before moving the VO to
a thread.

CC: @mpv-player/stable
2014-10-03 23:07:08 +02:00
wm4 6dad7d6fe7 x11: fix --wid=0
Another fallout resulting from the changes whether or not to wait for
mapping the window. In this case, it obviously makes no sense to wait
for mapping, because the root window is always mapped. Mapping will
never happen, and it would wait forever.

Fixes #1139.
CC: @mpv-player/stable
2014-10-02 18:14:30 +02:00
wm4 64fb37c173 vo_vdpau: don't try to create surfaces of size 0
At least on kwin, we decide to proceed without waiting for the window
being mapped (due to the frame exts hack, see commit 8c002b79). But that
leaves us with a window size of 0x0, which causes VdpOutputSurfaceCreate
to fail. This prints some warnings, although vo_vdpau recovers later and
this has no other bad consequences.

Do the following things to deal with this:
- set the "known" window size to the suggested window size before the
  window is even created
- allow calling XGetGeometry on the window even if the window is not
  mapped yet (this should work just fine)
- make the output surface minimum size 1x1

Strictly speaking, only one of these would be required to make the
warning disappear, but they're all valid changes and increase robustness
and correctness. At no point we use a window size of 0x0 as magic value
for "unset" or unknown size, so keeping it unset has no purpose anyway.

CC: @mpv-player/stable
2014-10-01 17:29:24 +02:00
James Ross-Gowan f23827d557 w32_common: quit event loop on destroy
When embedding, if the parent window is destroyed, it will cause mpv's
window to be destroyed as well. Since WM_USER wakeups are sent to the
window, destroying the window will prevent wakeups and cause uninit to
hang.

Fix this by quitting the event loop on WM_DESTROY. Events should only be
processed for the lifetime of the window, from CreateWindowEx to
WM_DESTROY. After the event loop is finished, mp_dispatch_queue_process
can handle any remaining requests.
2014-09-30 23:01:06 +10:00
wm4 c2592be4f0 vd_lavc: fix a small memory leak on init error
The private context wasn't free'd when codec init failed. Restructure
the code so that it can't happen.
2014-09-29 20:37:12 +02:00
wm4 053196de84 x11: always wait for mapped when using --wid
Might help with embedding with mozplugger. I can't confirm whether it
fixes the issue.

See #1090.
2014-09-29 18:06:45 +02:00
wm4 3273db1ef7 client API, X11: change default keyboard input handling again
Commit 64b7811c tried to do the "right thing" with respect to whether
keyboard input should be enabled or not. It turns out that X11 does
something stupid by design. All modern toolkits work around this native
X11 behavior, but embedding breaks these workarounds.

The only way to handle this correctly is the XEmbed protocol. It needs
to be supported by the toolkit, and probably also some mpv support. But
Qt has inconsistent support for it. In Qt 4, a X11 specific embedding
widget was needed. Qt 5.0 doesn't support it at all. Qt 5.1 apparently
supports it via QWindow, but if it really does, I couldn't get it to
work.

So add a hack instead. The new --input-x11-keyboard option controls
whether mpv should enable keyboard input on the X11 window or not. In
the command line player, it's enabled by default, but in libmpv it's
disabled.

This hack has the same problem as all previous embedding had: move the
mouse outside of the window, and you don't get keyboard input anymore.
Likewise, mpv will steal all keyboard input from the parent application
as long as the mouse is inside of the mpv window.

Also see issue #1090.
2014-09-28 20:11:00 +02:00
wm4 aeaa1767e9 Fix build with libavfilter disabled
Although I'm not sure why we even support this.
2014-09-28 19:10:50 +02:00
wm4 cdb25d5a21 video: change automatic rotation and 3D filter insertion
We inserted these filters with fixed parameters, which was ok. But this
also didn't change image parameters for the filters down the filter
chain and the VO. For example, if rotation by 90° was requested by the
file, we would insert a filter and rotate the video, but the VO would
still receive image parameters that direct rotation by 90°.

This wasn't a problem, but it could become one.

Fix this by letting the filters automatically pick up the image params.
The image params are reset on application. (We could probably also
always try to apply and reset image params in a filter, instead of
having special "auto" parameters. This would probably work, and video.c
would insert a "rotate=0" filter. But I'm afraid this would be confusing
and the current solution is cosmetically slightly nicer.)

Unfortunately, the vf_stereo3d.c change turned out a big mess, but once
the "internal" filter is fully replaced with libavfilter, most of this
can be radically simplified.
2014-09-27 18:31:59 +02:00
wm4 0ec6df2ddf vf_lavfi: make chaining from other filters more flexible
Some filters exists only to create a specific lavfi graph. Allow these
filters to reset the graph exactly on reconfig, and allow them to modify
some image parameters too. Also make vf_lw_update_graph() behave like
vf_lw_set_graph() - they had a subtitle difference with filter==NULL.

Useful for the following commit.
2014-09-27 17:21:29 +02:00
wm4 debbff76f9 Remove mpbswap.h
This was once central, but now it's almost unused. Only vf_divtc still
uses it for extremely weird and incomprehensible reasons. The use in
stream.c is trivial. Replace these, and remove mpbswap.h.
2014-09-25 21:32:55 +02:00
wm4 fd7dde404d video: remove BITMAPINFOHEADER from internal demuxer API
MPlayer traditionally did this because it made sense: the most important
formats (avi, asf/wmv) used Microsoft formats, and many important
decoders (win32 binary codecs) also did. But the world has changed, and
I've always wanted to get rid of this thing from the codebase.

demux_mkv.c internally still uses it, because, guess what, Matroska has
a VfW muxing mode, which uses these data structures natively.
2014-09-25 00:59:15 +02:00
wm4 1f4a74cbed vf_vapoursynth: make it possible to get filter output incrementally
Until now, we always required the playback core to decode a new frame to
get more output from the filter. That seems to be completely
unnecessary, because filtered results may arrive before that.

Add a filter_out callback, and restructure the code such that it can
return any filtered frames, or block if it hasn't read at least one
frame.

In the worst case, it still can happen that bursts of input requests and
output requests happen. (This commit tries to reduce burst-like
behavior, but it's not entirely possible due to the indeterministic
nature of VS threading.)

This is a similar change as with 95bb0bb6.
2014-09-23 00:35:57 +02:00
wm4 a4241f9de6 video: fix redrawing when pausing after framedrop
When pausing after a frame was just dropped, we're logically at the
dropped frame, and thus should redraw the dropped frame. This was
implemented, but didn't work after unpausing for the second time,
because of a minor logic bug.
2014-09-21 10:06:06 +02:00
wm4 1cf229f462 video: fix some vo_direct3d crashes due to FFmpeg nonsense
For incomprehensible reasons, AV_PIX_FMT_GRAY8 (and some others) have a
palette. This literally makes no sense and this issue has bitten us
before, but it is how it is.

This also caused a crash with vo_direct3d: this mapped a texture as
IMGFMT_Y8 (i.e. AV_PIX_FMT_GRAY8), and when copying this, it tried to
copy the non-existent palette.

Fixes #1113.
2014-09-21 09:33:51 +02:00
wm4 68b7217d41 vo_vdpau: better integration with the generic framedrop code
vo_vdpau uses its own framedrop code, mostly for historic reasons. It
has some tricky heuristics, of which I'm not sure how they work, or if
they have any effect at all, but in any case, I want to keep this code
for now. One day it might get fully ported to the vo.c framedrop code,
or just removed.

But improve its interaction with the user-visible framedrop controls.
Make --framedrop actually enable and disable the vo_vdpau framedrop
code, and increment the number of dropped frames correctly.

The code path for other VOs should be equivalent. The vo_vdpau behavior
should, except for the improvements mentioned above, be mostly
equivalent as well. One minor change is that frames "shown" during
preemption are always count as dropped.

Remove the statement from the manpage that vo_vdpau is the default; this
hasn't been the case for a while.
2014-09-20 15:17:12 +02:00
wm4 461c78e4d9 vo_vdpau: fix confusion around vsync_interval
vc->vsync_interval and vsync_interval should be the same value, but
actually vc->vsync_interval was updated after vsync_interval was
initialized. This was probably not intended. Fix this by removing the
duplicate local variable. There were probably no bad effects.
2014-09-20 14:54:19 +02:00
Alexander Preisinger 29467736cf wayland: use reported rete and delay
If native-keyrepeat is true then we set the rate and delay reported by the
compositor.
2014-09-19 17:38:24 +02:00
wm4 95bb0bb671 vf_lavfi: fetch output frames incrementally
Uses the new mechanism introduced in the previous commit.

Depending on the actual filter, this distributes CPU load more evenly
over time, although it probably doesn't matter.
2014-09-18 19:36:55 +02:00
wm4 580cf433bd video/filter: allow better dataflow
Consider a filter which turns 1 frame into 2 frames (such as an
deinterlacer). Until now, we forced filters to produce all output frames
at once. This was done for simplicity.

Change the filter API such that a filter can produce frames
incrementally.
2014-09-18 19:36:27 +02:00
wm4 6ef40cb910 video: wake up core as soon as possible
There's no reason to let the core wait until the frame is done
displaying. In practice, the core normally didn't need this additional
wakeup, and the VO was quick enough to fetch the new frame, before the
core even attempted to queue a new frame. But it wasn't entirely clean,
and the correct wakeup handling might matter in some cases.
2014-09-16 23:59:13 +02:00
Alexander Preisinger 95053ba78b vo_wayland: remove unnecessary check
buffer_pool_get_front now returns always a valid buffer.
No need for corner cases.
2014-09-16 15:54:10 +02:00
Alexander Preisinger 20643b6c91 wayland/buffer: use buffer macros consistently 2014-09-16 15:48:07 +02:00
wm4 8c002b79d3 x11: if the WM supports _NET_FRAME_EXTENTS, don't wait for map
Some window managers can prevent mapping of a window as a feature. i3
can put new windows on a certain workspace (with "assign"), so if mpv is
started on a different workspace, the window will never be mapped.

mpv currently waits until the window is mapped (blocking almost all of
the player), in order to avoid race conditions regarding the window
size. We don't want to remove this, but on the other hand we also don't
want to block the player forever in these situations.

So what we need is a way to know when the window manager is "done" with
processing the map request. Unfortunately, there doesn't seem to be a
standard way for this. So, instead we could do some arbitrary
communication with the WM, that may act as "barrier" after map request
and the "immediate" mapping of the window. If the window is not mapped
after this barrier, it means the window manager decided to delay the
mapping indefinitely. Use the _NET_REQUEST_FRAME_EXTENTS message as such
a barrier. WMs supporting this message must set the _NET_FRAME_EXTENTS
property on the mpv window, and we receive a PropertyNotify event. If
that happens, we always continue and cancel waiting for the MapNotify
event.

I don't know if this is sane or if there's a better mechanism. Also,
this works only for WMs which support this message, which are not many.
But at least it appears to work on i3. It may reintroduce flickering on
fullscreen with other WMs, though.
2014-09-15 19:19:01 +02:00
Ben Boeckel 3f6212cd8d sanitizer: avoid divide-by-zero instances
Merges pull request #1094, with some minor changes. mpv expects IEEE,
and IEEE allows divisions by 0 for floats, so these shouldn't actually
be a problem, but do it anyway for the sake of clang.

Signed-off-by: wm4 <wm4@nowhere>
2014-09-14 21:07:30 +02:00