pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/multimedia/mpv Add stereo/mono fallback logic for `oss...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/cae361933338
branches:  trunk
changeset: 365420:cae361933338
user:      leot <leot%pkgsrc.org@localhost>
date:      Sun Jul 16 12:06:25 2017 +0000

description:
Add stereo/mono fallback logic for `oss' audio output.

Previously playing files with more audio channels available than the ones
provided by audio device resulted in muted audio. A possible workaround to that
was forcing the `--audio-channels=2' or similar.

Thanks to <mrg> for kindly provided a reliable test (file|case) for that!

While here also get rid of a trailing whitespace in options.mk (spotted by
pkglint!)

Bump PKGREVISION.

diffstat:

 multimedia/mpv/Makefile                          |   3 +-
 multimedia/mpv/distinfo                          |   3 +-
 multimedia/mpv/options.mk                        |   4 +-
 multimedia/mpv/patches/patch-audio_out_ao__oss.c |  40 ++++++++++++++++++++++++
 4 files changed, 46 insertions(+), 4 deletions(-)

diffs (86 lines):

diff -r ca15d711f35d -r cae361933338 multimedia/mpv/Makefile
--- a/multimedia/mpv/Makefile   Sun Jul 16 11:42:59 2017 +0000
+++ b/multimedia/mpv/Makefile   Sun Jul 16 12:06:25 2017 +0000
@@ -1,6 +1,7 @@
-# $NetBSD: Makefile,v 1.55 2017/04/24 15:18:01 maya Exp $
+# $NetBSD: Makefile,v 1.56 2017/07/16 12:06:25 leot Exp $
 
 DISTNAME=      mpv-0.25.0
+PKGREVISION=   1
 CATEGORIES=    multimedia
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=mpv-player/}
 GITHUB_TAG=    v${PKGVERSION_NOREV}
diff -r ca15d711f35d -r cae361933338 multimedia/mpv/distinfo
--- a/multimedia/mpv/distinfo   Sun Jul 16 11:42:59 2017 +0000
+++ b/multimedia/mpv/distinfo   Sun Jul 16 12:06:25 2017 +0000
@@ -1,7 +1,8 @@
-$NetBSD: distinfo,v 1.34 2017/04/24 15:18:01 maya Exp $
+$NetBSD: distinfo,v 1.35 2017/07/16 12:06:25 leot Exp $
 
 SHA1 (mpv-0.25.0.tar.gz) = fe98e9afe0a5ed04ef957cb2d0bf014b5c6c6665
 RMD160 (mpv-0.25.0.tar.gz) = fd9c2ebe95ae121de8f2f17aa4e36711457ed758
 SHA512 (mpv-0.25.0.tar.gz) = eefc574e2995ddf6bd15c9b62986a5ca277c30949b036d57a11bbfb796c11c1e6dd7c313abd91a909dd98ca0f2b0be29ec6b980d0287a5891b42b0ffba926cbf
 Size (mpv-0.25.0.tar.gz) = 2874584 bytes
+SHA1 (patch-audio_out_ao__oss.c) = 518f87f39e56d764046a198a9f9429e3c051d67a
 SHA1 (patch-player_main.c) = 842432e448526a9d170e7efd2b01276e36072e16
diff -r ca15d711f35d -r cae361933338 multimedia/mpv/options.mk
--- a/multimedia/mpv/options.mk Sun Jul 16 11:42:59 2017 +0000
+++ b/multimedia/mpv/options.mk Sun Jul 16 12:06:25 2017 +0000
@@ -1,11 +1,11 @@
-# $NetBSD: options.mk,v 1.13 2017/03/13 10:26:24 leot Exp $
+# $NetBSD: options.mk,v 1.14 2017/07/16 12:06:25 leot Exp $
 
 PKG_OPTIONS_VAR=       PKG_OPTIONS.mpv
 
 .include "../../multimedia/libva/available.mk"
 .include "../../multimedia/libvdpau/available.mk"
 
-PKG_SUPPORTED_OPTIONS= ass caca lua pulseaudio rpi sdl sdl2 v4l2 
+PKG_SUPPORTED_OPTIONS= ass caca lua pulseaudio rpi sdl sdl2 v4l2
 PKG_SUGGESTED_OPTIONS= ass lua pulseaudio
 
 .if ${VAAPI_AVAILABLE} == "yes"
diff -r ca15d711f35d -r cae361933338 multimedia/mpv/patches/patch-audio_out_ao__oss.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/multimedia/mpv/patches/patch-audio_out_ao__oss.c  Sun Jul 16 12:06:25 2017 +0000
@@ -0,0 +1,40 @@
+$NetBSD: patch-audio_out_ao__oss.c,v 1.4 2017/07/16 12:06:25 leot Exp $
+
+ioctl(..., SNDCTL_DSP_CHANNELS, &nchannels) for not supported nchannels does not
+return an error and instead set nchannels to the default value. Instead of
+failing with no audio, fallback to stereo or mono.
+
+Fallback logic inspired by `OSS v3 Programmer's guide', p. 34.
+
+--- audio/out/ao_oss.c.orig    2017-02-12 01:31:16.000000000 +0000
++++ audio/out/ao_oss.c
+@@ -345,13 +345,26 @@ static int reopen_device(struct ao *ao, 
+         // We only use SNDCTL_DSP_CHANNELS for >2 channels, in case some drivers don't have it
+         if (reqchannels > 2) {
+             int nchannels = reqchannels;
+-            if (ioctl(p->audio_fd, SNDCTL_DSP_CHANNELS, &nchannels) == -1 ||
+-                nchannels != reqchannels)
+-            {
++            if (ioctl(p->audio_fd, SNDCTL_DSP_CHANNELS, &nchannels) == -1) {
+                 MP_ERR(ao, "Failed to set audio device to %d channels.\n",
+                        reqchannels);
+                 goto fail;
+             }
++            if (nchannels != reqchannels) {
++                // Fallback to stereo or mono
++                int c;
++                for (nchannels = c = 2; c >= 1; c--, nchannels--) {
++                    if (ioctl(p->audio_fd, SNDCTL_DSP_CHANNELS, &c) == -1) {
++                        MP_ERR(ao, "Failed to set audio device to %d channels.\n", c);
++                        goto fail;
++                    }
++                    if (c == nchannels)
++                        break;
++                }
++                if (!ao_chmap_sel_get_def(ao, &sel, &channels, c))
++                    goto fail;
++                MP_WARN(ao, "using %d channels (requested: %d)\n", channels.num, reqchannels);
++            }
+         } else {
+             int c = reqchannels - 1;
+             if (ioctl(p->audio_fd, SNDCTL_DSP_STEREO, &c) == -1) {



Home | Main Index | Thread Index | Old Index