pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/multimedia/mpv



Module Name:    pkgsrc
Committed By:   nia
Date:           Mon Mar 16 20:31:44 UTC 2020

Modified Files:
        pkgsrc/multimedia/mpv: Makefile distinfo
        pkgsrc/multimedia/mpv/patches: patch-options_options.c patch-wscript
Added Files:
        pkgsrc/multimedia/mpv/patches: patch-DOCS_man_ao.rst
            patch-audio_out_ao.c patch-audio_out_ao__netbsd.c
            patch-wscript__build.py

Log Message:
mpv: Add NetBSD audio support

We had some problems with the OSS audio output, this should avoid those.

This maintains pretty perfect audio-video sync and framerates with
autosync=0 and blk_ms=4.

Bump PKGREVISION


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 pkgsrc/multimedia/mpv/Makefile
cvs rdiff -u -r1.59 -r1.60 pkgsrc/multimedia/mpv/distinfo
cvs rdiff -u -r0 -r1.1 pkgsrc/multimedia/mpv/patches/patch-DOCS_man_ao.rst \
    pkgsrc/multimedia/mpv/patches/patch-audio_out_ao.c \
    pkgsrc/multimedia/mpv/patches/patch-audio_out_ao__netbsd.c \
    pkgsrc/multimedia/mpv/patches/patch-wscript__build.py
cvs rdiff -u -r1.2 -r1.3 \
    pkgsrc/multimedia/mpv/patches/patch-options_options.c
cvs rdiff -u -r1.3 -r1.4 pkgsrc/multimedia/mpv/patches/patch-wscript

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/multimedia/mpv/Makefile
diff -u pkgsrc/multimedia/mpv/Makefile:1.98 pkgsrc/multimedia/mpv/Makefile:1.99
--- pkgsrc/multimedia/mpv/Makefile:1.98 Tue Mar 10 22:10:41 2020
+++ pkgsrc/multimedia/mpv/Makefile      Mon Mar 16 20:31:44 2020
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.98 2020/03/10 22:10:41 wiz Exp $
+# $NetBSD: Makefile,v 1.99 2020/03/16 20:31:44 nia Exp $
 
 DISTNAME=      mpv-0.32.0
-PKGREVISION=   3
+PKGREVISION=   4
 CATEGORIES=    multimedia
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=mpv-player/}
 GITHUB_TAG=    v${PKGVERSION_NOREV}
@@ -65,6 +65,11 @@ BUILDLINK_PASSTHRU_DIRS+=    ${XCODE_DIR}/T
 .  endif
 .endif
 
+.if ${OPSYS} == "NetBSD"
+# Use audio(4) over ossaudio(4) on NetBSD.
+WAF_CONFIGURE_ARGS+=   --disable-oss-audio
+.endif
+
 post-install:
        cd ${DESTDIR}${PREFIX} && ${MV} etc/mpv/encoding-profiles.conf share/examples/mpv
 

Index: pkgsrc/multimedia/mpv/distinfo
diff -u pkgsrc/multimedia/mpv/distinfo:1.59 pkgsrc/multimedia/mpv/distinfo:1.60
--- pkgsrc/multimedia/mpv/distinfo:1.59 Sun Jan 26 21:28:11 2020
+++ pkgsrc/multimedia/mpv/distinfo      Mon Mar 16 20:31:44 2020
@@ -1,12 +1,16 @@
-$NetBSD: distinfo,v 1.59 2020/01/26 21:28:11 leot Exp $
+$NetBSD: distinfo,v 1.60 2020/03/16 20:31:44 nia Exp $
 
 SHA1 (mpv-0.32.0.tar.gz) = 5b69ea34dd5f8d209acd5266415c7bc00ab83341
 RMD160 (mpv-0.32.0.tar.gz) = d1e399fce8985a0399fe627248b87d8537cfefd7
 SHA512 (mpv-0.32.0.tar.gz) = f6426c0254ec0bf2f120e2196904f1e15fe17032b06764abca1d5e074f0cabb452eaf1cd09f8fd9b25b591accee7b881bfc3b06c19d5c98980305c4712486bd6
 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-options_options.c) = 0c711323e2cd46948852476144ed0e07418394b4
