diff options
author | nia <nia@pkgsrc.org> | 2020-04-08 12:17:02 +0000 |
---|---|---|
committer | nia <nia@pkgsrc.org> | 2020-04-08 12:17:02 +0000 |
commit | c6e122a8d35a069867ab3e875089c05fa0d0ef19 (patch) | |
tree | 694dee6ab01efb1640d8483e28ffdbcb16665630 /multimedia | |
parent | 475a25f44930df515cfbc24ad0a833fe98cf3d66 (diff) | |
download | pkgsrc-c6e122a8d35a069867ab3e875089c05fa0d0ef19.tar.gz |
mpv: ao_netbsd improvements. Fixes playing very small audio files.
- Get the preferred sample rate from the device.
This ensures sample rate conversion is done in user space,
which is a Good Idea and should improve output quality.
This backend is now Even More NetBSD.
- Implement drain().
- Bump up the buffer size.
Bump PKGREVISION
Diffstat (limited to 'multimedia')
-rw-r--r-- | multimedia/mpv/Makefile | 4 | ||||
-rw-r--r-- | multimedia/mpv/distinfo | 4 | ||||
-rw-r--r-- | multimedia/mpv/patches/patch-audio_out_ao__netbsd.c | 53 |
3 files changed, 37 insertions, 24 deletions
diff --git a/multimedia/mpv/Makefile b/multimedia/mpv/Makefile index b19c98eda0d..238c5036d8c 100644 --- a/multimedia/mpv/Makefile +++ b/multimedia/mpv/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.105 2020/04/07 13:47:04 ryoon Exp $ +# $NetBSD: Makefile,v 1.106 2020/04/08 12:17:02 nia Exp $ DISTNAME= mpv-0.32.0 -PKGREVISION= 7 +PKGREVISION= 8 CATEGORIES= multimedia MASTER_SITES= ${MASTER_SITE_GITHUB:=mpv-player/} GITHUB_TAG= v${PKGVERSION_NOREV} diff --git a/multimedia/mpv/distinfo b/multimedia/mpv/distinfo index 60ea470a49c..da75fd231c2 100644 --- a/multimedia/mpv/distinfo +++ b/multimedia/mpv/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.63 2020/03/18 11:49:21 leot Exp $ +$NetBSD: distinfo,v 1.64 2020/04/08 12:17:02 nia Exp $ SHA1 (mpv-0.32.0.tar.gz) = 5b69ea34dd5f8d209acd5266415c7bc00ab83341 RMD160 (mpv-0.32.0.tar.gz) = d1e399fce8985a0399fe627248b87d8537cfefd7 @@ -7,7 +7,7 @@ Size (mpv-0.32.0.tar.gz) = 3148730 bytes SHA1 (patch-DOCS_man_ao.rst) = 5940fe1ad4d4328c03b9e6e5265c517762cfe2d0 SHA1 (patch-audio_out_ao.c) = 1527c818d0f50801485ad3b90c5d86b30b2ca6f1 SHA1 (patch-audio_out_ao__alsa.c) = c4661d0d22550d6e4eb2b7a42dd04dbcc58123b0 -SHA1 (patch-audio_out_ao__netbsd.c) = 544b976fae4d672a4f99b226b949f5f338712820 +SHA1 (patch-audio_out_ao__netbsd.c) = 1a88957a89dd8ebffaeadb14463c16796eb444d3 SHA1 (patch-options_options.c) = c75fb27140ad21e0a11c6ded976116c544661f56 SHA1 (patch-player_main.c) = 7d1d62091c327fca698844004ddb9a7871e15fce SHA1 (patch-video_out_drm__common.c) = a545a8aec29f1b3c44d26aacbc59b86d3333a0b9 diff --git a/multimedia/mpv/patches/patch-audio_out_ao__netbsd.c b/multimedia/mpv/patches/patch-audio_out_ao__netbsd.c index 7e5a181ca9d..cb366e7d318 100644 --- a/multimedia/mpv/patches/patch-audio_out_ao__netbsd.c +++ b/multimedia/mpv/patches/patch-audio_out_ao__netbsd.c @@ -1,10 +1,10 @@ -$NetBSD: patch-audio_out_ao__netbsd.c,v 1.3 2020/03/18 11:49:21 leot Exp $ +$NetBSD: patch-audio_out_ao__netbsd.c,v 1.4 2020/04/08 12:17:02 nia Exp $ NetBSD audio support. ---- audio/out/ao_netbsd.c.orig 2020-03-18 11:11:11.484992180 +0000 +--- audio/out/ao_netbsd.c.orig 2020-04-08 12:06:20.470592603 +0000 +++ audio/out/ao_netbsd.c -@@ -0,0 +1,263 @@ +@@ -0,0 +1,276 @@ +/* + * Copyright (c) 2020 Nia Alarie <nia@NetBSD.org> + * All rights reserved. @@ -50,12 +50,8 @@ NetBSD audio support. +#define NETBSD_MAX_DEVS (8) +#endif + -+#ifndef NETBSD_MAX_CHANNELS -+#define NETBSD_MAX_CHANNELS (12) -+#endif -+ -+#ifndef NETBSD_BUF_FRAMES -+#define NETBSD_BUF_FRAMES (32) ++#ifndef NETBSD_BUF_SIZE ++#define NETBSD_BUF_SIZE (1024) +#endif + +struct priv { @@ -69,10 +65,12 @@ NetBSD audio support. + char device[16] = "/dev/audio"; + struct priv *p = ao->priv; + struct audio_info info; ++ struct audio_info hw_info; + struct audio_prinfo *pinfo; + struct mp_chmap_sel sel = {0}; + + AUDIO_INITINFO(&info); ++ AUDIO_INITINFO(&hw_info); + pinfo = &info.play; + + if (ao->device != NULL) { @@ -87,9 +85,14 @@ NetBSD audio support. + goto fail; + } + ++ if (ioctl(p->fd, AUDIO_GETFORMAT, &hw_info) == -1) { ++ MP_ERR(ao, "AUDIO_GETFORMAT failed: %s\n", mp_strerror(errno)); ++ goto fail; ++ } ++ + info.mode = AUMODE_PLAY; + -+ for (int n = 1; n <= NETBSD_MAX_CHANNELS; n++) { ++ for (int n = 1; n <= hw_info.play.channels; n++) { + struct mp_chmap map; + + mp_chmap_from_channels(&map, n); @@ -102,7 +105,7 @@ NetBSD audio support. + } + + pinfo->channels = ao->channels.num; -+ pinfo->sample_rate = ao->samplerate; ++ pinfo->sample_rate = ao->samplerate = hw_info.play.sample_rate; + + switch (ao->format) { + case AF_FORMAT_U8: @@ -124,14 +127,6 @@ NetBSD audio support. + MP_ERR(ao, "AUDIO_SETINFO failed: %s\n", mp_strerror(errno)); + goto fail; + } -+ -+ if (ioctl(p->fd, AUDIO_GETINFO, &info) == -1) { -+ MP_ERR(ao, "AUDIO_GETINFO failed: %s\n", mp_strerror(errno)); -+ goto fail; -+ } -+ -+ ao->samplerate = pinfo->sample_rate; -+ + return 0; + +fail: @@ -161,14 +156,31 @@ NetBSD audio support. + return; + } + ++ (void)ioctl(p->fd, AUDIO_FLUSH, NULL); ++ (void)ioctl(p->fd, AUDIO_GETOOFFS, &offset); /* reset deltablks */ ++ p->total_blocks = p->total_bytes / info.blocksize; ++} ++ ++static void drain(struct ao *ao) ++{ ++ struct priv *p = ao->priv; ++ struct audio_info info; ++ struct audio_offset offset; ++ ++ if (ioctl(p->fd, AUDIO_GETINFO, &info) == -1) { ++ MP_ERR(ao, "AUDIO_GETINFO failed: %s\n", mp_strerror(errno)); ++ return; ++ } ++ + (void)ioctl(p->fd, AUDIO_DRAIN, NULL); ++ (void)ioctl(p->fd, AUDIO_FLUSH, NULL); + (void)ioctl(p->fd, AUDIO_GETOOFFS, &offset); /* reset deltablks */ + p->total_blocks = p->total_bytes / info.blocksize; +} + +static int get_space(struct ao *ao) +{ -+ return NETBSD_BUF_FRAMES * ao->sstride; ++ return NETBSD_BUF_SIZE; +} + +static void audio_pause(struct ao *ao) @@ -260,6 +272,7 @@ NetBSD audio support. + .init = init, + .uninit = uninit, + .reset = reset, ++ .drain = drain, + .pause = audio_pause, + .resume = audio_resume, + .get_space = get_space, |