diff options
| author | Michael Forney <mforney@mforney.org> | 2022-09-06 23:31:52 -0700 |
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2022-09-07 16:00:07 -0700 |
| commit | 0e01791187d5a8d1e00eff3f90ba4dd09b7e6535 (patch) | |
| tree | f1d33671c9794902495e5883b830b8cf61f6c411 /pkg/mpv/patch | |
| parent | 569b21ba94f76e8d419fbc8375daef73cdb43583 (diff) | |
mpv: Update to 0.34.1
Diffstat (limited to 'pkg/mpv/patch')
8 files changed, 725 insertions, 145 deletions
diff --git a/pkg/mpv/patch/0001-Add-generated-ebml-sources.patch b/pkg/mpv/patch/0001-Add-generated-ebml-sources.patch index c14f7154..6cacc5e1 100644 --- a/pkg/mpv/patch/0001-Add-generated-ebml-sources.patch +++ b/pkg/mpv/patch/0001-Add-generated-ebml-sources.patch @@ -1,24 +1,24 @@ -From 4769ec9ec67b9f0b9d2afa0d0a0d1775877414e1 Mon Sep 17 00:00:00 2001 +From d1e11f91a28e4095ae11af36e9ed6d4bdadf6c3f Mon Sep 17 00:00:00 2001 From: Michael Forney <mforney@mforney.org> Date: Sat, 2 Jul 2016 17:32:27 -0700 Subject: [PATCH] Add generated ebml sources These require python to generate. -$ python TOOLS/matroska.py --generate-header > demux/ebml_types.h -$ python TOOLS/matroska.py --generate-definitions > demux/ebml_defs.c +$ python TOOLS/matroska.py --generate-header > demux/generated/ebml_types.h +$ python TOOLS/matroska.py --generate-definitions > demux/generated/ebml_defs.c --- - demux/ebml_defs.c | 574 ++++++++++++++++++++++++++++++++++++++++ - demux/ebml_types.h | 637 +++++++++++++++++++++++++++++++++++++++++++++ + demux/generated/ebml_defs.c | 574 +++++++++++++++++++++++++++++++ + demux/generated/ebml_types.h | 637 +++++++++++++++++++++++++++++++++++ 2 files changed, 1211 insertions(+) - create mode 100644 demux/ebml_defs.c - create mode 100644 demux/ebml_types.h + create mode 100644 demux/generated/ebml_defs.c + create mode 100644 demux/generated/ebml_types.h -diff --git a/demux/ebml_defs.c b/demux/ebml_defs.c +diff --git a/demux/generated/ebml_defs.c b/demux/generated/ebml_defs.c new file mode 100644 index 0000000000..db4eb9c2a7 --- /dev/null -+++ b/demux/ebml_defs.c ++++ b/demux/generated/ebml_defs.c @@ -0,0 +1,574 @@ +// Generated by TOOLS/matroska.py, do not edit manually + @@ -594,11 +594,11 @@ index 0000000000..db4eb9c2a7 +F(EBML_ID_DOCTYPEREADVERSION, doc_type_read_version, 0) +}}; +#undef N -diff --git a/demux/ebml_types.h b/demux/ebml_types.h +diff --git a/demux/generated/ebml_types.h b/demux/generated/ebml_types.h new file mode 100644 index 0000000000..d32af2d6c1 --- /dev/null -+++ b/demux/ebml_types.h ++++ b/demux/generated/ebml_types.h @@ -0,0 +1,637 @@ +// Generated by TOOLS/matroska.py, do not edit manually + @@ -1238,5 +1238,5 @@ index 0000000000..d32af2d6c1 + +#define MAX_EBML_SUBELEMENTS 23 -- -2.18.0 +2.35.1 diff --git a/pkg/mpv/patch/0002-Use-memset-to-initialize-large-structures.patch b/pkg/mpv/patch/0002-Use-memset-to-initialize-large-structures.patch index 4a1ab83f..ae3d43b5 100644 --- a/pkg/mpv/patch/0002-Use-memset-to-initialize-large-structures.patch +++ b/pkg/mpv/patch/0002-Use-memset-to-initialize-large-structures.patch @@ -1,4 +1,4 @@ -From c9c69a95d8724efdcd634d352234382e5c7dbd30 Mon Sep 17 00:00:00 2001 +From 5c6190de25762e04b4ee2b265760fd5b8afd115e Mon Sep 17 00:00:00 2001 From: Michael Forney <mforney@mforney.org> Date: Tue, 2 Jul 2019 17:41:43 -0700 Subject: [PATCH] Use memset to initialize large structures @@ -9,10 +9,10 @@ These are over 256 KiB in size. 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c -index 88a8557cc2..1264769a9a 100644 +index e4c4ee9290..0e15837d5e 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c -@@ -3496,7 +3496,7 @@ static void frame_perf_data(struct pass_info pass[], struct mp_frame_perf *out) +@@ -3514,7 +3514,7 @@ static void frame_perf_data(struct pass_info pass[], struct mp_frame_perf *out) void gl_video_perfdata(struct gl_video *p, struct voctrl_performance_data *out) { @@ -21,7 +21,7 @@ index 88a8557cc2..1264769a9a 100644 frame_perf_data(p->pass_fresh, &out->fresh); frame_perf_data(p->pass_redraw, &out->redraw); } -@@ -3927,14 +3927,13 @@ struct gl_video *gl_video_init(struct ra *ra, struct mp_log *log, +@@ -3955,14 +3955,13 @@ struct gl_video *gl_video_init(struct ra *ra, struct mp_log *log, struct mpv_global *g) { struct gl_video *p = talloc_ptrtype(NULL, p); @@ -44,5 +44,5 @@ index 88a8557cc2..1264769a9a 100644 p->pass = p->pass_fresh; struct gl_video_opts *opts = p->opts_cache->opts; -- -2.25.0 +2.35.1 diff --git a/pkg/mpv/patch/0003-video-out-gpu-Prevent-empty-array-when-no-compilers-.patch b/pkg/mpv/patch/0003-video-out-gpu-Prevent-empty-array-when-no-compilers-.patch index d3b7be6b..862f2caa 100644 --- a/pkg/mpv/patch/0003-video-out-gpu-Prevent-empty-array-when-no-compilers-.patch +++ b/pkg/mpv/patch/0003-video-out-gpu-Prevent-empty-array-when-no-compilers-.patch @@ -1,28 +1,37 @@ -From 30a85ce789cd15dedd7abd60ed36f74212068a31 Mon Sep 17 00:00:00 2001 +From 25a7c939446a456b258e889013a1f3136199f09b Mon Sep 17 00:00:00 2001 From: Michael Forney <mforney@mforney.org> Date: Wed, 3 Jul 2019 02:21:16 -0700 Subject: [PATCH] video/out/gpu: Prevent empty array when no compilers or contexts are enabled --- - video/out/gpu/context.c | 9 +++++---- - video/out/gpu/spirv.c | 1 + - 2 files changed, 6 insertions(+), 4 deletions(-) + video/out/gpu/context.c | 11 ++++++----- + video/out/gpu/spirv.c | 1 + + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/video/out/gpu/context.c b/video/out/gpu/context.c -index 9561b534d8..f73d0674be 100644 +index 6e58cce485..0e68c45b91 100644 --- a/video/out/gpu/context.c +++ b/video/out/gpu/context.c -@@ -108,6 +108,7 @@ static const struct ra_ctx_fns *contexts[] = { - #endif +@@ -110,6 +110,7 @@ static const struct ra_ctx_fns *contexts[] = { + &ra_ctx_vulkan_display, #endif + NULL }; - int ra_ctx_validate_api(struct mp_log *log, const struct m_option *opt, -@@ -122,7 +123,7 @@ int ra_ctx_validate_api(struct mp_log *log, const struct m_option *opt, - } + int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt, +@@ -117,7 +118,7 @@ int ra_ctx_api_help(struct mp_log *log, const struct m_option *opt, + { + mp_info(log, "GPU APIs (contexts):\n"); + mp_info(log, " auto (autodetect)\n"); +- for (int n = 0; n < MP_ARRAY_SIZE(contexts); n++) ++ for (int n = 0; n < MP_ARRAY_SIZE(contexts) - 1; n++) + mp_info(log, " %s (%s)\n", contexts[n]->type, contexts[n]->name); + return M_OPT_EXIT; + } +@@ -128,7 +129,7 @@ int ra_ctx_validate_api(struct mp_log *log, const struct m_option *opt, + struct bstr param = bstr0(*value); if (bstr_equals0(param, "auto")) return 1; - for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) { @@ -30,15 +39,17 @@ index 9561b534d8..f73d0674be 100644 if (bstr_equals0(param, contexts[i]->type)) return 1; } -@@ -135,13 +136,13 @@ int ra_ctx_validate_context(struct mp_log *log, const struct m_option *opt, - if (bstr_equals0(param, "help")) { - mp_info(log, "GPU contexts (APIs):\n"); - mp_info(log, " auto (autodetect)\n"); -- for (int n = 0; n < MP_ARRAY_SIZE(contexts); n++) -+ for (int n = 0; n < MP_ARRAY_SIZE(contexts) - 1; n++) - mp_info(log, " %s (%s)\n", contexts[n]->name, contexts[n]->type); - return M_OPT_EXIT; - } +@@ -140,7 +141,7 @@ int ra_ctx_context_help(struct mp_log *log, const struct m_option *opt, + { + mp_info(log, "GPU contexts (APIs):\n"); + mp_info(log, " auto (autodetect)\n"); +- for (int n = 0; n < MP_ARRAY_SIZE(contexts); n++) ++ for (int n = 0; n < MP_ARRAY_SIZE(contexts) - 1; n++) + mp_info(log, " %s (%s)\n", contexts[n]->name, contexts[n]->type); + return M_OPT_EXIT; + } +@@ -151,7 +152,7 @@ int ra_ctx_validate_context(struct mp_log *log, const struct m_option *opt, + struct bstr param = bstr0(*value); if (bstr_equals0(param, "auto")) return 1; - for (int i = 0; i < MP_ARRAY_SIZE(contexts); i++) { @@ -46,7 +57,7 @@ index 9561b534d8..f73d0674be 100644 if (bstr_equals0(param, contexts[i]->name)) return 1; } -@@ -166,7 +167,7 @@ struct ra_ctx *ra_ctx_create(struct vo *vo, const char *context_type, +@@ -176,7 +177,7 @@ struct ra_ctx *ra_ctx_create(struct vo *vo, const char *context_type, bool old_probing = vo->probing; vo->probing = opts.probing; @@ -56,7 +67,7 @@ index 9561b534d8..f73d0674be 100644 continue; if (!api_auto && strcmp(contexts[i]->type, context_type) != 0) diff --git a/video/out/gpu/spirv.c b/video/out/gpu/spirv.c -index ee11d601a3..87596ba5e3 100644 +index 67088bc7df..69100497eb 100644 --- a/video/out/gpu/spirv.c +++ b/video/out/gpu/spirv.c @@ -16,6 +16,7 @@ static const struct spirv_compiler_fns *compilers[] = { @@ -68,5 +79,5 @@ index ee11d601a3..87596ba5e3 100644 static const struct m_opt_choice_alternatives compiler_choices[] = { -- -2.23.0 +2.35.1 diff --git a/pkg/mpv/patch/0004-ao_sndio-add-this-audio-output-again.patch b/pkg/mpv/patch/0004-ao_sndio-add-this-audio-output-again.patch new file mode 100644 index 00000000..5f1c47af --- /dev/null +++ b/pkg/mpv/patch/0004-ao_sndio-add-this-audio-output-again.patch @@ -0,0 +1,413 @@ +From eb7c5d6fc8de657776c736458f426beb274b5523 Mon Sep 17 00:00:00 2001 +From: rim <rozhuk.im@gmail.com> +Date: Wed, 25 Nov 2020 06:10:19 +0300 +Subject: [PATCH] ao_sndio: add this audio output again + +Changes: +- rewrite to use new internal MPV API; +- code refactoring; +- fix buffers size calculations; +- buffer set to auto; +- reset() - clean/reinit device only after errors; +--- + DOCS/man/ao.rst | 6 + + audio/out/ao.c | 4 + + audio/out/ao_sndio.c | 317 +++++++++++++++++++++++++++++++++++++++++++ + wscript | 6 + + wscript_build.py | 1 + + 5 files changed, 334 insertions(+) + create mode 100644 audio/out/ao_sndio.c + +diff --git a/DOCS/man/ao.rst b/DOCS/man/ao.rst +index 1c0b9e146b..97c213a5dd 100644 +--- a/DOCS/man/ao.rst ++++ b/DOCS/man/ao.rst +@@ -219,5 +219,11 @@ Available audio output drivers are: + ``no-waveheader`` option - with ``waveheader`` it's broken, because + it will write a WAVE header every time the file is opened. + ++``sndio`` ++ Audio output to the OpenBSD sndio sound system ++ ++ (Note: only supports mono, stereo, 4.0, 5.1 and 7.1 channel ++ layouts.) ++ + ``wasapi`` + Audio output to the Windows Audio Session API. +diff --git a/audio/out/ao.c b/audio/out/ao.c +index 7c347cb138..950f935c81 100644 +--- a/audio/out/ao.c ++++ b/audio/out/ao.c +@@ -41,6 +41,7 @@ extern const struct ao_driver audio_out_audiounit; + extern const struct ao_driver audio_out_coreaudio; + extern const struct ao_driver audio_out_coreaudio_exclusive; + extern const struct ao_driver audio_out_rsound; ++extern const struct ao_driver audio_out_sndio; + extern const struct ao_driver audio_out_pulse; + extern const struct ao_driver audio_out_jack; + extern const struct ao_driver audio_out_openal; +@@ -87,6 +88,9 @@ static const struct ao_driver * const audio_out_drivers[] = { + #endif + #if HAVE_SDL2_AUDIO + &audio_out_sdl, ++#endif ++#if HAVE_SNDIO ++ &audio_out_sndio, + #endif + &audio_out_null, + #if HAVE_COREAUDIO +diff --git a/audio/out/ao_sndio.c b/audio/out/ao_sndio.c +new file mode 100644 +index 0000000000..4a6f49ee58 +--- /dev/null ++++ b/audio/out/ao_sndio.c +@@ -0,0 +1,317 @@ ++/* ++ * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> ++ * Copyright (c) 2013 Christian Neukirchen <chneukirchen@gmail.com> ++ * Copyright (c) 2020 Rozhuk Ivan <rozhuk.im@gmail.com> ++ * ++ * Permission to use, copy, modify, and distribute this software for any ++ * purpose with or without fee is hereby granted, provided that the above ++ * copyright notice and this permission notice appear in all copies. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ */ ++ ++#include "config.h" ++ ++#include <sys/types.h> ++#include <poll.h> ++#include <errno.h> ++#include <sndio.h> ++ ++#include "options/m_option.h" ++#include "common/msg.h" ++ ++#include "audio/format.h" ++#include "ao.h" ++#include "internal.h" ++ ++struct priv { ++ struct sio_hdl *hdl; ++ struct sio_par par; ++ int delay; ++ bool playing; ++ int vol; ++ int havevol; ++ struct pollfd *pfd; ++}; ++ ++ ++static const struct mp_chmap sndio_layouts[MP_NUM_CHANNELS + 1] = { ++ {0}, /* empty */ ++ {1, {MP_SPEAKER_ID_FL}}, /* mono */ ++ MP_CHMAP2(FL, FR), /* stereo */ ++ {0}, /* 2.1 */ ++ MP_CHMAP4(FL, FR, BL, BR), /* 4.0 */ ++ {0}, /* 5.0 */ ++ MP_CHMAP6(FL, FR, BL, BR, FC, LFE), /* 5.1 */ ++ {0}, /* 6.1 */ ++ MP_CHMAP8(FL, FR, BL, BR, FC, LFE, SL, SR), /* 7.1 */ ++ /* Above is the fixed channel assignment for sndio, since we need to ++ * fill all channels and cannot insert silence, not all layouts are ++ * supported. ++ * NOTE: MP_SPEAKER_ID_NA could be used to add padding channels. */ ++}; ++ ++static void uninit(struct ao *ao); ++ ++ ++/* Make libsndio call movecb(). */ ++static void process_events(struct ao *ao) ++{ ++ struct priv *p = ao->priv; ++ ++ if (!p->playing) ++ return; ++ int n = sio_pollfd(p->hdl, p->pfd, POLLOUT); ++ while (poll(p->pfd, n, 0) < 0 && errno == EINTR) {} ++ ++ sio_revents(p->hdl, p->pfd); ++} ++ ++/* Call-back invoked to notify of the hardware position. */ ++static void movecb(void *addr, int delta) ++{ ++ struct ao *ao = addr; ++ struct priv *p = ao->priv; ++ ++ p->delay -= delta; ++} ++ ++/* Call-back invoked to notify about volume changes. */ ++static void volcb(void *addr, unsigned newvol) ++{ ++ struct ao *ao = addr; ++ struct priv *p = ao->priv; ++ ++ p->vol = newvol; ++} ++ ++static int init(struct ao *ao) ++{ ++ struct priv *p = ao->priv; ++ struct mp_chmap_sel sel = {0}; ++ size_t i; ++ struct af_to_par { ++ int format, bits, sig; ++ }; ++ static const struct af_to_par af_to_par[] = { ++ {AF_FORMAT_U8, 8, 0}, ++ {AF_FORMAT_S16, 16, 1}, ++ {AF_FORMAT_S32, 32, 1}, ++ }; ++ const struct af_to_par *ap; ++ const char *device = ((ao->device) ? ao->device : SIO_DEVANY); ++ ++ /* Opening device. */ ++ MP_VERBOSE(ao, "Using '%s' audio device.\n", device); ++ p->hdl = sio_open(device, SIO_PLAY, 0); ++ if (p->hdl == NULL) { ++ MP_ERR(ao, "Can't open audio device %s.\n", device); ++ goto err_out; ++ } ++ ++ sio_initpar(&p->par); ++ ++ /* Selecting sound format. */ ++ ao->format = af_fmt_from_planar(ao->format); ++ for (i = 0, ap = af_to_par;; i++, ap++) { ++ if (i == MP_ARRAY_SIZE(af_to_par)) { ++ MP_VERBOSE(ao, "unsupported format\n"); ++ p->par.bits = 16; ++ p->par.sig = 1; ++ p->par.le = SIO_LE_NATIVE; ++ break; ++ } ++ if (ap->format == ao->format) { ++ p->par.bits = ap->bits; ++ p->par.sig = ap->sig; ++ if (ap->bits > 8) ++ p->par.le = SIO_LE_NATIVE; ++ if (ap->bits != SIO_BPS(ap->bits)) ++ p->par.bps = ap->bits / 8; ++ break; ++ } ++ } ++ ++ p->par.rate = ao->samplerate; ++ ++ /* Channels count. */ ++ for (i = 0; i < MP_ARRAY_SIZE(sndio_layouts); i++) { ++ mp_chmap_sel_add_map(&sel, &sndio_layouts[i]); ++ } ++ if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels)) ++ goto err_out; ++ ++ p->par.pchan = ao->channels.num; ++#ifdef __FreeBSD__ ++ /* OSS wrapper have bad defaults, overwrite it. */ ++ p->par.appbufsz = ((p->par.rate * 25) / 1000); /* 25 ms. */ ++#endif ++ if (!sio_setpar(p->hdl, &p->par)) { ++ MP_ERR(ao, "couldn't set params\n"); ++ goto err_out; ++ } ++ ++ /* Get current sound params. */ ++ if (!sio_getpar(p->hdl, &p->par)) { ++ MP_ERR(ao, "couldn't get params\n"); ++ goto err_out; ++ } ++ if (p->par.bps > 1 && p->par.le != SIO_LE_NATIVE) { ++ MP_ERR(ao, "swapped endian output not supported\n"); ++ goto err_out; ++ } ++ ++ /* Update sound params. */ ++ if (p->par.bits == 8 && p->par.bps == 1 && !p->par.sig) { ++ ao->format = AF_FORMAT_U8; ++ } else if (p->par.bits == 16 && p->par.bps == 2 && p->par.sig) { ++ ao->format = AF_FORMAT_S16; ++ } else if ((p->par.bits == 32 || p->par.msb) && p->par.bps == 4 && p->par.sig) { ++ ao->format = AF_FORMAT_S32; ++ } else { ++ MP_ERR(ao, "couldn't set format\n"); ++ goto err_out; ++ } ++ ++ p->havevol = sio_onvol(p->hdl, volcb, ao); ++ sio_onmove(p->hdl, movecb, ao); ++ ++ p->pfd = calloc(sio_nfds(p->hdl), sizeof(struct pollfd)); ++ if (!p->pfd) ++ goto err_out; ++ ++ ao->device_buffer = p->par.bufsz; ++ MP_VERBOSE(ao, "bufsz = %i, appbufsz = %i, round = %i\n", ++ p->par.bufsz, p->par.appbufsz, p->par.round); ++ ++ p->delay = 0; ++ p->playing = false; ++ if (!sio_start(p->hdl)) { ++ MP_ERR(ao, "start: sio_start() fail.\n"); ++ goto err_out; ++ } ++ ++ return 0; ++ ++err_out: ++ uninit(ao); ++ return -1; ++} ++ ++static void uninit(struct ao *ao) ++{ ++ struct priv *p = ao->priv; ++ ++ if (p->hdl) { ++ sio_close(p->hdl); ++ p->hdl = NULL; ++ } ++ free(p->pfd); ++ p->pfd = NULL; ++ p->playing = false; ++} ++ ++static int control(struct ao *ao, enum aocontrol cmd, void *arg) ++{ ++ struct priv *p = ao->priv; ++ ao_control_vol_t *vol = arg; ++ ++ switch (cmd) { ++ case AOCONTROL_GET_VOLUME: ++ if (!p->havevol) ++ return CONTROL_FALSE; ++ vol->left = vol->right = p->vol * 100 / SIO_MAXVOL; ++ break; ++ case AOCONTROL_SET_VOLUME: ++ if (!p->havevol) ++ return CONTROL_FALSE; ++ sio_setvol(p->hdl, vol->left * SIO_MAXVOL / 100); ++ break; ++ default: ++ return CONTROL_UNKNOWN; ++ } ++ return CONTROL_OK; ++} ++ ++static void reset(struct ao *ao) ++{ ++ struct priv *p = ao->priv; ++ ++ process_events(ao); ++ p->delay = 0; ++ p->playing = false; ++ ++ /* XXX: some times may block here then sndiod used. */ ++ if (!sio_stop(p->hdl)) { ++ MP_ERR(ao, "reset: couldn't sio_stop()\n"); ++reinit: ++ /* Without this device will never work again. */ ++ MP_WARN(ao, "Force reinitialize audio device.\n"); ++ uninit(ao); ++ init(ao); ++ return; ++ } ++ if (!sio_start(p->hdl)) { ++ MP_ERR(ao, "reset: sio_start() fail.\n"); ++ goto reinit; ++ } ++} ++ ++static void start(struct ao *ao) ++{ ++ struct priv *p = ao->priv; ++ ++ p->playing = true; ++ process_events(ao); ++} ++ ++static bool audio_write(struct ao *ao, void **data, int samples) ++{ ++ struct priv *p = ao->priv; ++ const size_t size = (samples * ao->sstride); ++ size_t rc; ++ ++ rc = sio_write(p->hdl, data[0], size); ++ if (rc != size) { ++ MP_WARN(ao, "audio_write: unexpected partial write: required: %zu, written: %zu.\n", ++ size, rc); ++ reset(ao); ++ p->playing = false; ++ return false; ++ } ++ p->delay += samples; ++ process_events(ao); ++ ++ return true; ++} ++ ++static void get_state(struct ao *ao, struct mp_pcm_state *state) ++{ ++ struct priv *p = ao->priv; ++ ++ process_events(ao); ++ ++ state->free_samples = (ao->device_buffer - p->delay); ++ state->queued_samples = p->delay; ++ state->delay = (p->delay / (double)p->par.rate); ++ state->playing = p->playing; ++} ++ ++const struct ao_driver audio_out_sndio = { ++ .name = "sndio", ++ .description = "sndio audio output", ++ .init = init, ++ .uninit = uninit, ++ .control = control, ++ .reset = reset, ++ .start = start, ++ .write = audio_write, ++ .get_state = get_state, ++ .priv_size = sizeof(struct priv), ++}; +diff --git a/wscript b/wscript +index b44adc2ad4..eeb38f127f 100644 +--- a/wscript ++++ b/wscript +@@ -434,6 +434,12 @@ audio_output_features = [ + 'desc': 'OSSv4 audio output', + 'func': check_statement(['sys/soundcard.h'], 'int x = SNDCTL_DSP_SETPLAYVOL'), + 'deps': 'posix && gpl', ++ }, { ++ 'name': '--sndio', ++ 'desc': 'sndio audio input/output', ++ 'func': check_statement('sndio.h', ++ 'struct sio_par par; sio_initpar(&par); const char *s = SIO_DEVANY', lib='sndio'), ++ 'default': 'disable' + }, { + 'name': '--pulse', + 'desc': 'PulseAudio audio output', +diff --git a/wscript_build.py b/wscript_build.py +index 384bb50d2e..8244dbe3d3 100644 +--- a/wscript_build.py ++++ b/wscript_build.py +@@ -248,6 +248,7 @@ def build(ctx): + ( "audio/out/ao_pcm.c" ), + ( "audio/out/ao_pulse.c", "pulse" ), + ( "audio/out/ao_sdl.c", "sdl2-audio" ), ++ ( "audio/out/ao_sndio.c", "sndio" ), + ( "audio/out/ao_wasapi.c", "wasapi" ), + ( "audio/out/ao_wasapi_changenotify.c", "wasapi" ), + ( "audio/out/ao_wasapi_utils.c", "wasapi" ), +-- +2.35.1 + diff --git a/pkg/mpv/patch/0004-ytdl_hook.lua-search-for-yt-dlp-by-default.patch b/pkg/mpv/patch/0004-ytdl_hook.lua-search-for-yt-dlp-by-default.patch deleted file mode 100644 index 9fc40dac..00000000 --- a/pkg/mpv/patch/0004-ytdl_hook.lua-search-for-yt-dlp-by-default.patch +++ /dev/null @@ -1,106 +0,0 @@ -From 050f86d1aafff0059d7254f356275fa33e123d60 Mon Sep 17 00:00:00 2001 -From: Guido Cella <guido@guidocella.xyz> -Date: Fri, 17 Sep 2021 09:37:09 +0200 -Subject: [PATCH] ytdl_hook.lua: search for yt-dlp by default - -Because youtube-dl is inactive and the yt-dlp fork is becoming more -popular, make mpv use yt-dlp without any extra configuration. - -yt-dlp is ordered before youtube-dl because it's more obscure, so users -who have yt-dlp installed are more likely to want to use it rather than -youtube-dl. - -Fixes #9208. ---- - player/lua/ytdl_hook.lua | 53 +++++++++++++++++++++++++++++----------- - 1 file changed, 39 insertions(+), 14 deletions(-) - -diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua -index 7e77eb01ba..8d841f24d5 100644 ---- a/player/lua/ytdl_hook.lua -+++ b/player/lua/ytdl_hook.lua -@@ -10,7 +10,8 @@ local o = { - options.read_options(o) - - local ytdl = { -- path = "youtube-dl", -+ path = "", -+ paths_to_search = {"yt-dlp", "yt-dlp_x86", "youtube-dl"}, - searched = false, - blacklisted = {} - } -@@ -29,7 +30,13 @@ local safe_protos = Set { - "data" - } - -+local function platform_is_windows() -+ return package.config:sub(1,1) == "\\" -+end -+ - local function exec(args) -+ msg.debug("Running: " .. table.concat(args, " ")) -+ - local ret = mp.command_native({name = "subprocess", - args = args, - capture_stdout = true, -@@ -472,17 +479,6 @@ end - function run_ytdl_hook(url) - local start_time = os.clock() - -- -- check for youtube-dl in mpv's config dir -- if not (ytdl.searched) then -- local exesuf = (package.config:sub(1,1) == '\\') and '.exe' or '' -- local ytdl_mcd = mp.find_config_file("youtube-dl" .. exesuf) -- if not (ytdl_mcd == nil) then -- msg.verbose("found youtube-dl at: " .. ytdl_mcd) -- ytdl.path = ytdl_mcd -- end -- ytdl.searched = true -- end -- - -- strip ytdl:// - if (url:find("ytdl://") == 1) then - url = url:sub(8) -@@ -534,8 +530,37 @@ function run_ytdl_hook(url) - end - table.insert(command, "--") - table.insert(command, url) -- msg.debug("Running: " .. table.concat(command,' ')) -- local es, json, result, aborted = exec(command) -+ -+ local es, json, result, aborted -+ if ytdl.searched then -+ es, json, result, aborted = exec(command) -+ else -+ for _, path in pairs(ytdl.paths_to_search) do -+ -- search for youtube-dl in mpv's config dir -+ local exesuf = platform_is_windows() and ".exe" or "" -+ local ytdl_cmd = mp.find_config_file(path .. exesuf) -+ if ytdl_cmd then -+ msg.verbose("Found youtube-dl at: " .. ytdl_cmd) -+ ytdl.path = ytdl_cmd -+ command[1] = ytdl.path -+ es, json, result, aborted = exec(command) -+ break -+ else -+ msg.verbose("No youtube-dl found with path " .. path .. exesuf .. " in config directories") -+ command[1] = path -+ es, json, result, aborted = exec(command) -+ if result.error_string == "init" then -+ msg.verbose("youtube-dl with path " .. path .. exesuf .. " not found in PATH or not enough permissions") -+ else -+ msg.verbose("Found youtube-dl with path " .. path .. exesuf .. " in PATH") -+ ytdl.path = path -+ break -+ end -+ end -+ end -+ -+ ytdl.searched = true -+ end - - if aborted then - return --- -2.34.0 - diff --git a/pkg/mpv/patch/0005-ao_sndio-bugfix-and-small-refactoring-for-8314.patch b/pkg/mpv/patch/0005-ao_sndio-bugfix-and-small-refactoring-for-8314.patch new file mode 100644 index 00000000..7f86a979 --- /dev/null +++ b/pkg/mpv/patch/0005-ao_sndio-bugfix-and-small-refactoring-for-8314.patch @@ -0,0 +1,199 @@ +From d3e06b98678b5cde1330476b92def52df31ed344 Mon Sep 17 00:00:00 2001 +From: Andrew Krasavin <noiseless-ak@yandex.ru> +Date: Tue, 11 Jan 2022 19:23:52 +0300 +Subject: [PATCH] ao_sndio: bugfix and small refactoring for #8314 + +Changes: + * fixed hangups in the loop function and in some other cases + * refactoring according to @michaelforney's recommendations in #8314 + * a few minor and/or cosmetic changes + * ability to build ao_sndio using meson +--- + audio/out/ao_sndio.c | 87 ++++++++++++++++++++++---------------------- + wscript | 3 +- + 2 files changed, 45 insertions(+), 45 deletions(-) + +diff --git a/audio/out/ao_sndio.c b/audio/out/ao_sndio.c +index 4a6f49ee58..6dc1d5ca9e 100644 +--- a/audio/out/ao_sndio.c ++++ b/audio/out/ao_sndio.c +@@ -2,6 +2,7 @@ + * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> + * Copyright (c) 2013 Christian Neukirchen <chneukirchen@gmail.com> + * Copyright (c) 2020 Rozhuk Ivan <rozhuk.im@gmail.com> ++ * Copyright (c) 2021 Andrew Krasavin <noiseless-ak@yandex.ru> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above +@@ -41,7 +42,7 @@ struct priv { + }; + + +-static const struct mp_chmap sndio_layouts[MP_NUM_CHANNELS + 1] = { ++static const struct mp_chmap sndio_layouts[] = { + {0}, /* empty */ + {1, {MP_SPEAKER_ID_FL}}, /* mono */ + MP_CHMAP2(FL, FR), /* stereo */ +@@ -64,11 +65,9 @@ static void uninit(struct ao *ao); + static void process_events(struct ao *ao) + { + struct priv *p = ao->priv; +- +- if (!p->playing) +- return; ++ + int n = sio_pollfd(p->hdl, p->pfd, POLLOUT); +- while (poll(p->pfd, n, 0) < 0 && errno == EINTR) {} ++ while (poll(p->pfd, n, 0) < 0 && errno == EINTR); + + sio_revents(p->hdl, p->pfd); + } +@@ -119,21 +118,15 @@ static int init(struct ao *ao) + + /* Selecting sound format. */ + ao->format = af_fmt_from_planar(ao->format); +- for (i = 0, ap = af_to_par;; i++, ap++) { +- if (i == MP_ARRAY_SIZE(af_to_par)) { +- MP_VERBOSE(ao, "unsupported format\n"); +- p->par.bits = 16; +- p->par.sig = 1; +- p->par.le = SIO_LE_NATIVE; +- break; +- } ++ ++ p->par.bits = 16; ++ p->par.sig = 1; ++ p->par.le = SIO_LE_NATIVE; ++ for (i = 0; i < MP_ARRAY_SIZE(af_to_par); i++) { ++ ap = &af_to_par[i]; + if (ap->format == ao->format) { + p->par.bits = ap->bits; + p->par.sig = ap->sig; +- if (ap->bits > 8) +- p->par.le = SIO_LE_NATIVE; +- if (ap->bits != SIO_BPS(ap->bits)) +- p->par.bps = ap->bits / 8; + break; + } + } +@@ -148,10 +141,9 @@ static int init(struct ao *ao) + goto err_out; + + p->par.pchan = ao->channels.num; +-#ifdef __FreeBSD__ +- /* OSS wrapper have bad defaults, overwrite it. */ +- p->par.appbufsz = ((p->par.rate * 25) / 1000); /* 25 ms. */ +-#endif ++ p->par.appbufsz = p->par.rate * 250 / 1000; /* 250ms buffer */ ++ p->par.round = p->par.rate * 10 / 1000; /* 10ms block size */ ++ + if (!sio_setpar(p->hdl, &p->par)) { + MP_ERR(ao, "couldn't set params\n"); + goto err_out; +@@ -182,7 +174,7 @@ static int init(struct ao *ao) + p->havevol = sio_onvol(p->hdl, volcb, ao); + sio_onmove(p->hdl, movecb, ao); + +- p->pfd = calloc(sio_nfds(p->hdl), sizeof(struct pollfd)); ++ p->pfd = talloc_array_ptrtype(p, p->pfd, sio_nfds(p->hdl)); + if (!p->pfd) + goto err_out; + +@@ -212,7 +204,6 @@ static void uninit(struct ao *ao) + sio_close(p->hdl); + p->hdl = NULL; + } +- free(p->pfd); + p->pfd = NULL; + p->playing = false; + } +@@ -243,23 +234,16 @@ static void reset(struct ao *ao) + { + struct priv *p = ao->priv; + +- process_events(ao); +- p->delay = 0; +- p->playing = false; ++ if (p->playing) { ++ p->playing = false; + +- /* XXX: some times may block here then sndiod used. */ +- if (!sio_stop(p->hdl)) { +- MP_ERR(ao, "reset: couldn't sio_stop()\n"); +-reinit: +- /* Without this device will never work again. */ +- MP_WARN(ao, "Force reinitialize audio device.\n"); +- uninit(ao); +- init(ao); +- return; +- } +- if (!sio_start(p->hdl)) { +- MP_ERR(ao, "reset: sio_start() fail.\n"); +- goto reinit; ++ if (!sio_stop(p->hdl)) { ++ MP_ERR(ao, "reset: couldn't sio_stop()\n"); ++ } ++ p->delay = 0; ++ if (!sio_start(p->hdl)) { ++ MP_ERR(ao, "reset: sio_start() fail.\n"); ++ } + } + } + +@@ -286,7 +270,6 @@ static bool audio_write(struct ao *ao, void **data, int samples) + return false; + } + p->delay += samples; +- process_events(ao); + + return true; + } +@@ -297,10 +280,28 @@ static void get_state(struct ao *ao, struct mp_pcm_state *state) + + process_events(ao); + +- state->free_samples = (ao->device_buffer - p->delay); ++ /* how many samples we can play without blocking */ ++ state->free_samples = ao->device_buffer - p->delay; ++ state->free_samples = state->free_samples / p->par.round * p->par.round; ++ /* how many samples are already in the buffer to be played */ + state->queued_samples = p->delay; +- state->delay = (p->delay / (double)p->par.rate); +- state->playing = p->playing; ++ /* delay in seconds between first and last sample in buffer */ ++ state->delay = p->delay / (double)p->par.rate; ++ ++ /* report unexpected EOF / underrun */ ++ if (state->queued_samples && state->queued_samples && ++ state->queued_samples < state->free_samples && ++ p->playing || sio_eof(p->hdl)) ++ { ++ MP_VERBOSE(ao, "get_state: EOF/underrun detected.\n"); ++ MP_VERBOSE(ao, "get_state: free: %d, queued: %d, delay: %lf\n", \ ++ state->free_samples, state->queued_samples, state->delay); ++ p->playing = false; ++ state->playing = p->playing; ++ ao_wakeup_playthread(ao); ++ } else { ++ state->playing = p->playing; ++ } + } + + const struct ao_driver audio_out_sndio = { +diff --git a/wscript b/wscript +index eeb38f127f..1651187b34 100644 +--- a/wscript ++++ b/wscript +@@ -437,8 +437,7 @@ audio_output_features = [ + }, { + 'name': '--sndio', + 'desc': 'sndio audio input/output', +- 'func': check_statement('sndio.h', +- 'struct sio_par par; sio_initpar(&par); const char *s = SIO_DEVANY', lib='sndio'), ++ 'func': check_pkg_config('sndio'), + 'default': 'disable' + }, { + 'name': '--pulse', +-- +2.35.1 + diff --git a/pkg/mpv/patch/0006-wayland-include-math.h-for-ceil.patch b/pkg/mpv/patch/0006-wayland-include-math.h-for-ceil.patch new file mode 100644 index 00000000..0e18bb85 --- /dev/null +++ b/pkg/mpv/patch/0006-wayland-include-math.h-for-ceil.patch @@ -0,0 +1,24 @@ +From 1c8ae213f7d683c69298f131d424c9006a9650d3 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Thu, 21 Jul 2022 14:00:02 -0700 +Subject: [PATCH] wayland: include <math.h> for ceil + +--- + video/out/wayland_common.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c +index 3cebab9e99..4ec5c148e7 100644 +--- a/video/out/wayland_common.c ++++ b/video/out/wayland_common.c +@@ -18,6 +18,7 @@ + #include <errno.h> + #include <limits.h> + #include <linux/input-event-codes.h> ++#include <math.h> + #include <poll.h> + #include <time.h> + #include <unistd.h> +-- +2.35.1 + diff --git a/pkg/mpv/patch/0007-wayland-actually-handle-0x0-resizes-correctly.patch b/pkg/mpv/patch/0007-wayland-actually-handle-0x0-resizes-correctly.patch new file mode 100644 index 00000000..d425c867 --- /dev/null +++ b/pkg/mpv/patch/0007-wayland-actually-handle-0x0-resizes-correctly.patch @@ -0,0 +1,39 @@ +From 386d92e1ac1c22dbed0d2ab0e77ba1038baba966 Mon Sep 17 00:00:00 2001 +From: Dudemanguy <random342@airmail.cc> +Date: Tue, 25 Jan 2022 11:56:37 -0600 +Subject: [PATCH] wayland: actually handle 0x0 resizes correctly + +According to the xdg-shell protocol spec, a 0x0 size from the compositor +means that "the client should decide its own window dimension". We were +not doing this correctly. What should happen is that mpv should simply +reuse the old window size if it is not maximized or fullscreened. This +should work on all (reasonably recent) versions of mutter and an +compositor that follows the spec. + +https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/stable/xdg-shell/xdg-shell.xml#L1050 +--- + video/out/wayland_common.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c +index 4ec5c148e7..61964c46e5 100644 +--- a/video/out/wayland_common.c ++++ b/video/out/wayland_common.c +@@ -856,6 +856,14 @@ static void handle_toplevel_config(void *data, struct xdg_toplevel *toplevel, + } + } + ++ /* Reuse old size if either of these are 0. */ ++ if (width == 0 || height == 0) { ++ if (!is_fullscreen && !is_maximized) { ++ wl->geometry = wl->window_size; ++ } ++ goto resize; ++ } ++ + if (old_toplevel_width == wl->toplevel_width && + old_toplevel_height == wl->toplevel_height) + return; +-- +2.35.1 + |
