Compare commits

...
11 Commits
Author SHA1 Message Date
sfan5 349e437466 Release 0.34.1 2022-01-03 20:45:08 +01:00
Dudemanguy f47a055440 wayland: avoid doing unneccesary window resizes
Commits 04018c3061
cd7a7a1de8 introduced behavior that
updated window geometry during wayland events (specifically surface and
output). This is good but they also are too aggressive with
automatically resizing. For example, if a window is manually resized by
the user and then dragged to a different monitor with different geometry
than the initial monitor, mpv will automatically resize itself to the
window's resolution. The initial thought behind this logic was for
autofit to automatically readjust itself on a new monitor, but doing
that breaks other common use cases. An attempt could be made to
distinguish between autofit and a manual resize but that introduces a
lot of complexity for an edge case. It's better to simply not change the
window geometry here. Internal values are recalculated and scaled of
course, but wl->window_size and wl->geometry should not change.
2021-12-27 12:58:37 +01:00
sfan5 80c03b49bf subprocess: unblock/reset signals before running child process
During execve() ignored and blocked signals carry over to the child
process, though apparently for SIGCHLD (which the bug report was about)
this is implementation-defined.
fixes #9613
2021-12-19 15:58:12 +01:00
Niklas Haas e7fbc86d58 af_lavcac3enc: fix memory leak on no-op
Simply returning out of this function leaks avpkt, need to always "goto
done".

Rewrite the logic a bit to make it more clear what's going on (IMO).

Fixes #9593
2021-12-19 15:58:12 +01:00
Philip Langdale 85a4557369 vo_gpu: opengl: try and create context at version 440 again
nvidia follow the OpenGL spec very strictly, with two particular
consequences:

* They will give you the exact context version that you ask for,
  rather than the highest possible version that meets your request.
* They will hide extensions that the specs say require a higher
  version than you request, even if it's technically possible to
  provide the extension at lower versions.

In our case, we really want a variety of extensions, particularly
compute shaders that are only available in 4.2 or higher. That means
that we must explicitly include a high enough version in our list of
versions to check for us to be able to get a 'good' enough context.

As for which version? We restore the 4.4 version that we had in the
old version selection logic. This is the highest version we ever asked
for, and we have separate logic that clamps the GLSL version to 4.4,
so anything newer wouldn't make a difference.
2021-12-19 15:58:12 +01:00
Niklas Haas 7c0a9b8ff7 vo_gpu: opengl: fix wrong glMemoryBarrier
This call was completely wrong.
2021-12-19 15:58:12 +01:00
Dudemanguy f2bc9e4dd1 wayland: fix a potential segfault on surface enter
This possibility actually existed for years. The wayland protocol is
asynchronous and there's no restriction on when a compositor can send a
surface enter event. In mpv's case, the surface enter event is used to
set some vital things regarded geometry/scaling etc. However, this
implictly assumes that wl->current_output is actually initialized. The
vast majority of the time, vo_wayland_reconfig will happen first which
is where wl->current_output is, and should, be created. There's no
rule/law that the ordering of events will always occur in this order.
Plasma with certain auto-profile conditions can send the surface enter
event before mpv does its initial reconfig. That segfaults of course.
Just add a check to make sure we have wl->current_output here and return
if we don't. This assumes that the compositor will send us another
surface enterance event when mpv actually does the initial surface
commit and roundtrip request later. Wayland logs indicate this does
happen. Fixes #9492.
2021-12-19 15:58:12 +01:00
Aman Karmani f8b85dd65d audio: stop corrupting audio on underreads
regression introduced in b74c09efbf

Signed-off-by: Aman Karmani <aman@tmm1.net>
2021-12-19 15:56:50 +01:00
Dudemanguy bde10d2771 egl_helpers: remove EGL_OPENGL_ES3_BIT
d2e8bc4499 was the the commit that
originally introduced the usage of this bit. As the message states, the
purpose was to force creating GLES 3 contexts on drivers that do not
return a higher version context than what was requested. With the recent
opengl refactors, mpv's gl selection has already moved away from such
complicated queries. Perhaps when that commit was added things were
different, but nowadays it seems like Mesa simply returns the highest
driver version available that is compatibile with the request (i.e.
requesting GLES 2 returns a GLES 3 context on my machine). In that case,
let's just simply drop EGL_OPENGL_ES3_BIT altogether as it does break
GLES 2 only machines. Fixes #9431.
2021-12-19 15:53:30 +01:00
Jan Ekström 22c1468b5a ao_oss: define PATH_DEV_MIXER as it is an internal define
This fixes a mismatch between configure working and build time
failing with Linux + OSSv4, enabling compilation on Debian based
Linux systems with the oss4-dev package.

