Commit Graph

40364 Commits

Author SHA1 Message Date
wm4 460ef9c7a4 wayland: implement key modifiers
Includes shift, ctrl, alt, meta.
2015-01-12 16:41:00 +01:00
wm4 10532b99e5 wayland: don't compute absurd window size
For some reason, schedule_resize() can be called with everything set to
0. The code couldn't handle wl->window.aspect set to 0, converting NaNs
to integers. Just work this around.

(I have no idea what I'm doing. This is probably a corner case caused
by my broken-ish wayland setup.)
2015-01-12 15:21:26 +01:00
wm4 4a7c6aaedf bstr: fix possible undefined behavior with length 0 strings
BSTR_P() passes the string length and start pointer to printf-like
functions. If the lenfth is 0, the pointer can be NULL, but we're
actually still not allowed to pass a NULL pointer in any case.

This is mostly a technically, because nobody in their right mind would
attempt to specifically break such cases. But it's still undefined
behavior, and some libcs might be strict about this.
2015-01-12 14:43:52 +01:00
wm4 8144d142e4 player: don't set tag strings to NULL
bstr is a bounded string type, consisting of a pointer and a length
value. If the length is 0, the pointer can be NULL. This is somewhat
logical due to how this abstraction works, but it can leak when
converting to C strings.

talloc_strndup() returns NULL instead of "" in this case, which broke
some other code. Use bstrto0() instead, which is the "proper" function
to convert bstr to char*.

Fixes #1462.
2015-01-12 14:33:56 +01:00
wm4 da2dbd74da demux_mkv: fix EBML parsing checks
Reading IDs must be checked too. This was basically forgotten in commit
f3a978cd. Also set the *length parameter for ebml_parse_length() in some
error cases, which _really_ should happen.

Fixes #1461.
2015-01-12 14:31:31 +01:00
wm4 ab185a2d42 manpage: improve --title description
It might be rather surprising that --title also sets the audio stream
title (for PulseAudio and wasapi), so it certainly should be mentioned.
2015-01-12 14:21:16 +01:00
wm4 fcdbaf78f2 tl_matroska: fix minor memory leak in error case
Going the way of least resistance. Fixes #1460.
2015-01-12 13:20:56 +01:00
wm4 8336563d23 player: check sufficient track selection before destroying VO
mpv needs at least an audio or video track to play something. If the
track selection is basically insufficient, the player will immediately
skip to the next file (or quit).

One slightly annoying thing might be that trying to play a subtitle file
will close the VO window, and then go to the next file immediately (so
"mpv 1.mkv 2.srt 3.mkv" would flash the video window when 2.srt is
skipped). Move the check to before the video window is possibly closed.

This is a minor cosmetic issue; one can use --force-window to avoid
closing the video window at all.

Fixes #1459.
2015-01-12 13:04:21 +01:00
wm4 3459130e5c client API: reasonable behavior if window is closed
Closing the video window sends CLOSE_WIN, which is normally mapped to
the "quit" command. The client API normally disables all key bindings,
and closing the window does nothing. It's simply left to the application
to handle this. This is fine - an embedded window can not be destroyed
by user interaction.

But sometimes, the window might be destroyed anyway, for example because
the containing window is destroyed. If this happens, CLOSE_WIN should
better not be ignored. We can't expect client API users to handle this
specially (by providing their own input.conf), so provide some fallback
for this pseudo key binding. The "quit" command might be too intrusive
(not every client necessarily handles "unexpected" MPV_EVENT_SHUTDOWN),
but I think it's still reasonable.
2015-01-12 12:53:49 +01:00
wm4 a8df0bbf22 x11: explicitly query map status when waiting for map event
For some reason, mpv sometimes does not get a MapNotify event with
GtkSocket embedding. This happens maybe 1 out of 10 times. I'm not sure
how this can happen - it certainly shouldn't. Since I was not able to
find the cause, and causes an apparent "deadlock", here's a lazy hack to
fix the misbehavior.
2015-01-12 12:15:27 +01:00
wm4 fc95678d8d x11: support XEmbed
Seems to work with GtkSocket and passing the gtk_socket_get_id() value
via "wid" option to mpv.

