Gentoo Archives: gentoo-commits

From: Lars Wendler <polynomial-c@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: media-plugins/alsa-plugins/files/, media-plugins/alsa-plugins/
Date: Thu, 20 Feb 2020 15:49:47
Message-Id: 1582213772.a33c9086ce400e80dba0944c142460fda822f640.polynomial-c@gentoo
1 commit: a33c9086ce400e80dba0944c142460fda822f640
2 Author: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
3 AuthorDate: Thu Feb 20 15:42:05 2020 +0000
4 Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
5 CommitDate: Thu Feb 20 15:49:32 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a33c9086
7
8 media-plugins/alsa-plugins: Removed old
9
10 Package-Manager: Portage-2.3.89, Repoman-2.3.20
11 Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>
12
13 media-plugins/alsa-plugins/Manifest | 1 -
14 .../alsa-plugins/alsa-plugins-1.1.1-r1.ebuild | 100 ------
15 .../alsa-plugins/alsa-plugins-1.1.9-r1.ebuild | 103 -------
16 .../files/alsa-plugins-1.0.23-automagic.patch | 12 -
17 .../files/alsa-plugins-1.0.28-libav10.patch | 338 ---------------------
18 5 files changed, 554 deletions(-)
19
20 diff --git a/media-plugins/alsa-plugins/Manifest b/media-plugins/alsa-plugins/Manifest
21 index f307fab4030..9d8379446d6 100644
22 --- a/media-plugins/alsa-plugins/Manifest
23 +++ b/media-plugins/alsa-plugins/Manifest
24 @@ -1,4 +1,3 @@
25 -DIST alsa-plugins-1.1.1.tar.bz2 366193 BLAKE2B 02892b0c241cf34d3bfce6cf580dbb6bedbce9253c3e57f04d3093a6cbb1d5b5e9b92566945962b875de20ba3e556e9c1fc4bb4e970502e3c03fc821e5e264fe SHA512 9dd277cb5cce144ce4e5e0010cebcba0f8634c783e7bcd80ce6d04b198d6de5150a2764df3087a39a468b5fb7c4578de2e252095568e811dedaa5e7ffdbeb7c9
26 DIST alsa-plugins-1.1.8.tar.bz2 375346 BLAKE2B 65c161ee375e7aed85dbe918a39bc2aa4818bbcfbaadf405f5f0170d9944ff55b5a9da3690e3cd78bd7ffff74ecf235f49cfc3a5dfe18b627c5a9cb0dc1eb207 SHA512 bb1a4411921ec332f47b43515f6d3b4c03a01568854950b9b5c3f0d8172d9a0c4a5b3652bc64c62eae5ea3aaa5d95fe3d32c0a213fe99adf490a9807bcb58ecd
27 DIST alsa-plugins-1.1.9.tar.bz2 406127 BLAKE2B 10bf3e96289a88edabfa3018d33ab4666982fe409eb41c486e6b9eee0dde87e926f3241c31e240b3bab114c8ab2c6d6bab92dd6192bceb467a01fcb6adc44b8e SHA512 1969dfe8f2bb4283e81a18da73d2f7f86d8788d1a8764d7195b4830b2f4704c208eacb50a1e26e20c9fe57e7d5bb06a004112d84cc86b4682b4180d2fec4d5d9
28 DIST alsa-plugins-1.2.1.tar.bz2 406309 BLAKE2B 2ac26ad87fcdcc4452ec32b2b437d3be4308f13ce2a8e24150f319805b6d684edc6be9e51654f27c1a5bbc01a7caa9eb70250be405dc6921ecd93ee417f24cdf SHA512 a49ef9290b66855112e301a5fd5a0932f13a50254e164f3340f2b342a36469532ee783beabfe5e95870dbf4cd81ca1e8d0415d94c8c7ee963133fb3c343721de
29
30 diff --git a/media-plugins/alsa-plugins/alsa-plugins-1.1.1-r1.ebuild b/media-plugins/alsa-plugins/alsa-plugins-1.1.1-r1.ebuild
31 deleted file mode 100644
32 index ea2912e9c1b..00000000000
33 --- a/media-plugins/alsa-plugins/alsa-plugins-1.1.1-r1.ebuild
34 +++ /dev/null
35 @@ -1,100 +0,0 @@
36 -# Copyright 1999-2020 Gentoo Authors
37 -# Distributed under the terms of the GNU General Public License v2
38 -
39 -EAPI=6
40 -inherit autotools eutils flag-o-matic ltprune multilib multilib-minimal
41 -
42 -DESCRIPTION="ALSA extra plugins"
43 -HOMEPAGE="http://www.alsa-project.org/"
44 -SRC_URI="https://www.alsa-project.org/files/pub/plugins/${P}.tar.bz2"
45 -
46 -LICENSE="GPL-2 LGPL-2.1"
47 -SLOT="0"
48 -KEYWORDS="~alpha amd64 arm hppa ia64 ppc ppc64 ~sh sparc x86 ~amd64-linux"
49 -IUSE="debug ffmpeg jack libav libsamplerate pulseaudio speex"
50 -
51 -RDEPEND="
52 - >=media-libs/alsa-lib-${PV}:=[${MULTILIB_USEDEP}]
53 - ffmpeg? (
54 - libav? ( media-video/libav:= )
55 - !libav? ( media-video/ffmpeg:0= )
56 - )
57 - jack? ( virtual/jack[${MULTILIB_USEDEP}] )
58 - libsamplerate? ( >=media-libs/libsamplerate-0.1.8-r1:=[${MULTILIB_USEDEP}] )
59 - pulseaudio? ( >=media-sound/pulseaudio-2.1-r1[${MULTILIB_USEDEP}] )
60 - speex? (
61 - >=media-libs/speex-1.2.0:=[${MULTILIB_USEDEP}]
62 - media-libs/speexdsp[${MULTILIB_USEDEP}]
63 - )
64 -"
65 -DEPEND="${RDEPEND}
66 - virtual/pkgconfig"
67 -
68 -PATCHES=(
69 - "${FILESDIR}/${PN}-1.0.23-automagic.patch"
70 - "${FILESDIR}/${PN}-1.0.28-libav10.patch"
71 -)
72 -
73 -src_prepare() {
74 - default
75 -
76 - # For some reasons the polyp/pulse plugin does fail with alsaplayer with a
77 - # failed assert. As the code works just fine with asserts disabled, for now
78 - # disable them waiting for a better solution.
79 - sed -i \
80 - -e '/AM_CFLAGS/s:-Wall:-DNDEBUG -Wall:' \
81 - pulse/Makefile.am || die
82 -
83 - eautoreconf
84 -}
85 -
86 -multilib_src_configure() {
87 - use debug || append-cppflags -DNDEBUG
88 -
89 - local myspeex=no
90 - use speex && myspeex=lib
91 -
92 - ECONF_SOURCE=${S} \
93 - econf \
94 - $(use_enable ffmpeg avcodec) \
95 - $(use_enable jack) \
96 - $(use_enable libsamplerate samplerate) \
97 - $(use_enable pulseaudio) \
98 - --with-speex=${myspeex}
99 -}
100 -
101 -multilib_src_install_all() {
102 - einstalldocs
103 -
104 - cd doc || die
105 - dodoc upmix.txt vdownmix.txt README-pcm-oss
106 - use jack && dodoc README-jack
107 - use libsamplerate && dodoc samplerate.txt
108 - use ffmpeg && dodoc lavcrate.txt a52.txt
109 -
110 - if use pulseaudio; then
111 - dodoc README-pulse
112 - # install ALSA configuration files
113 - # making PA to be used by alsa clients
114 - insinto /usr/share/alsa
115 - doins "${FILESDIR}"/pulse-default.conf
116 - insinto /usr/share/alsa/alsa.conf.d
117 - doins "${FILESDIR}"/51-pulseaudio-probe.conf
118 - # bug #410261, comment 5+
119 - # seems to work fine without any path
120 - sed -i \
121 - -e "s:/usr/lib/alsa-lib/::" \
122 - "${ED}"/usr/share/alsa/alsa.conf.d/51-pulseaudio-probe.conf || die #410261
123 - fi
124 -
125 - prune_libtool_files --all
126 -}
127 -
128 -pkg_postinst() {
129 - if use pulseaudio; then
130 - einfo "The PulseAudio device is now set as the default device if the"
131 - einfo "PulseAudio server is found to be running. Any custom"
132 - einfo "configuration in /etc/asound.conf or ~/.asoundrc for this"
133 - einfo "purpose should now be unnecessary."
134 - fi
135 -}
136
137 diff --git a/media-plugins/alsa-plugins/alsa-plugins-1.1.9-r1.ebuild b/media-plugins/alsa-plugins/alsa-plugins-1.1.9-r1.ebuild
138 deleted file mode 100644
139 index fba448266fc..00000000000
140 --- a/media-plugins/alsa-plugins/alsa-plugins-1.1.9-r1.ebuild
141 +++ /dev/null
142 @@ -1,103 +0,0 @@
143 -# Copyright 1999-2019 Gentoo Authors
144 -# Distributed under the terms of the GNU General Public License v2
145 -
146 -EAPI=7
147 -inherit autotools flag-o-matic multilib multilib-minimal
148 -
149 -DESCRIPTION="ALSA extra plugins"
150 -HOMEPAGE="http://www.alsa-project.org/"
151 -SRC_URI="https://www.alsa-project.org/files/pub/plugins/${P}.tar.bz2"
152 -
153 -LICENSE="GPL-2 LGPL-2.1"
154 -SLOT="0"
155 -KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~sh ~sparc ~x86 ~amd64-linux"
156 -IUSE="arcam_av debug ffmpeg jack libav libsamplerate +mix oss pulseaudio speex +usb_stream"
157 -
158 -RDEPEND="
159 - >=media-libs/alsa-lib-${PV}:=[${MULTILIB_USEDEP}]
160 - ffmpeg? (
161 - libav? ( media-video/libav:= )
162 - !libav? ( media-video/ffmpeg:0= )
163 - )
164 - jack? ( virtual/jack[${MULTILIB_USEDEP}] )
165 - libsamplerate? ( >=media-libs/libsamplerate-0.1.8-r1:=[${MULTILIB_USEDEP}] )
166 - pulseaudio? ( >=media-sound/pulseaudio-2.1-r1[${MULTILIB_USEDEP}] )
167 - speex? (
168 - >=media-libs/speex-1.2.0:=[${MULTILIB_USEDEP}]
169 - media-libs/speexdsp[${MULTILIB_USEDEP}]
170 - )
171 -"
172 -DEPEND="${RDEPEND}"
173 -BDEPEND="virtual/pkgconfig"
174 -
175 -src_prepare() {
176 - default
177 -
178 - # For some reasons the polyp/pulse plugin does fail with alsaplayer with a
179 - # failed assert. As the code works just fine with asserts disabled, for now
180 - # disable them waiting for a better solution.
181 - sed -i \
182 - -e '/AM_CFLAGS/s:-Wall:-DNDEBUG -Wall:' \
183 - pulse/Makefile.am || die
184 -
185 - eautoreconf
186 -}
187 -
188 -multilib_src_configure() {
189 - use debug || append-cppflags -DNDEBUG
190 -
191 - local myeconfargs=(
192 - # default does not contain $prefix: bug #673464
193 - --with-alsalconfdir="${EPREFIX}"/etc/alsa/conf.d
194 -
195 - --with-speex="$(usex speex lib no)"
196 - $(use_enable arcam_av arcamav)
197 - $(use_enable ffmpeg libav)
198 - $(use_enable jack)
199 - $(use_enable libsamplerate samplerate)
200 - $(use_enable mix)
201 - $(use_enable oss)
202 - $(use_enable pulseaudio)
203 - $(use_enable speex speexdsp)
204 - $(use_enable usb_stream usbstream)
205 - )
206 - ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
207 -}
208 -
209 -multilib_src_install_all() {
210 - einstalldocs
211 -
212 - cd doc || die
213 - dodoc upmix.txt vdownmix.txt README-pcm-oss
214 - use jack && dodoc README-jack
215 - use libsamplerate && dodoc samplerate.txt
216 - use ffmpeg && dodoc lavrate.txt a52.txt
217 -
218 - if use pulseaudio; then
219 - dodoc README-pulse
220 - # install ALSA configuration files
221 - # making PA to be used by alsa clients
222 - insinto /usr/share/alsa
223 - doins "${FILESDIR}"/pulse-default.conf
224 - insinto /usr/share/alsa/alsa.conf.d
225 - doins "${FILESDIR}"/51-pulseaudio-probe.conf
226 - # bug #410261, comment 5+
227 - # seems to work fine without any path
228 - sed -i \
229 - -e "s:/usr/lib/alsa-lib/::" \
230 - "${ED}"/usr/share/alsa/alsa.conf.d/51-pulseaudio-probe.conf || die #410261
231 - dosym ../../../usr/share/alsa/alsa.conf.d/51-pulseaudio-probe.conf \
232 - /etc/alsa/conf.d/51-pulseaudio-probe.conf #670960
233 - fi
234 -
235 - find "${ED}" \( -name '*.a' -o -name '*.la' \) -delete || die
236 -}
237 -
238 -pkg_postinst() {
239 - if use pulseaudio; then
240 - einfo "The PulseAudio device is now set as the default device if the"
241 - einfo "PulseAudio server is found to be running. Any custom"
242 - einfo "configuration in /etc/asound.conf or ~/.asoundrc for this"
243 - einfo "purpose should now be unnecessary."
244 - fi
245 -}
246
247 diff --git a/media-plugins/alsa-plugins/files/alsa-plugins-1.0.23-automagic.patch b/media-plugins/alsa-plugins/files/alsa-plugins-1.0.23-automagic.patch
248 deleted file mode 100644
249 index 8e62f20a143..00000000000
250 --- a/media-plugins/alsa-plugins/files/alsa-plugins-1.0.23-automagic.patch
251 +++ /dev/null
252 @@ -1,12 +0,0 @@
253 -diff -uNr alsa-plugins-1.0.23.ORIg//Makefile.am alsa-plugins-1.0.23/Makefile.am
254 ---- alsa-plugins-1.0.23.ORIg//Makefile.am 2010-04-16 23:38:58.546243512 +0100
255 -+++ alsa-plugins-1.0.23/Makefile.am 2010-04-16 23:39:20.049278487 +0100
256 -@@ -17,7 +17,7 @@
257 - if HAVE_PPH
258 - SUBDIRS += pph
259 - endif
260 --if HAVE_SPEEXDSP
261 -+if USE_LIBSPEEX
262 - SUBDIRS += speex
263 - endif
264 -
265
266 diff --git a/media-plugins/alsa-plugins/files/alsa-plugins-1.0.28-libav10.patch b/media-plugins/alsa-plugins/files/alsa-plugins-1.0.28-libav10.patch
267 deleted file mode 100644
268 index 9718369782b..00000000000
269 --- a/media-plugins/alsa-plugins/files/alsa-plugins-1.0.28-libav10.patch
270 +++ /dev/null
271 @@ -1,338 +0,0 @@
272 -https://bugs.gentoo.org/539680
273 -
274 -From: Luca Barbato <lu_zero@g.o>
275 -Description: lavr: Add a libavresample based rate plugin
276 -Date: Mon, 14 Apr 2014 10:01:07 +0200
277 -
278 -Provide lavcrate compatibility.
279 -
280 -Index: alsa-plugins-1.0.28/configure.ac
281 -===================================================================
282 ---- alsa-plugins-1.0.28.orig/configure.ac
283 -+++ alsa-plugins-1.0.28/configure.ac
284 -@@ -66,7 +66,7 @@ if test "$use_maemo_rm" = "yes"; then
285 - fi
286 -
287 - AC_ARG_ENABLE([avcodec],
288 -- AS_HELP_STRING([--disable-avcodec], [Don't build plugins depending on avcodec (a52)]))
289 -+ AS_HELP_STRING([--disable-avcodec], [Do not build plugins depending on avcodec (a52)]))
290 -
291 - if test "x$enable_avcodec" != "xno"; then
292 - PKG_CHECK_MODULES(AVCODEC, [libavcodec libavutil], [HAVE_AVCODEC=yes], [HAVE_AVCODEC=no])
293 -@@ -101,6 +101,10 @@ if test $HAVE_AVCODEC = yes; then
294 - if test -z "$AVCODEC_HEADER"; then
295 - HAVE_AVCODEC=no
296 - fi
297 -+ SAVE_LIBS=$LIBS
298 -+ LIBS="$LIBS $AVCODEC_LIBS"
299 -+ AC_CHECK_FUNCS([av_resample_init])
300 -+ LIBS=$SAVE_LIBS
301 - fi
302 -
303 - AM_CONDITIONAL(HAVE_AVCODEC, test x$HAVE_AVCODEC = xyes)
304 -@@ -108,6 +112,18 @@ AC_SUBST(AVCODEC_CFLAGS)
305 - AC_SUBST(AVCODEC_LIBS)
306 - AC_SUBST(AVCODEC_HEADER)
307 -
308 -+AC_ARG_ENABLE([avresample],
309 -+ AS_HELP_STRING([--disable-avresample], [Do not build plugins depending on avcodec (lavrate)]))
310 -+
311 -+if test "x$enable_avresample" != "xno"; then
312 -+ PKG_CHECK_MODULES(AVRESAMPLE, [libavresample libavutil], [HAVE_AVRESAMPLE=yes], [HAVE_AVRESAMPLE=no])
313 -+fi
314 -+
315 -+AM_CONDITIONAL(HAVE_AVRESAMPLE, test x$HAVE_AVCODEC = xyes)
316 -+AC_SUBST(AVRESAMPLE_CFLAGS)
317 -+AC_SUBST(AVRESAMPLE_LIBS)
318 -+AC_SUBST(AVRESAMPLE_HEADER)
319 -+
320 - PKG_CHECK_MODULES(speexdsp, [speexdsp >= 1.2], [HAVE_SPEEXDSP="yes"], [HAVE_SPEEXDSP=""])
321 - AM_CONDITIONAL(HAVE_SPEEXDSP, test "$HAVE_SPEEXDSP" = "yes")
322 -
323 -@@ -181,7 +197,7 @@ AC_OUTPUT([
324 - mix/Makefile
325 - rate/Makefile
326 - a52/Makefile
327 -- rate-lavc/Makefile
328 -+ rate-lavr/Makefile
329 - maemo/Makefile
330 - doc/Makefile
331 - usb_stream/Makefile
332 -Index: alsa-plugins-1.0.28/Makefile.am
333 -===================================================================
334 ---- alsa-plugins-1.0.28.orig/Makefile.am
335 -+++ alsa-plugins-1.0.28/Makefile.am
336 -@@ -9,8 +9,14 @@ if HAVE_SAMPLERATE
337 - SUBDIRS += rate
338 - endif
339 - if HAVE_AVCODEC
340 -+SUBDIRS += a52
341 -+if !HAVE_AVRESAMPLE
342 - SUBDIRS += a52 rate-lavc
343 - endif
344 -+endif
345 -+if HAVE_AVRESAMPLE
346 -+SUBDIRS += rate-lavr
347 -+endif
348 - if HAVE_MAEMO_PLUGIN
349 - SUBDIRS += maemo
350 - endif
351 -Index: alsa-plugins-1.0.28/rate-lavr/Makefile.am
352 -===================================================================
353 ---- /dev/null
354 -+++ alsa-plugins-1.0.28/rate-lavr/Makefile.am
355 -@@ -0,0 +1,22 @@
356 -+asound_module_rate_lavr_LTLIBRARIES = libasound_module_rate_lavr.la
357 -+
358 -+asound_module_rate_lavrdir = @ALSA_PLUGIN_DIR@
359 -+
360 -+AM_CFLAGS = -Wall -g @ALSA_CFLAGS@ @AVRESAMPLE_CFLAGS@
361 -+AM_LDFLAGS = -module -avoid-version -export-dynamic -no-undefined $(LDFLAGS_NOUNDEFINED)
362 -+
363 -+libasound_module_rate_lavr_la_SOURCES = rate_lavr.c
364 -+libasound_module_rate_lavr_la_LIBADD = @ALSA_LIBS@ @AVRESAMPLE_LIBS@
365 -+
366 -+
367 -+install-exec-hook:
368 -+ rm -f $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavcrate*.so
369 -+ $(LN_S) libasound_module_rate_lavr.so $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavcrate.so
370 -+ $(LN_S) libasound_module_rate_lavr.so $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavcrate_higher.so
371 -+ $(LN_S) libasound_module_rate_lavr.so $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavcrate_high.so
372 -+ $(LN_S) libasound_module_rate_lavr.so $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavcrate_fast.so
373 -+ $(LN_S) libasound_module_rate_lavr.so $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavcrate_faster.so
374 -+
375 -+uninstall-hook:
376 -+ rm -f $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavcrate*.so
377 -+ rm -f $(DESTDIR)@ALSA_PLUGIN_DIR@/libasound_module_rate_lavr*.so
378 -Index: alsa-plugins-1.0.28/rate-lavr/rate_lavr.c
379 -===================================================================
380 ---- /dev/null
381 -+++ alsa-plugins-1.0.28/rate-lavr/rate_lavr.c
382 -@@ -0,0 +1,227 @@
383 -+/*
384 -+ * Rate converter plugin using libavresample
385 -+ * Copyright (c) 2014 by Anton Khirnov
386 -+ *
387 -+ * This library is free software; you can redistribute it and/or
388 -+ * modify it under the terms of the GNU Lesser General Public
389 -+ * License as published by the Free Software Foundation; either
390 -+ * version 2.1 of the License, or (at your option) any later version.
391 -+ *
392 -+ * This library is distributed in the hope that it will be useful,
393 -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
394 -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
395 -+ * Lesser General Public License for more details.
396 -+ */
397 -+
398 -+#include <stdio.h>
399 -+#include <alsa/asoundlib.h>
400 -+#include <alsa/pcm_rate.h>
401 -+
402 -+#include <libavresample/avresample.h>
403 -+#include <libavutil/channel_layout.h>
404 -+#include <libavutil/opt.h>
405 -+#include <libavutil/mathematics.h>
406 -+#include <libavutil/samplefmt.h>
407 -+
408 -+
409 -+static int filter_size = 16;
410 -+static int phase_shift = 10; /* auto-adjusts */
411 -+static double cutoff = 0; /* auto-adjusts */
412 -+
413 -+struct rate_src {
414 -+ AVAudioResampleContext *avr;
415 -+
416 -+ int in_rate;
417 -+ int out_rate;
418 -+ unsigned int channels;
419 -+};
420 -+
421 -+static snd_pcm_uframes_t input_frames(void *obj, snd_pcm_uframes_t frames)
422 -+{
423 -+ return frames;
424 -+}
425 -+
426 -+static snd_pcm_uframes_t output_frames(void *obj, snd_pcm_uframes_t frames)
427 -+{
428 -+ return frames;
429 -+}
430 -+
431 -+static void pcm_src_free(void *obj)
432 -+{
433 -+ struct rate_src *rate = obj;
434 -+ avresample_free(&rate->avr);
435 -+}
436 -+
437 -+static int pcm_src_init(void *obj, snd_pcm_rate_info_t *info)
438 -+{
439 -+ struct rate_src *rate = obj;
440 -+ int i, ir, or;
441 -+
442 -+ if (!rate->avr || rate->channels != info->channels) {
443 -+ int ret;
444 -+
445 -+ pcm_src_free(rate);
446 -+ rate->channels = info->channels;
447 -+ ir = rate->in_rate = info->in.rate;
448 -+ or = rate->out_rate = info->out.rate;
449 -+ i = av_gcd(or, ir);
450 -+ if (or > ir) {
451 -+ phase_shift = or/i;
452 -+ } else {
453 -+ phase_shift = ir/i;
454 -+ }
455 -+ if (cutoff <= 0.0) {
456 -+ cutoff = 1.0 - 1.0/filter_size;
457 -+ if (cutoff < 0.80)
458 -+ cutoff = 0.80;
459 -+ }
460 -+
461 -+ rate->avr = avresample_alloc_context();
462 -+ if (!rate->avr)
463 -+ return -ENOMEM;
464 -+
465 -+ av_opt_set_int(rate->avr, "in_sample_rate", info->in.rate, 0);
466 -+ av_opt_set_int(rate->avr, "out_sample_rate", info->out.rate, 0);
467 -+ av_opt_set_int(rate->avr, "in_sample_format", AV_SAMPLE_FMT_S16, 0);
468 -+ av_opt_set_int(rate->avr, "out_sample_format", AV_SAMPLE_FMT_S16, 0);
469 -+ av_opt_set_int(rate->avr, "in_channel_layout", av_get_default_channel_layout(rate->channels), 0);
470 -+ av_opt_set_int(rate->avr, "out_channel_layout", av_get_default_channel_layout(rate->channels), 0);
471 -+
472 -+ av_opt_set_int(rate->avr, "filter_size", filter_size, 0);
473 -+ av_opt_set_int(rate->avr, "phase_shift", phase_shift, 0);
474 -+ av_opt_set_double(rate->avr, "cutoff", cutoff, 0);
475 -+
476 -+ ret = avresample_open(rate->avr);
477 -+ if (ret < 0) {
478 -+ avresample_free(&rate->avr);
479 -+ return -EINVAL;
480 -+ }
481 -+ }
482 -+
483 -+ return 0;
484 -+}
485 -+
486 -+static int pcm_src_adjust_pitch(void *obj, snd_pcm_rate_info_t *info)
487 -+{
488 -+ struct rate_src *rate = obj;
489 -+
490 -+ if (info->out.rate != rate->out_rate || info->in.rate != rate->in_rate)
491 -+ pcm_src_init(obj, info);
492 -+ return 0;
493 -+}
494 -+
495 -+static void pcm_src_reset(void *obj)
496 -+{
497 -+ struct rate_src *rate = obj;
498 -+
499 -+ if (rate->avr) {
500 -+ avresample_close(rate->avr);
501 -+ avresample_open(rate->avr);
502 -+ }
503 -+}
504 -+
505 -+static void pcm_src_convert_s16(void *obj, int16_t *dst, unsigned int
506 -+ dst_frames, const int16_t *src, unsigned int src_frames)
507 -+{
508 -+ struct rate_src *rate = obj;
509 -+ int consumed = 0, chans=rate->channels, ret=0, i;
510 -+ int total_in = avresample_get_delay(rate->avr) + src_frames;
511 -+
512 -+ ret = avresample_convert(rate->avr, &dst, dst_frames * chans * 2, dst_frames,
513 -+ &src, src_frames * chans * 2, src_frames);
514 -+
515 -+ avresample_set_compensation(rate->avr,
516 -+ total_in - src_frames > filter_size ? 0 : 1, src_frames);
517 -+}
518 -+
519 -+static void pcm_src_close(void *obj)
520 -+{
521 -+ pcm_src_free(obj);
522 -+}
523 -+
524 -+#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
525 -+static int get_supported_rates(void *obj, unsigned int *rate_min,
526 -+ unsigned int *rate_max)
527 -+{
528 -+ *rate_min = *rate_max = 0; /* both unlimited */
529 -+ return 0;
530 -+}
531 -+
532 -+static void dump(void *obj, snd_output_t *out)
533 -+{
534 -+ snd_output_printf(out, "Converter: libavr\n");
535 -+}
536 -+#endif
537 -+
538 -+static snd_pcm_rate_ops_t pcm_src_ops = {
539 -+ .close = pcm_src_close,
540 -+ .init = pcm_src_init,
541 -+ .free = pcm_src_free,
542 -+ .adjust_pitch = pcm_src_adjust_pitch,
543 -+ .convert_s16 = pcm_src_convert_s16,
544 -+ .input_frames = input_frames,
545 -+ .output_frames = output_frames,
546 -+#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
547 -+ .version = SND_PCM_RATE_PLUGIN_VERSION,
548 -+ .get_supported_rates = get_supported_rates,
549 -+ .dump = dump,
550 -+#endif
551 -+};
552 -+
553 -+int pcm_src_open(unsigned int version, void **objp, snd_pcm_rate_ops_t *ops)
554 -+
555 -+{
556 -+ struct rate_src *rate;
557 -+
558 -+#if SND_PCM_RATE_PLUGIN_VERSION < 0x010002
559 -+ if (version != SND_PCM_RATE_PLUGIN_VERSION) {
560 -+ fprintf(stderr, "Invalid rate plugin version %x\n", version);
561 -+ return -EINVAL;
562 -+ }
563 -+#endif
564 -+ rate = calloc(1, sizeof(*rate));
565 -+ if (!rate)
566 -+ return -ENOMEM;
567 -+
568 -+ *objp = rate;
569 -+ rate->avr = NULL;
570 -+#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
571 -+ if (version == 0x010001)
572 -+ memcpy(ops, &pcm_src_ops, sizeof(snd_pcm_rate_old_ops_t));
573 -+ else
574 -+#endif
575 -+ *ops = pcm_src_ops;
576 -+ return 0;
577 -+}
578 -+
579 -+int SND_PCM_RATE_PLUGIN_ENTRY(lavcrate)(unsigned int version, void **objp,
580 -+ snd_pcm_rate_ops_t *ops)
581 -+{
582 -+ return pcm_src_open(version, objp, ops);
583 -+}
584 -+int SND_PCM_RATE_PLUGIN_ENTRY(lavcrate_higher)(unsigned int version,
585 -+ void **objp, snd_pcm_rate_ops_t *ops)
586 -+{
587 -+ filter_size = 64;
588 -+ return pcm_src_open(version, objp, ops);
589 -+}
590 -+int SND_PCM_RATE_PLUGIN_ENTRY(lavcrate_high)(unsigned int version,
591 -+ void **objp, snd_pcm_rate_ops_t *ops)
592 -+{
593 -+ filter_size = 32;
594 -+ return pcm_src_open(version, objp, ops);
595 -+}
596 -+int SND_PCM_RATE_PLUGIN_ENTRY(lavcrate_fast)(unsigned int version,
597 -+ void **objp, snd_pcm_rate_ops_t *ops)
598 -+{
599 -+ filter_size = 8;
600 -+ return pcm_src_open(version, objp, ops);
601 -+}
602 -+int SND_PCM_RATE_PLUGIN_ENTRY(lavcrate_faster)(unsigned int version,
603 -+ void **objp, snd_pcm_rate_ops_t *ops)
604 -+{
605 -+ filter_size = 4;
606 -+ return pcm_src_open(version, objp, ops);
607 -+}
608 -+
609 -+