Fixes #9378
2021-12-19 15:53:25 +01:00
Dudemanguy 01843cf9e7 player: fix autofit/geometry related segfault
Back when runtime updating of autofit/geometry was added for wayland and
x11 (commits: 4445ac828dca0298543103094357e64f8828ef56 and
ced92ba607ebd98687b26ef3d8c09d5f6e22cf4b respectively), the naive
assumption was that window-related geometry would always be available.
While this is true 99% of the time, this isn't a guarentee. It is
possible for certain things such as loading shaders to delay starting up
the player. This causes autofit/geometry options to be registered as a
runtime update and triggers VOCTRL_VO_OPTS_CHANGED. This ends up calling
some geometry-related functions but this happens before the actual
values are available. Hence, a nullptr was accessed which segfaults. At
least one user experienced this with a combination of options in wayland
but in theory the same thing could happen under x11.

The fix is simple. Just be sure to check that the required geometry is
available before doing any calculations. In wayland, this would be
wl->current_output. Additionally add an assert to set_geometry (we
should never use this function without wl->current_output) to be extra
sure. In x11, the check is on x11->window. Later when the reconfig for
each backend actually happens, the autofit/geometry set by the user
happens anyway so ignoring it in this case does no harm. Fixes #9381.
2021-12-19 15:51:49 +01:00
11 changed files with 92 additions and 36 deletions

No files matched your search