One caveat is that using <tab> to move input focus from mpv to GTK does
not work. It seems we would have to interpret <tab> ourselves in this
case. I'm not sure if we really should do this - it would probably
require emulating some other typical conventions too. I'm not sure if an
embedder could do something about this on the toolkit level, but in
theory it would be possible, so leave it as is for now.
2015-01-12 12:08:48 +01:00
wm4 2e531aaf14 vo: don't synchronize when seeking
Don't use vo_control() for sending VOCTRL_RESET when starting a seek.
This means vo_seek_reset() won't wait until the VO actually processed
VOCTRL_RESET. It happens asynchronously instead.

The impact of this change should be minimal, unless the VO is somehow
too busy (like blocking on vsync).
2015-01-12 05:14:41 +01:00
wm4 3f3e1547ba player: change --display-tags behavior
Remove the "all" special-behavior, and instead interpret trailing "*"
characters. --display-tags=all is replaced by --display-tags=* as a
special-case of the new behavior.

See #1404.

Note that the most straight-forward value for matchlen in the normal
case would be INT_MAX, because it should be using the entire string.
I used keylen+1 instead, because glibc seems to handle this case
incorrectly:

    snprintf(buf, sizeof(buf), "%.*s", INT_MAX, "hello");

The result is empty, instead of just containing the string argument.
This might be a glibc bug; it works with other libcs (even MinGW-w64).
2015-01-12 04:57:56 +01:00
wm4 f3a978cd17 demux_mkv: better check for some EBML parsing
Apparently, originally this code was meant to be able to read past the
buffer somewhat, which is why the buffer allocation was padded by 8
byte. This is unclean and confuses valgrind. This probably could have
crashed with certain invalid files too.

Also revert the change added with 10a2f69; it should be not needed
anymore.
2015-01-12 02:11:51 +01:00
wm4 866a5a12b9 demux_mkv: avoid endless loop with broken files
Fixes #1457.
2015-01-12 01:33:35 +01:00
wm4 2c9180f47b ao_pulse: exit AO if stream fails
This can for example reproduced by killing the pulseaudio server. If
this happens, just try to reload the AO, instead of breaking everything
forever.
2015-01-11 04:19:40 +01:00
wm4 3b091995a0 win32: drop hacks for possibly broken static pthreads-win32 linking
We now use threads and other pthread API a lot, and not always we use it
from threads created with pthread_create() (or the main thread). As I
understand, with static linking we would have to use
pthread_win32_thread_attach/detach_np() every time we enter or leave a
foreign thread. We don't do this, and it's not feasible either, so it's
just broken.

This still should work with dynamic pthreads-win32. The MinGW pthread
implementation should be unaffected from all of this.
2015-01-11 02:23:02 +01:00
wm4 e96c08ecb5 command: fix property naming convention
Use "-" instead of "_" as separator.
2015-01-10 21:16:34 +01:00
wm4 e5f2072364 command: change properties added in previous commit
Make their meaning more exact, and don't pretend that there's a
reasonable definition for "bits-per-pixel". Also make unset fields
unavailable.

average_depth still might be inconsistent: for example, 10 bit 4:2:0 is
identified as 24 bits, but RGB 4:4:4 as 12 bits. So YUV formats
seemingly drop the per-component padding, while RGB formats do not.
Internally it's consistent though: 10 bit YUV components are read as
16 bit, and the padding must be 0 (it's basically like an odd fixed-
point representation, rather than a bitfield).
2015-01-10 19:13:16 +01:00
xylosper 242558bec1 command.c: new subproperties for video-params: bpp and depth
bpp(bits-per-pixel) and depth(bit-depth for color component) can
be calculated from pixelformat technically but it requires massive
informations to be implemented in client side.