+SHA1 (patch-audio_out_ao__netbsd.c) = 137cd9da82108adc02848954fa72c057a9de7a1e
+SHA1 (patch-options_options.c) = c75fb27140ad21e0a11c6ded976116c544661f56
 SHA1 (patch-player_main.c) = 7d1d62091c327fca698844004ddb9a7871e15fce
 SHA1 (patch-video_out_drm__common.c) = a545a8aec29f1b3c44d26aacbc59b86d3333a0b9
 SHA1 (patch-video_out_wayland__common.c) = d3e72c4ff5426bd8349c15679a47d446c35666b1
-SHA1 (patch-wscript) = 2f082a2d3797234bf56859d95c219f5355382224
+SHA1 (patch-wscript) = 33c81597c1eb25911b13c64a1ba8e47d268bd517
+SHA1 (patch-wscript__build.py) = bbb391be46f6e5c02d1946a07bb5d8bbb442fd5a

Index: pkgsrc/multimedia/mpv/patches/patch-options_options.c
diff -u pkgsrc/multimedia/mpv/patches/patch-options_options.c:1.2 pkgsrc/multimedia/mpv/patches/patch-options_options.c:1.3
--- pkgsrc/multimedia/mpv/patches/patch-options_options.c:1.2   Sat Dec 28 17:20:33 2019
+++ pkgsrc/multimedia/mpv/patches/patch-options_options.c       Mon Mar 16 20:31:44 2020
@@ -1,9 +1,7 @@
-$NetBSD: patch-options_options.c,v 1.2 2019/12/28 17:20:33 leot Exp $
+$NetBSD: patch-options_options.c,v 1.3 2020/03/16 20:31:44 nia Exp $
 