+23 -3
View File
@@ -1,3 +1,23 @@
Release 0.34.1
==============
Bug fix release for the 0.34 branch.
Fixes and Minor Enhancements
----------------------------
- player: fix autofit/geometry related segfault
- ao_oss: add missing PATH_DEV_MIXER define
- egl_helpers: fix context creation if GLES 3 is not available
- audio: stop corrupting audio on underreads
- wayland: fix a potential segfault on surface enter
- vo_gpu: opengl: fix wrong glMemoryBarrier call
- vo_gpu: opengl: create context at version 4.4 again
- af_lavcac3enc: fix memory leak on no-op
- subprocess: unblock/reset signals before running child process
- wayland: avoid doing unneccesary window resizes
Release 0.34.0
==============
@@ -140,7 +160,7 @@ This listing is not complete. Check DOCS/client-api-changes.rst for a history
of changes to the client API, and DOCS/interface-changes.rst for a history
of changes to other user-visible interfaces.
A complete changelog can be seen by running `git log v0.33.0..v0.34.0`
A complete changelog can be seen by running `git log v0.33.0..v0.34.1`
in the git repository or by visiting either
https://github.com/mpv-player/mpv/compare/v0.33.0...v0.34.0 or
https://git.srsfckn.biz/mpv/log/?qt=range&q=v0.33.0..v0.34.0
https://github.com/mpv-player/mpv/compare/v0.33.0...v0.34.1 or
https://git.srsfckn.biz/mpv/log/?qt=range&q=v0.33.0..v0.34.1
+1 -1
View File
@@ -1 +1 @@
0.34.0
0.34.1
+19 -16
View File
@@ -163,46 +163,47 @@ static void process(struct mp_filter *f)
break;
if (lavc_ret < 0 && lavc_ret != AVERROR(EAGAIN)) {
MP_FATAL(f, "Encode failed (receive).\n");
goto done;
goto error;
}
}
AVFrame *frame = NULL;
struct mp_frame input = mp_pin_out_read(s->in_pin);
// The following code assumes no sample data buffering in the encoder.
if (input.type == MP_FRAME_EOF) {
switch (input.type) {
case MP_FRAME_NONE:
goto done; // no data yet
case MP_FRAME_EOF:
mp_pin_in_write(f->ppins[1], input);
return;
} else if (input.type == MP_FRAME_AUDIO) {
goto done;
case MP_FRAME_AUDIO:
TA_FREEP(&s->in_frame);
s->in_frame = input.data;
frame = mp_frame_to_av(input, NULL);
if (!frame)
goto done;
goto error;
if (mp_aframe_get_channels(s->in_frame) < s->opts->min_channel_num) {
// Just pass it through.
s->in_frame = NULL;
mp_pin_in_write(f->ppins[1], input);
return;
goto done;
}
if (!mp_aframe_config_equals(s->in_frame, s->cur_format)) {
if (!reinit(f))
goto done;
goto error;
}
} else if (input.type) {
goto done;
} else {
return; // no data yet
break;
default: goto error; // unexpected packet type
}
int lavc_ret = avcodec_send_frame(s->lavc_actx, frame);
av_frame_free(&frame);
if (lavc_ret < 0 && lavc_ret != AVERROR(EAGAIN)) {
MP_FATAL(f, "Encode failed (send).\n");
goto done;
goto error;
}
}
if (!s->in_frame)
goto done;
goto error;
out = mp_aframe_create();
mp_aframe_set_format(out, AF_FORMAT_S_AC3);
@@ -210,7 +211,7 @@ static void process(struct mp_filter *f)
mp_aframe_set_rate(out, 48000);
if (mp_aframe_pool_allocate(s->out_pool, out, s->out_samples) < 0)
goto done;
goto error;
int sstride = mp_aframe_get_sstride(out);
@@ -239,7 +240,7 @@ static void process(struct mp_filter *f)
uint8_t **planes = mp_aframe_get_data_rw(out);
if (!planes)
goto done;
goto error;
char *buf = planes[0];
memcpy(buf, hdr, header_len);
memcpy(buf + header_len, pkt.data, pkt.size);
@@ -250,8 +251,10 @@ static void process(struct mp_filter *f)
mp_pin_in_write(f->ppins[1], MAKE_FRAME(MP_FRAME_AUDIO, out));
out = NULL;
err = 0;
done:
err = false;
// fall through
error:
av_packet_unref(&pkt);
talloc_free(out);
if (err)
+1
View File
@@ -49,6 +49,7 @@
#endif
#define PATH_DEV_DSP "/dev/dsp"
#define PATH_DEV_MIXER "/dev/mixer"
struct priv {
int dsp_fd;
+2 -1
View File
@@ -162,7 +162,8 @@ static int read_buffer(struct ao *ao, void **data, int samples, bool *eof)
// pad with silence (underflow/paused/eof)
for (int n = 0; n < ao->num_planes; n++) {
af_fill_silence((char *)data[n] + pos, (samples - pos) * ao->sstride,
af_fill_silence((char *)data[n] + pos * ao->sstride,
(samples - pos) * ao->sstride,
ao->format);
}
+21
View File
@@ -33,6 +33,12 @@
extern char **environ;
#ifdef SIGRTMAX
#define SIGNAL_MAX SIGRTMAX
#else
#define SIGNAL_MAX 32
#endif
#define SAFE_CLOSE(fd) do { if ((fd) >= 0) close((fd)); (fd) = -1; } while (0)
// Async-signal-safe execvpe(). POSIX does not list it as async-signal-safe
@@ -65,6 +71,20 @@ static int as_execvpe(const char *path, const char *file, char *const argv[],
return -1;
}
// In the child process, resets the signal mask to defaults. Also clears any
// signal handlers first so nothing funny happens.
static void reset_signals_child(void)
{
struct sigaction sa = { 0 };
sigset_t sigmask;
sa.sa_handler = SIG_DFL;
sigemptyset(&sigmask);
for (int nr = 1; nr < SIGNAL_MAX; nr++)
sigaction(nr, &sa, NULL);
sigprocmask(SIG_SETMASK, &sigmask, NULL);
}
// Returns 0 on any error, valid PID on success.
// This function must be async-signal-safe, as it may be called from a fork().
static pid_t spawn_process(const char *path, struct mp_subprocess_opts *opts,
@@ -96,6 +116,7 @@ static pid_t spawn_process(const char *path, struct mp_subprocess_opts *opts,
}
if (fres == 0) {
// child
reset_signals_child();
for (int n = 0; n < opts->num_fds; n++) {
if (src_fds[n] == opts->fds[n].fd) {
+9
View File
@@ -23,6 +23,15 @@
// 0-terminated list of desktop GL versions a backend should try to
// initialize. Each entry is the minimum required version.
const int mpgl_min_required_gl_versions[] = {
/*
* Nvidia drivers will not provide the highest supported version
* when 320 core is requested. Instead, it just returns 3.2. This
* would be bad, as we actually want compute shaders that require
* 4.2, so we have to request a sufficiently high version. We use
* 440 to maximise driver compatibility as we don't need anything
* from newer versions.
*/
440,
320,
210,
0
+1 -2
View File
@@ -41,7 +41,6 @@
#define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1
#define EGL_OPENGL_ES3_BIT 0x00000040
typedef intptr_t EGLAttrib;
#endif
@@ -117,7 +116,7 @@ static bool create_context(struct ra_ctx *ctx, EGLDisplay display,
name = "Desktop OpenGL";
} else {
api = EGL_OPENGL_ES_API;
rend = EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT;
rend = EGL_OPENGL_ES2_BIT;
name = "GLES 2.x +";
}
+1 -1
View File
@@ -989,7 +989,7 @@ static void update_uniform(struct ra *ra, struct ra_renderpass *pass,
gl->BindBufferBase(buf_gl->target, input->binding, buf_gl->buffer);
// SSBOs are not implicitly coherent in OpengL
if (input->type == RA_VARTYPE_BUF_RW)
gl->MemoryBarrier(buf_gl->target);
gl->MemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
break;
}
default:
+11 -12
View File
@@ -653,9 +653,6 @@ static void output_handle_done(void* data, struct wl_output *wl_output)
}
spawn_cursor(wl);
set_geometry(wl);
wl->window_size = wl->vdparams;
if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized)
wl->geometry = wl->window_size;
wl->pending_vo_events |= VO_EVENT_DPI;
wl->pending_vo_events |= VO_EVENT_RESIZE;
}
@@ -685,6 +682,9 @@ static void surface_handle_enter(void *data, struct wl_surface *wl_surface,
struct wl_output *output)
{
struct vo_wayland_state *wl = data;
if (!wl->current_output)
return;
struct mp_rect old_output_geometry = wl->current_output->geometry;
struct mp_rect old_geometry = wl->geometry;
wl->current_output = NULL;
@@ -713,13 +713,9 @@ static void surface_handle_enter(void *data, struct wl_surface *wl_surface,
if (!mp_rect_equals(&old_output_geometry, &wl->current_output->geometry)) {
set_geometry(wl);
wl->window_size = wl->vdparams;
force_resize = true;
}
if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized)
wl->geometry = wl->window_size;
if (!mp_rect_equals(&old_geometry, &wl->geometry) || force_resize)
wl->pending_vo_events |= VO_EVENT_RESIZE;
@@ -1370,6 +1366,7 @@ static int set_cursor_visibility(struct vo_wayland_state *wl, bool on)
static void set_geometry(struct vo_wayland_state *wl)
{
struct vo *vo = wl->vo;
assert(wl->current_output);
struct vo_win_geometry geo;
struct mp_rect screenrc = wl->current_output->geometry;
@@ -1597,11 +1594,13 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg)
if (opt == &opts->geometry || opt == &opts->autofit ||
opt == &opts->autofit_smaller || opt == &opts->autofit_larger)
{
set_geometry(wl);
wl->window_size = wl->vdparams;
if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized)
wl->geometry = wl->window_size;
wl->pending_vo_events |= VO_EVENT_RESIZE;
if (wl->current_output) {
set_geometry(wl);
wl->window_size = wl->vdparams;
if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized)
wl->geometry = wl->window_size;
wl->pending_vo_events |= VO_EVENT_RESIZE;
}
}
}
return VO_TRUE;
+3
View File
@@ -1847,6 +1847,9 @@ static void vo_x11_set_geometry(struct vo *vo)
{
struct vo_x11_state *x11 = vo->x11;
if (!x11->window)
return;
if (x11->opts->window_maximized) {
x11->pending_geometry_change = true;
} else {