logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git
commit: 76ad3cadb4a8f45df2d7414d7989eaad8d0ae731
parent 5d9af55a4054d028f553f176126c828640581cf4
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 19 Oct 2021 00:00:43 +0200

media-video/mpv: Fixup patch

Diffstat:

Mmedia-video/mpv/files/mpv-0.33.1-sndio_pr9298.patch259++++++++++++++++---------------------------------------------------------------
1 file changed, 53 insertions(+), 206 deletions(-)

diff --git a/media-video/mpv/files/mpv-0.33.1-sndio_pr9298.patch b/media-video/mpv/files/mpv-0.33.1-sndio_pr9298.patch @@ -1,7 +1,7 @@ -From edf0039d762198b4dfea0a9355bac56244118a9a Mon Sep 17 00:00:00 2001 +From d41e8d39dd1de81aa5f56bb1aa4d9fffc1a2ef3d Mon Sep 17 00:00:00 2001 From: rim <rozhuk.im@gmail.com> -Date: Wed, 25 Nov 2020 06:10:19 +0300 -Subject: [PATCH 1/2] ao_sndio: add this audio output again +Date: Mon, 18 Oct 2021 23:55:49 +0200 +Subject: [PATCH] ao_sndio: add this audio output again Changes: - rewrite to use new internal MPV API; @@ -12,17 +12,17 @@ Changes: --- DOCS/man/ao.rst | 6 + audio/out/ao.c | 4 + - audio/out/ao_sndio.c | 317 +++++++++++++++++++++++++++++++++++++++++++ + audio/out/ao_sndio.c | 311 +++++++++++++++++++++++++++++++++++++++++++ wscript | 6 + wscript_build.py | 1 + - 5 files changed, 334 insertions(+) + 5 files changed, 328 insertions(+) create mode 100644 audio/out/ao_sndio.c diff --git a/DOCS/man/ao.rst b/DOCS/man/ao.rst -index 1c0b9e146be..97c213a5dd8 100644 +index cc42ec23a6..1f9bf915b3 100644 --- a/DOCS/man/ao.rst +++ b/DOCS/man/ao.rst -@@ -219,5 +219,11 @@ Available audio output drivers are: +@@ -216,5 +216,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. @@ -35,10 +35,10 @@ index 1c0b9e146be..97c213a5dd8 100644 ``wasapi`` Audio output to the Windows Audio Session API. diff --git a/audio/out/ao.c b/audio/out/ao.c -index 7c347cb1380..950f935c812 100644 +index 52a38b63be..00893c0eb3 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c -@@ -41,6 +41,7 @@ extern const struct ao_driver audio_out_audiounit; +@@ -40,6 +40,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; @@ -46,7 +46,7 @@ index 7c347cb1380..950f935c812 100644 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[] = { +@@ -83,6 +84,9 @@ static const struct ao_driver * const audio_out_drivers[] = { #endif #if HAVE_SDL2_AUDIO &audio_out_sdl, @@ -58,10 +58,10 @@ index 7c347cb1380..950f935c812 100644 #if HAVE_COREAUDIO diff --git a/audio/out/ao_sndio.c b/audio/out/ao_sndio.c new file mode 100644 -index 00000000000..4a6f49ee58a +index 0000000000..ec2fb3bcb6 --- /dev/null +++ b/audio/out/ao_sndio.c -@@ -0,0 +1,317 @@ +@@ -0,0 +1,311 @@ +/* + * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> + * Copyright (c) 2013 Christian Neukirchen <chneukirchen@gmail.com> @@ -105,7 +105,7 @@ index 00000000000..4a6f49ee58a +}; + + -+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 */ @@ -128,11 +128,9 @@ index 00000000000..4a6f49ee58a +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); +} @@ -183,21 +181,15 @@ index 00000000000..4a6f49ee58a + + /* 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; + } + } @@ -246,7 +238,7 @@ index 00000000000..4a6f49ee58a + 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; + @@ -276,7 +268,6 @@ index 00000000000..4a6f49ee58a + sio_close(p->hdl); + p->hdl = NULL; + } -+ free(p->pfd); + p->pfd = NULL; + p->playing = false; +} @@ -307,23 +298,16 @@ index 00000000000..4a6f49ee58a +{ + 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"); ++ } + } +} + @@ -350,7 +334,6 @@ index 00000000000..4a6f49ee58a + return false; + } + p->delay += samples; -+ process_events(ao); + + return true; +} @@ -361,9 +344,20 @@ index 00000000000..4a6f49ee58a + + 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; ++ /* how many samples are already in the buffer to be played */ + state->queued_samples = p->delay; -+ state->delay = (p->delay / (double)p->par.rate); ++ /* delay in seconds between first and last sample in buffer */ ++ state->delay = p->delay / (double)p->par.rate; ++ ++ /* reset on unexpected EOF / underrun */ ++ if (state->queued_samples && state->queued_samples && ++ state->queued_samples < state->free_samples && ++ p->playing) ++ { ++ reset(ao); ++ } + state->playing = p->playing; +} + @@ -380,13 +374,13 @@ index 00000000000..4a6f49ee58a + .priv_size = sizeof(struct priv), +}; diff --git a/wscript b/wscript -index e9f4d53002c..ac2f9e68d88 100644 +index b81f1202ec..e9af544b0c 100644 --- a/wscript +++ b/wscript -@@ -426,6 +426,12 @@ audio_output_features = [ - 'desc': 'OSSv4 audio output', - 'func': check_statement(['sys/soundcard.h'], 'int x = SNDCTL_DSP_SETPLAYVOL'), - 'deps': 'posix && gpl', +@@ -421,6 +421,12 @@ audio_output_features = [ + 'desc': 'SDL2 audio output', + 'deps': 'sdl2', + 'func': check_true, + }, { + 'name': '--sndio', + 'desc': 'sndio audio input/output', @@ -397,10 +391,10 @@ index e9f4d53002c..ac2f9e68d88 100644 'name': '--pulse', 'desc': 'PulseAudio audio output', diff --git a/wscript_build.py b/wscript_build.py -index a12cbf19e17..afa10b83e06 100644 +index 14c254e1ec..7943f850b0 100644 --- a/wscript_build.py +++ b/wscript_build.py -@@ -248,6 +248,7 @@ def swift(task): +@@ -247,6 +247,7 @@ def build(ctx): ( "audio/out/ao_pcm.c" ), ( "audio/out/ao_pulse.c", "pulse" ), ( "audio/out/ao_sdl.c", "sdl2-audio" ), @@ -408,153 +402,6 @@ index a12cbf19e17..afa10b83e06 100644 ( "audio/out/ao_wasapi.c", "wasapi" ), ( "audio/out/ao_wasapi_changenotify.c", "wasapi" ), ( "audio/out/ao_wasapi_utils.c", "wasapi" ), +-- +2.32.0 -From f57938190b85832482963b13ebe19fb51e5f1ecc Mon Sep 17 00:00:00 2001 -From: Andrew Krasavin <noiseless-ak@yandex.ru> -Date: Wed, 13 Oct 2021 05:14:28 +0300 -Subject: [PATCH 2/2] 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 ---- - audio/out/ao_sndio.c | 70 ++++++++++++++++++++------------------------ - 1 file changed, 32 insertions(+), 38 deletions(-) - -diff --git a/audio/out/ao_sndio.c b/audio/out/ao_sndio.c -index 4a6f49ee58a..ec2fb3bcb61 100644 ---- a/audio/out/ao_sndio.c -+++ b/audio/out/ao_sndio.c -@@ -41,7 +41,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 +64,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 +117,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; - } - } -@@ -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,9 +280,20 @@ 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; -+ /* how many samples are already in the buffer to be played */ - state->queued_samples = p->delay; -- state->delay = (p->delay / (double)p->par.rate); -+ /* delay in seconds between first and last sample in buffer */ -+ state->delay = p->delay / (double)p->par.rate; -+ -+ /* reset on unexpected EOF / underrun */ -+ if (state->queued_samples && state->queued_samples && -+ state->queued_samples < state->free_samples && -+ p->playing) -+ { -+ reset(ao); -+ } - state->playing = p->playing; - } -