-autosync=0 requires "a perfect audio delay measurement".
-
-NetBSD does not provide this. Setting it to 30 (as recommended in
-mpv's man page) fixes frame drops in NetBSD.
+Workaround for frame drops with a high default blocksize.
+Can be removed when we are blk_ms=4 everywhere.
 
 PR kern/54230
 

Index: pkgsrc/multimedia/mpv/patches/patch-wscript
diff -u pkgsrc/multimedia/mpv/patches/patch-wscript:1.3 pkgsrc/multimedia/mpv/patches/patch-wscript:1.4
--- pkgsrc/multimedia/mpv/patches/patch-wscript:1.3     Fri Oct 25 14:35:56 2019
+++ pkgsrc/multimedia/mpv/patches/patch-wscript Mon Mar 16 20:31:44 2020
@@ -1,10 +1,18 @@
-$NetBSD: patch-wscript,v 1.3 2019/10/25 14:35:56 leot Exp $
+$NetBSD: patch-wscript,v 1.4 2020/03/16 20:31:44 nia Exp $
 
 Enable support for DRM on NetBSD.
 
---- wscript.orig       2019-10-25 13:08:15.000000000 +0000
+NetBSD audio support.
+
+--- wscript.orig       2020-01-26 20:31:54.000000000 +0000
 +++ wscript
-@@ -289,6 +289,11 @@ iconv support use --disable-iconv.",
+@@ -1,4 +1,4 @@
+-# vi: ft=python
++# vi: ft=python3.7
+ 
+ import sys, os, re
+ sys.path.insert(0, os.path.join(os.getcwd(), 'waftools'))
+@@ -291,6 +291,11 @@ iconv support use --disable-iconv.",
          'func': check_statement(['sys/vt.h', 'sys/ioctl.h'],
                                  'int m; ioctl(0, VT_GETMODE, &m)'),
      }, {
@@ -16,7 +24,19 @@ Enable support for DRM on NetBSD.
          'name': 'gbm.h',
          'desc': 'gbm.h',
          'func': check_cc(header_name=['stdio.h', 'gbm.h']),
-@@ -584,7 +589,7 @@ video_output_features = [
+@@ -521,6 +526,11 @@ audio_output_features = [
+         'func': check_cc(header_name='sys/soundcard.h'),
+         'deps': 'posix && gpl',
+     }, {
++        'name': '--netbsd-audio',
++        'desc': 'NetBSD audio output',
++        'func': check_statement(['sys/audioio.h', 'sys/ioctl.h'],
++                                'struct audio_device d; ioctl(0, AUDIO_GETDEV, &d)'),
++    }, {
+         'name': '--rsound',
+         'desc': 'RSound audio output',
+         'func': check_statement('rsound.h', 'rsd_init(NULL)', lib='rsound')
+@@ -587,7 +597,7 @@ video_output_features = [
      }, {
          'name': '--drm',
          'desc': 'DRM',

Added files:

Index: pkgsrc/multimedia/mpv/patches/patch-DOCS_man_ao.rst
diff -u /dev/null pkgsrc/multimedia/mpv/patches/patch-DOCS_man_ao.rst:1.1
--- /dev/null   Mon Mar 16 20:31:44 2020
+++ pkgsrc/multimedia/mpv/patches/patch-DOCS_man_ao.rst Mon Mar 16 20:31:44 2020
@@ -0,0 +1,16 @@
+$NetBSD: patch-DOCS_man_ao.rst,v 1.1 2020/03/16 20:31:44 nia Exp $
+
+NetBSD audio support.
+
+--- DOCS/man/ao.rst.orig       2020-01-26 20:31:54.000000000 +0000
++++ DOCS/man/ao.rst
+@@ -177,6 +177,9 @@ Available audio output drivers are:
+         Sets the number of extra audio buffers in mpv. Usually needs not be
+         changed.
+ 
++``netbsd``
++    Audio output to the NetBSD sound system
++
+ ``null``
+     Produces no audio output but maintains video playback speed. You can use
+     ``--ao=null --ao-null-untimed`` for benchmarking.
Index: pkgsrc/multimedia/mpv/patches/patch-audio_out_ao.c
diff -u /dev/null pkgsrc/multimedia/mpv/patches/patch-audio_out_ao.c:1.1
--- /dev/null   Mon Mar 16 20:31:44 2020
+++ pkgsrc/multimedia/mpv/patches/patch-audio_out_ao.c  Mon Mar 16 20:31:44 2020
@@ -0,0 +1,24 @@
+$NetBSD: patch-audio_out_ao.c,v 1.1 2020/03/16 20:31:44 nia Exp $
+
+NetBSD audio support.
+
+--- audio/out/ao.c.orig        2020-01-26 20:31:54.000000000 +0000
++++ audio/out/ao.c
+@@ -40,6 +40,7 @@ extern const struct ao_driver audio_out_
+ 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_netbsd;
+ extern const struct ao_driver audio_out_rsound;
+ extern const struct ao_driver audio_out_sndio;
+ extern const struct ao_driver audio_out_pulse;
+@@ -64,6 +65,9 @@ static const struct ao_driver * const au
+ #if HAVE_COREAUDIO
+     &audio_out_coreaudio,
+ #endif
++#if HAVE_NETBSD_AUDIO
++    &audio_out_netbsd,
++#endif
+ #if HAVE_PULSE
+     &audio_out_pulse,
+ #endif
Index: pkgsrc/multimedia/mpv/patches/patch-audio_out_ao__netbsd.c
diff -u /dev/null pkgsrc/multimedia/mpv/patches/patch-audio_out_ao__netbsd.c:1.1
--- /dev/null   Mon Mar 16 20:31:44 2020
+++ pkgsrc/multimedia/mpv/patches/patch-audio_out_ao__netbsd.c  Mon Mar 16 20:31:44 2020
@@ -0,0 +1,283 @@
+$NetBSD: patch-audio_out_ao__netbsd.c,v 1.1 2020/03/16 20:31:44 nia Exp $
+
+NetBSD audio support.
+
+--- audio/out/ao_netbsd.c.orig 2020-03-16 20:20:16.030655720 +0000
++++ audio/out/ao_netbsd.c
+@@ -0,0 +1,276 @@
++/*
++ * Copyright (c) 2020 Nia Alarie <nia%NetBSD.org@localhost>
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ *
++ * 1. Redistributions of source code must retain the above copyright
++ *    notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ *    notice, this list of conditions and the following disclaimer in the
++ *    documentation and/or other materials provided with the distribution.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
++ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
++ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
++ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
++ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
++ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
++ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
++ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
++ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
++ * POSSIBILITY OF SUCH DAMAGE.
++ */
++#include <sys/audioio.h>
++#include <sys/ioctl.h>
++#include <unistd.h>
++#include <fcntl.h>
++#include <errno.h>
++#include <stdint.h>
++#include <string.h>
++
++#include "options/m_option.h"
++#include "common/msg.h"
++
++#include "audio/format.h"
++#include "ao.h"
++#include "internal.h"
++
++#ifndef NETBSD_MAXDEVS
++#define NETBSD_MAXDEVS (8)
++#endif
++
++struct priv {
++    int fd;
++    uint64_t total_blocks; /* audio blocks output */
++    uint64_t total_bytes; /* bytes sent to the queue */
++};
++
++static int init(struct ao *ao)
++{
++    char device[16] = "/dev/audio";
++    struct priv *p = ao->priv;
++    struct audio_info info;
++    struct audio_prinfo *pinfo;
++    struct mp_chmap_sel sel = {0};
++
++    AUDIO_INITINFO(&info);
++    pinfo = &info.play;
++
++    if (ao->device != NULL) {
++         (void)snprintf(device, sizeof(device), "/dev/audio%s",
++                        ao->device + sizeof("netbsd/") - 1);
++    }
++
++    MP_ERR(ao, "Opening device %s", ao->device);
++    if ((p->fd = open(device, O_WRONLY)) == -1) {
++        MP_ERR(ao, "Can't open audio device %s: %s\n",
++               ao->device, mp_strerror(errno));
++        goto fail;
++    }
++
++    info.mode = AUMODE_PLAY;
++
++    for (int n = 1; n <= 12; n++) {
++        struct mp_chmap map;
++
++        mp_chmap_from_channels(&map, n);
++        mp_chmap_sel_add_map(&sel, &map);
++    }
++
++    if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels)) {
++        MP_ERR(ao, "Failed to select a valid channel map\n");
++        goto fail;
++    }
++
++    pinfo->channels = ao->channels.num;
++    pinfo->sample_rate = ao->samplerate;
++
++    switch (ao->format) {
++    case AF_FORMAT_U8:
++        pinfo->precision = 8;
++        pinfo->encoding = AUDIO_ENCODING_ULINEAR;
++        break;
++    case AF_FORMAT_S16:
++        pinfo->precision = 16;
++        pinfo->encoding = AUDIO_ENCODING_SLINEAR;
++        break;
++    default:
++        pinfo->precision = 32;
++        pinfo->encoding = AUDIO_ENCODING_SLINEAR;
++        break;
++    }
++
++    if (ioctl(p->fd, AUDIO_SETINFO, &info) == -1) {
++        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;
++
++    switch (pinfo->precision) {
++    case 8:
++        ao->format = AF_FORMAT_U8;
++        break;
++    case 16:
++        ao->format = AF_FORMAT_S16;
++        break;
++    case 32:
++        ao->format = AF_FORMAT_S32;
++        break;
++    default:
++        MP_ERR(ao, "Unsupported precision %d\n", pinfo->precision);
++        goto fail;
++    }
++
++    return 0;
++
++fail:
++    if (p->fd != -1) {
++        close(p->fd);
++    }
++    return -1;
++}
++
++static void uninit(struct ao *ao)
++{
++    struct priv *p = ao->priv;
++
++    (void)ioctl(p->fd, AUDIO_FLUSH, NULL);
++    (void)close(p->fd);
++    p->fd = -1;
++}
++
++static void reset(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_GETOOFFS, &offset); /* reset deltablks */
++    p->total_blocks = p->total_bytes / info.blocksize;
++}
++
++static int get_space(struct ao *ao)
++{
++    struct priv *p = ao->priv;
++    struct audio_info info;
++
++    if (ioctl(p->fd, AUDIO_GETINFO, &info) == -1) {
++        MP_ERR(ao, "AUDIO_GETINFO failed: %s\n", mp_strerror(errno));
++        return 0;
++    }
++    return (info.blocksize - info.play.seek) / ao->sstride;
++}
++
++static void audio_pause(struct ao *ao)
++{
++    struct priv *p = ao->priv;
++    struct audio_info info;
++
++    if (ioctl(p->fd, AUDIO_GETINFO, &info) == -1) {
++        MP_ERR(ao, "AUDIO_GETINFO failed: %s\n", mp_strerror(errno));
++        return;
++    }
++    info.play.pause = 1;
++    (void)ioctl(p->fd, AUDIO_SETINFO, &info);
++}
++
++static void audio_resume(struct ao *ao)
++{
++    struct priv *p = ao->priv;
++    struct audio_info info;
++
++    if (ioctl(p->fd, AUDIO_GETINFO, &info) == -1) {
++        MP_ERR(ao, "AUDIO_GETINFO failed: %s\n", mp_strerror(errno));
++        return;
++    }
++    info.play.pause = 0;
++    (void)ioctl(p->fd, AUDIO_SETINFO, &info);
++    reset(ao);
++}
++
++static double get_delay(struct ao *ao)
++{
++    struct priv *p = ao->priv;
++    struct audio_info info;
++    struct audio_offset offset;
++    uint64_t transfer_len;
++
++    if (ioctl(p->fd, AUDIO_GETINFO, &info) == -1) {
++        MP_ERR(ao, "AUDIO_GETINFO failed: %s\n", mp_strerror(errno));
++        return 0;
++    }
++    if (ioctl(p->fd, AUDIO_GETOOFFS, &offset) == -1) {
++        MP_ERR(ao, "AUDIO_GETOOFFS failed: %s\n", mp_strerror(errno));
++        return 0;
++    }
++    p->total_blocks += offset.deltablks;
++    transfer_len = p->total_bytes - (p->total_blocks * info.blocksize);
++    return transfer_len / (double)ao->bps;
++}
++
++static int play(struct ao *ao, void **data, int samples, int flags)
++{
++    struct priv *p = ao->priv;
++    int len = samples * ao->sstride;
++    int ret;
++
++    if (len == 0)
++        return 0;
++
++    errno = 0;
++    if ((ret = write(p->fd, data[0], len)) == -1) {
++        MP_ERR(ao, "audio write failed: %s\n", mp_strerror(errno));
++        return 0;
++    }
++    p->total_bytes += ret;
++    return ret / ao->sstride;
++}
++
++static void list_devs(struct ao *ao, struct ao_device_list *list)
++{
++    char name[16];
++    struct audio_device dev;
++    int fd;
++
++    for (int i = 0; 0 < NETBSD_MAXDEVS; ++i) {
++        (void)snprintf(name, sizeof(name), "/dev/audio%d", i);
++        fd = open(name, O_WRONLY);
++        if (fd == -1 || ioctl(fd, AUDIO_GETDEV, &dev) == -1) {
++            break;
++        }
++        (void)snprintf(name, sizeof(name), "%d", i);
++        ao_device_list_add(list, ao, &(struct ao_device_desc){name, dev.name});
++        close(fd);
++    }
++}
++
++const struct ao_driver audio_out_netbsd = {
++    .description = "NetBSD audio output",
++    .name      = "netbsd",
++    .init      = init,
++    .uninit    = uninit,
++    .reset     = reset,
++    .pause     = audio_pause,
++    .resume    = audio_resume,
++    .get_space = get_space,
++    .get_delay = get_delay,
++    .play      = play,
++    .list_devs = list_devs,
++    .priv_size = sizeof(struct priv),
++};
Index: pkgsrc/multimedia/mpv/patches/patch-wscript__build.py
diff -u /dev/null pkgsrc/multimedia/mpv/patches/patch-wscript__build.py:1.1
--- /dev/null   Mon Mar 16 20:31:44 2020
+++ pkgsrc/multimedia/mpv/patches/patch-wscript__build.py       Mon Mar 16 20:31:44 2020
@@ -0,0 +1,14 @@
+$NetBSD: patch-wscript__build.py,v 1.1 2020/03/16 20:31:44 nia Exp $
+
+NetBSD audio support.
+
+--- wscript_build.py.orig      2020-01-26 20:31:54.000000000 +0000
++++ wscript_build.py
+@@ -252,6 +252,7 @@ def build(ctx):
+         ( "audio/out/ao_coreaudio_utils.c",      "coreaudio || audiounit" ),
+         ( "audio/out/ao_jack.c",                 "jack" ),
+         ( "audio/out/ao_lavc.c" ),
++        ( "audio/out/ao_netbsd.c",               "netbsd-audio" ),
+         ( "audio/out/ao_null.c" ),
+         ( "audio/out/ao_openal.c",               "openal" ),
+         ( "audio/out/ao_opensles.c",             "opensles" ),



Home | Main Index | Thread Index | Old Index