diff options
author | leot <leot@pkgsrc.org> | 2018-10-23 12:14:54 +0000 |
---|---|---|
committer | leot <leot@pkgsrc.org> | 2018-10-23 12:14:54 +0000 |
commit | 329e16a969bac9937ee90bfdc63e18a9accfd18f (patch) | |
tree | f188ab72c81e8f0a4e006549a910e5899a5e098f /multimedia | |
parent | ab7eade810e2f1670f75c1da4a47bc45fc67fe20 (diff) | |
download | pkgsrc-329e16a969bac9937ee90bfdc63e18a9accfd18f.tar.gz |
mpv: Rework logic of patch-audio_out_ao__oss.c to avoid (mostly) duplicated code
Diffstat (limited to 'multimedia')
-rw-r--r-- | multimedia/mpv/distinfo | 4 | ||||
-rw-r--r-- | multimedia/mpv/patches/patch-audio_out_ao__oss.c | 41 |
2 files changed, 22 insertions, 23 deletions
diff --git a/multimedia/mpv/distinfo b/multimedia/mpv/distinfo index 5c91c4746f2..1a9ec6cc912 100644 --- a/multimedia/mpv/distinfo +++ b/multimedia/mpv/distinfo @@ -1,8 +1,8 @@ -$NetBSD: distinfo,v 1.43 2018/10/03 09:07:20 leot Exp $ +$NetBSD: distinfo,v 1.44 2018/10/23 12:14:54 leot Exp $ SHA1 (mpv-0.29.1.tar.gz) = 83f2bc0eb5a8bec9a9d5efc7de0e19a442238ac5 RMD160 (mpv-0.29.1.tar.gz) = 72a4fda3a72ac4fd37ed04435833fa2cf378a012 SHA512 (mpv-0.29.1.tar.gz) = ec57c9ceaaf2915ee237dd5a1c5ea5d22725d8611e28a9b998e5bb0d8ab5bdf3631d0267fc7b54da31cb1eaa145ef35841e68846bd41c3b9e1024902e92fd086 Size (mpv-0.29.1.tar.gz) = 3059503 bytes -SHA1 (patch-audio_out_ao__oss.c) = d7f3a75ab43efe396ce536fb54e6207a7ded3510 +SHA1 (patch-audio_out_ao__oss.c) = b957a3a2cdb58d2c083c7098571485eea3c8f46d SHA1 (patch-player_main.c) = e794199990059cc95050032194bca70557c381d7 diff --git a/multimedia/mpv/patches/patch-audio_out_ao__oss.c b/multimedia/mpv/patches/patch-audio_out_ao__oss.c index 77cd440e03c..e77d3746a68 100644 --- a/multimedia/mpv/patches/patch-audio_out_ao__oss.c +++ b/multimedia/mpv/patches/patch-audio_out_ao__oss.c @@ -1,16 +1,21 @@ -$NetBSD: patch-audio_out_ao__oss.c,v 1.6 2017/09/13 10:35:58 leot Exp $ +$NetBSD: patch-audio_out_ao__oss.c,v 1.7 2018/10/23 12:14:54 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. + failing with no audio, fallbacks to stereo. ---- audio/out/ao_oss.c.orig 2017-07-22 17:01:42.955374723 +0000 +--- audio/out/ao_oss.c.orig 2018-10-02 19:03:41.000000000 +0000 +++ audio/out/ao_oss.c -@@ -332,13 +332,26 @@ static int reopen_device(struct ao *ao, +@@ -336,19 +336,23 @@ static int reopen_device(struct ao *ao, + mp_chmap_sel_add_map(&sel, &oss_layouts[n]); + if (!ao_chmap_sel_adjust(ao, &sel, &channels)) + goto fail; +- int reqchannels = channels.num; ++ int nchannels, reqchannels; ++ nchannels = reqchannels = channels.num; // We only use SNDCTL_DSP_CHANNELS for >2 channels, in case some drivers don't have it if (reqchannels > 2) { - int nchannels = reqchannels; +- int nchannels = reqchannels; - if (ioctl(p->audio_fd, SNDCTL_DSP_CHANNELS, &nchannels) == -1 || - nchannels != reqchannels) - { @@ -19,21 +24,15 @@ $NetBSD: patch-audio_out_ao__oss.c,v 1.6 2017/09/13 10:35:58 leot Exp $ reqchannels); goto fail; } + } else { +- int c = reqchannels - 1; ++ int c; + 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); ++ // Fallback to stereo ++ c = 1; ++ } else { ++ c = reqchannels - 1; + } - } else { - int c = reqchannels - 1; if (ioctl(p->audio_fd, SNDCTL_DSP_STEREO, &c) == -1) { + MP_ERR(ao, "Failed to set audio device to %d channels.\n", + reqchannels); |