These subproperties are provided for convenience.
2015-01-10 18:53:03 +01:00
wm4 69dad662c9 player: enable demuxer thread for external audio files
Enable asynchronous reading for external files. This excludes subtitle
files (so it's effectively enabled for audio files only), because most
subtitle files are fully read on loading, and running a thread for them
would just cause slowdowns and increase resource usage, without having
any advantages.

In theory, an external file could provide multiple tracks from the same
demuxer, but demux_start_thread() is idempotent, so the code can be
kept simple.

Should help with playing DASH with ytdl_hook.
2015-01-10 00:41:45 +01:00
wm4 23e4a8ce7f player: change stream list terminal output
Move the stream selection marker "(+)" to the beginning, and drop the
"[stream]" prefix. Make the edition output line up with it too.
2015-01-09 23:56:49 +01:00
wm4 3c3883ebe1 DOCS/client_api_examples: qml_direct: QWindow::size() is not thread-safe
We still keep the window pointer, because we want to call
QQuickWindow::resetOpenGLState() (which runs on the rendering thread
only). Interesting mess...
2015-01-09 16:00:16 +01:00
wm4 803e579ff5 DOCS/client_api_examples: qml: reduce number of files
This is annoying.
2015-01-09 15:49:34 +01:00
wm4 7f2b78846b ao_alsa: fix dtshd passthrough
We must not try to remap channels with this. Whethever ALSA gives us,
and whatever we do with it, the result will probably be nonsense.

Untested, as I don't have the required hardware.
2015-01-09 03:58:47 +01:00
James Ross-Gowan f2fd0c48cc DOCS/compile-windows.md: fix pkg-config directory 2015-01-09 13:30:35 +11:00
Niklas Haas 286340d7d0 video: Add sigmoidal upscaling to avoid ringing artifacts
This avoids issues when upscaling directly in linear light, and is the
recommended way to upscale images according to imagemagick.

The default slope of 6.5 offers a reasonable compromise between
ringing artifacts eliminated and ringing artifacts introduced by
sigmoid-upscaling. Same goes for the default center of 0.75.
2015-01-09 03:18:21 +01:00
wm4 33dd9147ae demux_mkv: improve robustness against broken libavcodec parsers
The VP9 codec parser has a bug: it doesn't set the data/size pointers
passed to it. As I understand, it must always do this, and in fact, if
it doesn't some libavcodec generic code would be in trouble too.

This helps with #1448, but is not the full fix for it. The codec parser
must be fixed in libavcodec itself.
2015-01-09 02:10:42 +01:00
wm4 a37d75d497 tl_matroska: check chapter bounds
I have no idea what this does, but it's without doubt a sufficient fix
for the issue at hand.

Fixes #1445.
2015-01-09 01:47:48 +01:00
xylosper a4c0e254a3 vo_opengl_cb: make mpv_opengl_cb_render() return left frames
Instead of error code which was not helpful because it's always 0,
mpv_opengl_cb_render() returns the number of left frames in the
frame queue now.
2015-01-08 21:32:22 +01:00
xylosper e66acd52af vo_opengl_cb: use vo's drop_count instead of internal counter
This commit makes it possible to query dropped frames by opengl-cb
through vo-drop-frame-count property.
2015-01-08 21:15:24 +01:00
xylosper 5bb3b1b4cf vo: add functions to increment drop_count
Add two functions which increment drop_count thread-safely.
This is for the commit followed.
2015-01-08 21:15:09 +01:00
xylosper 5b4d587ede vo_opengl_cb: introduce frame queue
The previous implementation of opengl-cb kept only latest flipped frame.
This can cause massive frame drops because rendering is done asynchronously
and only the latest frame can be rendered.

This commit introduces frame queue and releated options to opengl-cb.

frame-queue-size: the maximum size of frame queue (1-100, default: 1)
frame-drop-mode: behavior when frame queue is full (pop, clear, default: pop)

The frame queue holds delayed frames and drops frames if the frame queue is
overflowed with next method:

'pop' mode: drops all the oldest frames overflown.
'clear' mode: drops all frames in queue and clear it.

With default options(frame-queue-size=1:frame-drop-mode=pop),
opengl-cb behaves in the same way as previous implementation effectively.

For frame-queue-size > 1, opengl-cb tries to calls update() without waiting
next flip_page() in order to consume queued frames.

Signed-off-by: wm4 <wm4@nowhere>
2015-01-08 18:50:25 +01:00
wm4 348ea46537 win32: minor simplification
The events parameter is not needed here and won't ever be.
2015-01-08 18:32:23 +01:00
wm4 f6e466585a vo_opengl: don't crash win32 backend with NULL events
vo_opengl was crashing since f811348d because it passed NULL for the
events parameter to vo_control. Normally the parameter should not be
NULL, so add a hack to account for this. In particular, we should
handle the events that are returned. For the call in preinit() we
skip this, but it most likely has no meaning anyway, because in this
stage no window is visible yet.
2015-01-08 18:30:19 +01:00
wm4 88c6f18209 vo_opengl_cb: fix a typo 2015-01-08 16:54:15 +01:00
wm4 41f6c15df5 vo_opengl_cb: allow changing debug option at runtime
This was always supposed to work.

Just add the option declaration. Normally I'm not a fan of duplicating
such things, but in this case it's (still) harmless.
2015-01-08 13:36:09 +01:00
James Ross-Gowan 54d14b4480 DOCS: add instructions for building with MSYS2
mpv can be built natively on a Windows machine using MSYS2. Add detailed
instructions on how to build and merge them with the existing
instructions for cross-compilation.
2015-01-08 19:29:55 +11:00
wm4 f551fbaa25 DOCS/client_api_examples: add an alternative qml example
This one avoids use of a FBO. It's less flexible, because it uses works
around the whole QML rendering API. It seems to be the only way to get
OpenGL rendering without any indirections, though.

Parts of this example were insipired by Qt's "Squircle" example.

Also add a README file with a short description of each example, to
reduce the initial confusing.
2015-01-08 02:40:30 +01:00
wm4 f52ec079b2 vo_opengl_cb: fix flipped rendering
Oops.
2015-01-08 02:19:12 +01:00
wm4 d6aac7f930 vo_opengl: gl_lcms: implement change detection for memory profiles
This affects OSX, where memory profiles are updated e.g. on fullscreen
switches. The profile most likely doesn't change, but the LUT will
be generated and reloaded anyway.

Somewhat of a regression from commit f811348.

Fixes #1439.
2015-01-08 01:03:09 +01:00
wm4 ae8a91d6b6 vo_opengl: gl_lcms: fix potential dangling pointer issue
If icc-path is set, but the thing is replaced with a memory profile,
then p->icc_path would point to deallocated memory.

Also, the NULL checks are unnecessary.
2015-01-08 00:56:21 +01:00
wm4 5a7719594e ao: remove coreaudio_exclusive from autoprobing list
Apparently this was a mistake.
2015-01-07 22:31:34 +01:00
wm4 dc2d0539c7 ao_pulse: disable latency calculation hacks by default
This used to be required to workaround PulseAudio bugs. Even later, when
the bugs were (partially?) fixed in PulseAudio, I had the feeling the
hacks gave better behavior. On the other hand, I couldn't actually
reproduce any bad behavior without the hacks lately. On top of this, it
seems our hacks sometimes perform much worse than PulseAudio's native
implementation (see #1430).

So disable the hacks by default, but still leave the code and the option
in case it still helps somewhere. Also, being able to blame PulseAudio's
code by using its native API is much easier than trying to debug our own
(mplayer2-derived) hacks.
2015-01-07 22:23:38 +01:00
wm4 02dbd41ae0 vo_direct3d: fix shader colormatrix generation
It was accidentally broken in d42d60bc1.
2015-01-07 22:08:20 +01:00
wm4 f61b8b312d win32: request UTF-16 API variants, Vista+ APIs, and COM C macros
Put the Vista+ (_WIN32_WINNT) and the COM C (COBJMACROS) defines into
the build system, instead of defining them over and over in the code.
2015-01-07 21:42:44 +01:00
wm4 5f398831d2 x11: always use glXGetProcAddressARB()
glXGetProcAddress() is outdated, and as far as I know doesn't give all
the guarantees the "new" ARB function gives.

Probably doesn't matter too much, because until now it always appeared
to work. On the other hand, since this function is (bogusly) used only
on the gl3 code path, it could have happened that users hit this, and
just reverted to vo_opengl_old instead.
2015-01-07 21:13:26 +01:00
wm4 aa8823c2d2 terminal: always print to stderr with --no-input-terminal
The function terminal_in_background() reports whether the player was
backgrounded. In this case, we don't want to annoy the user by still
printing the status to stderr. If no terminal interaction is assumed,
this mechanism is disabled, and stderr is always used. The read_terminal
variable signals this case.

Oddly, just redirecting stderr will disable output to stderr, because
the background check with tcgetpgrp() is done on stderr, but
read_terminal is still true (because that one depends on stdin and
stdout).

Explicitly disable this mechanism if --no-input-terminal is used by
setting read_terminal to true only if terminal input is actually
initialized.
2015-01-07 19:45:44 +01:00
xylosper 21000774bf gl_video.c: invalidate image_params in uninit_video()
When the given mp_image_params does not match with that of gl_video,
gl_video_config() always calls uninit_video() but calls init_video()
only if valid format is given.

Since uninit_video() does not change image_params of gl_video,
when the same params as the previous one is given to gl_video_config()
after gl_video is unitialized with invalid format, gl_video_config()
never calls init_video().

To prevent this, invalidate image_params of gl_video in uninit_video().
2015-01-07 19:22:54 +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