Commit Graph

46530 Commits

Author SHA1 Message Date
wm4 a1ed1f8be0 thread_pool: make it slightly less dumb
The existing thread pool code is the most primitive thread pool
possible. That's fine, but one annoying thing was that it used a static
number of threads. Make it dynamic, so we don't need to "waste" idle
threads.

This tries to add threads as needed. If threads are idle for some time,
destroy them again until a minimum number of threads is reached.

Also change the license to ISC.
2018-05-24 19:56:34 +02:00
wm4 a0308d3169 client: merge can_terminate() function
This has some tricky interactions. In particular, it requires the core
to be locked due to reading outstanding_async, which is documented on
the only caller only. It's probably better to merge it with its only
caller.

The new code should be strictly equivalent, other than the fact that it
doesn't temporarily unlock+lock when entering the loop for the first
time (which doesn't matter here).
2018-05-24 19:56:34 +02:00
wm4 22c002138d misc: add a synchronization helper
This is almost like rendezvous(), except it allows async wakeup, and
does not require global state. It will be used by a later commit.

struct mp_waiter is intended to be allocated on the stack, and uses an
initializer including PTHREAD_MUTEX_INITIALIZER. This is the first case
in mpv that it uses PTHREAD_MUTEX_INITIALIZER for stack-allocated
mutexes. It seems POSIX still does not allow this formally, but since
POSIX is worth less than used toilet paper, I don't really care. Modern
OSes use futexes, which means you can make _every_ memory location a
lock, and this code tries to make use of it, without using OS specific
code.

The name of the source file is rather generic, because I intend to dump
further small helpers there (or maybe move mp_rendezvous() to it).
2018-05-24 19:56:34 +02:00
wm4 383da1bfd5 input: move an enum back to its correct place
This was accidentally moved together with the cmd stuff.
2018-05-24 19:56:33 +02:00
wm4 dc00566963 command: handle list commands like normal commands
Pretty annoying.
2018-05-24 19:56:33 +02:00
wm4 88f9506f42 dispatch: add an assert() 2018-05-24 19:56:33 +02:00
wm4 95ab93d9f1 client API: some doxygen fixes/additions 2018-05-24 19:56:33 +02:00
Aman Gupta 814869759c demux, player: fix playback of sparse video streams (w/ still images)
Fixes several issues playing back mpegts with video streams marked
as having "still images". For example, see this video which has
frames only every 6s: https://s3.amazonaws.com/tmm1/music-choice.ts

Changes include:
- start playback right away, without waiting for first video frame
- do not consider the sparse video stream in demuxer underrun detection
- do not require multiple video frames for the VO
- use audio as the master stream for demuxer metadata events
- use audio stream for playback time

Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-24 10:26:41 -07:00
Aman Gupta b24bd4e570 demux_lavf: co-locate disposition checks
Signed-off-by: Aman Gupta <aman@tmm1.net>
2018-05-24 10:26:41 -07:00
Rostislav Pehlivanov d828887792 waf: require wayland-protocols >= 1.14
Needed for the new xdg-wm tiling enums.
2018-05-20 02:48:23 +03:00
Rostislav Pehlivanov 0b3d1d6faf wayland_common: require wl_compositor of version 3
We already did require it, in order to call set_buffer_scale. This
just makes it error out more gracefully.
2018-05-20 02:48:23 +03:00
Rostislav Pehlivanov 43d575616c wayland_common: fix maximized state
Window size should not change if the window has been maximized or tiled.
2018-05-20 02:48:23 +03:00
Niklas Haas 05b392bc94 vo_gpu: allow higher icc-contrast and improve logging
With the advent of actual HDR devices, my real measured ICC profile has
an "infinite" contrast, since the display is completely off on pure
black inputs. 100k:1 might not be enough, so let's just bump it up to
1m:1 to be safe.

Also, improve the logging in the case that the detected contrast is too
high by default.
2018-05-17 22:56:45 +03:00
sfan5 1f01c05fef stats: show sample format of audio track 2018-05-17 22:54:56 +03:00
Bin Jin d65b6cf077 waftools: update clang_compilation_database
The old copy is broken with waf-1.9.8, update to the latest commit
(waf-project/waf@5e4b86b81d) instead.
2018-05-17 13:23:26 +02:00
Niklas Haas c0eea89b4d manpage: fix typo 2018-05-17 13:19:25 +02:00
Niklas Haas 37ec321287 manpage: clarify target-prim/trc=auto behavior
This logic has been changed throughout the years, notably in 38ac5d5 and
3bdbf6. Update the documentation to reflect the current state.

Closes #5834.
2018-05-17 13:19:25 +02:00
Philip Sequeira e5b2af0a80 m_option: fix duplicate flag value 2018-05-13 14:04:00 +02:00
Philip Langdale 1b19ba6c57 wscript: Remove code check for cuda hwaccel
This was there originally to detect too-old versions of ffmpeg. We now
only support >= 4.0, so it's not relevant. We just need the dependencies
to be present.
2018-05-10 22:43:08 +03:00
Anton Kindestam a645c6b2ec drm_atomic: Fix memory leaks in drm_atomic_create
First fix a memory leak when skipping cursor planes by inverting the
check and putting everything, but the free, in the body.

Then fix a missed drmModeFreePlane by simply copying the fields of the
drmModePlane we are interested in and freeing the drmModePlane struct
early.
2018-05-08 02:24:40 +03:00
Ricardo Constantino 11289d5238 ytdl_hook: try to set video track first if available
Fixes `--ytdl-format="dash-fastly_skyfire-video-363357330+dash-fastly_skyfire_sep-audio-363357330" https://vimeo.com/108650530`

This happened because the video track also had audio available and after
adding it expecting an audio-only track, there were no more tracks with video.
2018-05-03 22:03:48 +03:00
Aman Gupta 98b8e60b14 player: add more logging around buffering state 2018-05-03 19:47:58 +03:00
wm4 7d8eee36a5 command: fix condition for failure when parsing cycle-value params
Could make it behave differently (and leak memory) in certain cases.
Basically, m_option_parse() randomly returns 0 or 1, but most time 1,
with the difference due to legacy reasons that don't matter anymore.
2018-05-03 01:20:01 +03:00
wm4 78fe41f246 command: simplify option property init
The "if (prop.name)" check is redundant, because an assert above it
implies that it never can be NULL.

Deduplicate some code for initializing the "prop" variable.
2018-05-03 01:20:01 +03:00
wm4 88498bcc92 input: rename weirdly named function 2018-05-03 01:20:01 +03:00
wm4 407f5b407a input: move some more cmd definitions to cmd.h
Now both command "descriptions" and runtime command instances are in
cmd.h, which makes sense to me. input.h is now for the actual input
context.
2018-05-03 01:20:01 +03:00
wm4 9fa0e6bf6a input: merge cmd_list.c with cmd.c
It doesn't really make sense to keep a separate cmd_list.c file, which
does _not_ contain a command list, but only a few minor helper
functions.
2018-05-03 01:20:01 +03:00
wm4 e5f884e68c input: rename cmd_parse.c to cmd.c
Done separately from the cmd.h rename to avoid issues with git being bad
at tracking mixed content and filename changes.
2018-05-03 01:20:01 +03:00
wm4 76d8683e2e input: rename cmd_parse.h to cmd.h 2018-05-03 01:20:01 +03:00
wm4 fb9bbf2a0d command: split big command handler switch into separate functions
This gets rid of run_command() and its big switch statement, which was
an idiotically big function of almost 1000 lines.

The switch is replaced with a callback per command, and each command is
now implemented in its own function. Command IDs are not needed anymore,
so the mp_command_type enum disappears.

There should be no functional changes, but since this refactors 64
commands, regressions are possible.

The handler() parameter is void*, because in theory the input code is
supposed to be independent of the player core code. For example, you
should be able to reuse the command parser code for some other part of
mpv. In practice, the variable containing command list is defined in the
player core anyway, so you could say this doesn't work. But I'm still
trying to hold onto this idea, so I went with void*.
2018-05-03 01:20:01 +03:00
wm4 e8b073584d input: remove some explicit uses of command IDs
The plan is to remove the command ID enum. This will happen by replacing
the big switch statement in command.c with dispatching to per-command
callbacks. As preparation, remove uses of the command IDs outside of the
actual dispatching mechanism.

Also remove some instances of checking cmd->def for NULL. We now require
this always to be set.
2018-05-03 01:20:01 +03:00
wm4 14602b0201 input: remove legacy command handling
These are old MPlayer commands that were redundant since 2007 or so. In
2013, mpv explicitly deprecated them (actually removed them, but left
this wrapper, which translated them to modern commands). The list was
not extended since 2013, and mpv always warned on the terminal when a
legacy command was used. So it's time to remove it.
2018-05-03 01:20:01 +03:00
wm4 b092bb0f11 input: move command list to command.c
Preparation for more changes.
2018-05-03 01:20:01 +03:00
TheAMM a469554594 encode: remove removed encode options from presets 2018-05-03 01:09:46 +03:00
wm4 e02c9b9902 build: make encoding mode non-optional
Makes it easier to not break the build by confusing the ifdeffery.
2018-05-03 01:08:44 +03:00
wm4 0ab3184526 encode: get rid of the output packet queue
Until recently, ao_lavc and vo_lavc started encoding whenever the core
happened to send them data. Since audio and video are not initialized at
the same time, and the muxer was not necessarily opened when the first
encoder started to produce data, the resulting packets were put into a
queue. As soon as the muxer was opened, the queue was flushed.

Change this to make the core wait with sending data until all encoders
are initialized. This has the advantage that we don't need to queue up
the packets.
2018-05-03 01:08:44 +03:00
wm4 958053ff56 vo_lavc: explicitly skip redraw and repeated frames
The user won't want to have those in the video (I think). The core can
sporadically issue redraws, which is what you want for actual playback,
but not in encode mode. vo_lavc can explicitly detect those and skip
them. It only requires switching to a more advanced internal VO API.

The comments in vo.h are because vo_lavc draws to one of the images in
order to render OSD. This is OK, but might come as a surprise to whoever
calls draw_frame, so document it. (Current callers are OK with it.)
2018-05-03 01:08:44 +03:00
wm4 1a339fa09d video: actually wait for last frame being rendered on EOF
The video timing code could just decide that EOF was reached before it
was displayed. This is not really a problem for normal playback (if you
use something like --keep-open it'd show the last frame anyway,
otherwise it'd at best flash it on screen before destroying the window).
But in encode mode, it really matters, and makes the difference between
having one frame more or less in the output file.

Fix this by waiting for the VO before starting the real EOF.
vo_is_ready_for_frame() is normally used to determine when the VO frame
queue has enough space to send a new frame. Since the VO frame queue is
currently at most 1 frame, it being signaled means the remaining frame
was consumed and thus sent to the VO driver. If it returns false, it
will wake up the playloop as soon as the state changes.

I also considered using vo_still_displaying(), but it's not reliable,
because it checks the realtime of the frame end display time.
2018-05-03 01:08:44 +03:00
wm4 f18c4175ad encode: remove old timestamp handling
This effectively makes --ocopyts the default. The --ocopyts option
itself is also removed, because it's redundant.
2018-05-03 01:08:44 +03:00
wm4 60dade1040 encode: restore 2-pass mode
While I'm not sure whether it really works, at least it writes the pass1
log correctly now.

How 2-pass stat output is supposed to interact with the new decode API
is rather fishy. ffmpeg.c does the same, and before this change, the
log was not written on EOF (when at least libvpx actually outputs its
stats).
2018-05-03 01:08:44 +03:00
wm4 e51cf79181 manpage: -pre, -del etc. does not work on some options anymore
With the internal change from stringlist to keyvaluelist, these
sub-options stop working. I don't really care enough to bring them
back. (Order doesn't matter, -del always seemed annoying.)
2018-05-03 01:08:44 +03:00
Jan Ekström 36b0dea89e docs/vo: fixup some minor typos a la "planed" instead of "plane" 2018-05-01 20:49:30 +03:00
Anton Kindestam a9c2a8e162 drm_atomic: Disallow selecting cursor planes using the options 2018-05-01 20:48:02 +03:00
Anton Kindestam 02d40eee1b drm_common: Be smarter when deciding on which CRTC and Encoder to use
Inspired by kmscube, first try to pick the Encoder and CRTC already
associated with the selected Connector, if any. Otherwise try to find
the first matching encoder & CRTC like before.

The previous behavior had problems when using atomic
modesetting (crtc_setup_atomic) when we picked an Encoder & CRTC that
was currently being used by the fbcon together with another Encoder.
drmModeSetCrtc was able to "steal" the CRTC in this case, but using
atomic modesetting we do not seem to get this behavior automatically.

This should also improve behavior somewhat when run on a multi screen
setup with regards to deinit and VT switching (still sometimes you end
up with a blank screen where you previously had a cloned display of
your fbcon)
2018-05-01 20:48:02 +03:00
Anton Kindestam 4c6f36611d context_drm_egl: fix some comments and log messages that had not been updated since the plane rename commit 2018-05-01 20:48:02 +03:00
Anton Kindestam e60728a622 drm/atomic: Fix crtc_setup_atomic and crtc_release_atomic
Add some properties which where forgotten in crtc_setup_atomic.

In both change to not use DRM_MODE_PAGE_FLIP_EVENT | DRM_MODE_ATOMIC_NONBLOCK
flags. This should make it more similar to the drmSetCrtc which it aims to
replace (take effect directly, and blocking call). This also saves us the
trouble of having to set up a poll to wait for pageflip, which would've been
neccesary with DRM_MODE_PAGE_FLIP_EVENT, in both crtc_setup_atomic and
crtc_release_atomic.
2018-05-01 20:48:02 +03:00
LongChair ba3d90d9ed drm/atomic: disable video plane when unused.
This patch will make sure that the video plane is hidden when unused.
When using high resolution modes, typically UHD, and embedding mpv,
having the video plane sitting in the back when you don't play any video
is eating a lot of memory bandwidth for compositing.

That patch makes sure that the video layer is just disabled before and
after playback.
2018-05-01 20:48:02 +03:00
LongChair 1ccc56eff0 drm/atomic: add atomic modesetting.
This commit allows to add atomic modesetting when using the atomic renderer.
This is actually needed when using and osd with a smaller size than screen resolution.

It will also make the drm atomic path more consistent
2018-05-01 20:48:02 +03:00
LongChair ed94f8dc00 drm/atomic: refactor planes names
We are currently using primary / overlay planes drm objects, assuming that primary plane is osd and overlay plane is video.
This commit is doing two things :
  - replace the primary / overlay planes members with osd and video planes member without the assumption
  - Add two more options to determine which one of the primary / overlay is associated to osd / video.
  - It will default osd to overlay and video to primary if unspecified
2018-05-01 20:48:02 +03:00
LongChair 49bc07faea drm/atomic: add connector to atomic context
This patch adds
  - DRM connector object to atomic context.
  - fd property to the drm atomic object as well as a method to read blob type properties.

This allows to ensure that the proper connector is picked up, especially when specifying it
from the commandline, and also allows to make sure we're using the right one when embedding
with interop into an application.
2018-05-01 20:48:02 +03:00