You are not logged in.

#51 2021-05-31 14:47:49

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 773
Website

Re: A52 plugin with alsa-plugins >1.1.6

manio wrote:

did you maybe tested if the latest alsa-plugin changes makes any difference to our problem?
There was 3 commits on 25 may regarding a52 plugin:
https://github.com/alsa-project/alsa-pl … master/a52

Oh wow, fresh commits after three years without updates. No, so far I've only gone upstream on ffmpeg. It looks like these could potentially solve our need to build a patched alsa-lib, but I've never had the symptoms described in the linked bug report. I'll give this a try as soon as I have some time.

regarding the commits we need to test I think it is worth to start bisecting using these:
https://github.com/FFmpeg/FFmpeg/commit … c/ac3enc.c
If anything wrong happens there (in ac3 encoder) - it could directly hit our use-case.

Indeed, a targeted approach seems like a good idea. There are 3700 commits between the last working version and the latest stable release, but I did spot check and (unless I've done something terribly wrong) chopped it down to about 150 candidates over the weekend. Seems like whatever changed, it wasn't long after the release of 4.3.2.

------------

Edit: Sort of hit a wall here. I haven't narrowed it down to a particular commit, but approaching 4.3.2 in ffmpeg's commit log it fails to build with messages about undefined things in libsrt. These versions most likely depend on an earlier version of srt, which is now at 1.4.3-1 in [extra]. Trying to build the previous version of this package, 1.4.2-1, fails because it in turn appears to require earlier version of gcc. Compiling the compiler is a rather extreme measure, but that's what I am doing now: compiling the previous release of gcc in order to build srt against it in order to build (probably several versions of) ffmpeg against that in order to build alsa-lib-a52pcm against them... Hopefully srt builds against the immediately previous version of gcc; the compiler is updated rather frequently and takes even longer to build than ffmpeg and hopefully I get away with it (generally speaking, building one thing with a different version of the compiler than its dependency was built with does not work).

Edit again: looks like there's no building the previous version of srt without going back in time.

Last edited by quequotion (2021-06-02 14:08:26)

Online

#52 2021-06-05 19:51:18

manio
Member
Registered: 2021-05-05
Posts: 7

Re: A52 plugin with alsa-plugins >1.1.6

I found it smile
First bad commit:

commit 93016f5d1d280f9cb7856883af287fa66affc04c
Author: James Almer <jamrial@gmail.com>
Date:   Tue Jun 9 18:35:00 2020 -0300

    avcodec/encode: restructure the old encode API

    Following the same logic as 061a0c14bb, this commit turns the old encode API
    into a wrapper for the new one.

    Signed-off-by: James Almer <jamrial@gmail.com>

I've sent an email to James Almer...

@quequotion
I've tested with the following PKGBUILD:

diff --git a/trunk/PKGBUILD b/trunk/PKGBUILD
index 94058d1..be3abe8 100644
--- a/trunk/PKGBUILD
+++ b/trunk/PKGBUILD
@@ -106,14 +106,16 @@ sha256sums=(

 pkgver() {
   cd ffmpeg
-
-  git describe --tags | sed 's/^n//'
+  echo "4.4"
 }

 prepare() {
   cd ffmpeg
-  git cherry-pick -n 988f2e9eb063db7c1a678729f58aab6eba59a55b # fix nvenc on older gpus
-  patch -Np1 -i "${srcdir}"/vmaf-model-path.patch
+  #git cherry-pick -n 988f2e9eb063db7c1a678729f58aab6eba59a55b # fix nvenc on older gpus
+  #patch -Np1 -i "${srcdir}"/vmaf-model-path.patch
+
+  #git checkout 93016f5d1d   # first bad one
+  git checkout 827d6fe73d   # last OK
 }

 build() {
@@ -155,9 +157,7 @@ build() {
     --enable-librsvg \
     --enable-libsoxr \
     --enable-libspeex \
-    --enable-libsrt \
     --enable-libssh \
-    --enable-libsvtav1 \
     --enable-libtheora \
     --enable-libv4l2 \
     --enable-libvidstab \
@@ -176,7 +176,7 @@ build() {
     --enable-shared \
     --enable-version3

-  make
+  make -j4
   make tools/qt-faststart
   make doc/ff{mpeg,play}.1
 }

can you please also confirm it on your system?

update: I've got a back info from James that the A52 plugin is the one to blame as it unconditionally feeding the new ac3_fixed encoder with with wrong S16 planar audio...

edit 2: I was trying to fix the a52 plugin myself but unfortunately it was too hard for me, but I created an issue for this: https://github.com/alsa-project/alsa-plugins/issues/22

edit 3:
Some tips for you which are trying to build the alsa-plugins. The repository in Arch was upgraded to newest package version so doing it all according to @quequotion instructions will not work:
1. It will complain about missing pgp key - one workaround is to call it like this:

makechrootpkg -c -r $CHROOT -I ../../libavresample/libavresample-4.3.1-1-x86_64.pkg.tar.zst -- --skippgpcheck

note the skippgpcheck argument passed
2. It will not build because the usbstream. You can disable it in PKGBUILD by adding the line "--disable-usbstream \" in the ./configure / build() section

Otherwise you can checkout known good old version addind the bolded line:
[...]
cd alsa-plugins/trunk/
git checkout 0d52e87
[...]

Last edited by manio (2021-06-06 14:25:47)

Offline

#53 2021-06-06 16:30:44

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 773
Website

Re: A52 plugin with alsa-plugins >1.1.6

manio wrote:

I found it smile

Thank you for your hard work!

update: I've got a back info from James that the A52 plugin is the one to blame as it unconditionally feeding the new ac3_fixed encoder with with wrong S16 planar audio...

Progress! In the meantime I have tracked down Giovanni Harting (IdleGandalf) who wrote the patch for alsa-lib-a52pcm (fixing the config parser) and informed him of our plight. Perhaps he could be of assistance here.

@@ -155,9 +157,7 @@ build() {
     --enable-librsvg \
     --enable-libsoxr \
     --enable-libspeex \
-    --enable-libsrt \
     --enable-libssh \
-    --enable-libsvtav1 \
     --enable-libtheora \
     --enable-libv4l2 \
     --enable-libvidstab \

can you please also confirm it on your system?

I will give this a try after work tomorrow. For some reason I thought libsrt had to be enabled; it never occurred to me to try building without it.

The repository in Arch was upgraded to newest package version so doing it all according to @quequotion instructions will not work

The never-ending battle. After I confirm your build I'll go over the procedure again. There's probably a better way to avoid the pgp key issue.

It will not build because the usbstream.

Likely the same as the problem with libsrt: building an older version of ffmpeg against a newer Archlinux repository. Hopefully we can get the bug fixed in alsa-plugins so we can upgrade to the latest release of ffmpeg and not have this issue.

Last edited by quequotion (2021-06-07 23:27:06)

Online

#54 2021-06-06 17:23:09

manio
Member
Registered: 2021-05-05
Posts: 7

Re: A52 plugin with alsa-plugins >1.1.6

Yeah, maybe libsrt and libsvtav1 has to be enabled - I only removed it because I've built a wider range of commits when bisecting - and this was the reason...

Offline

#55 2021-06-07 17:57:00

IdleGandalf
Member
Registered: 2016-12-30
Posts: 4

Re: A52 plugin with alsa-plugins >1.1.6

Hi all, I wrote that patchset years ago.

I had a quick look, but my patches are not affected by whatever changed, as you previously guessed.

While looking through stuff I found this very recent commit: https://github.com/jamrial/alsa-plugins … 04d9476cf4

That seems to address at least one of the issues. Can someone test that to verify?

Offline

#56 2021-06-08 03:10:03

manio
Member
Registered: 2021-05-05
Posts: 7

Re: A52 plugin with alsa-plugins >1.1.6

@IdleGandalf
I know jamrial's pull request. I contacted him at the beginning when i discovered the "bad" commit. He is so kind, that he made some work on the plugin code which is adapting it to new API but this changes are not sufficient to give a clean sound (as he also mention in that pull request). I was trying to work on this yesterday (on top of his changes) but the best I've got so far was a stuttering sound (on all newest packages).

Offline

#57 2021-06-10 16:16:47

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 773
Website

Re: A52 plugin with alsa-plugins >1.1.6

Finally got something to work, sort of. I managed to replicate @manio's results with @jamrial's patches: the a52 plugin is operational but sound quality is bad (choppy, grinding really; kind of what you'd expect from an encoder that requires 32bits but is recieving 16).

I have a new PKGBUILD: alsa-plugins-libswresample-git, which I have not yet published on the AUR (waiting to see if @jamrial's branch gets merged).

This mouthful of a pkgname includes @IdleGandalf's patches to use libswresample instead of libavresample (see alsa-plugins-libswresample), eliminating the need to build the deprecated library, as well as pulling @jamrial's branch to support the new libavc API.

Note that indeed usbstream has to be disabled (failing to find a function that ought to be provided by alsa-lib? todo: debug that).

pkgname=alsa-plugins-libswresample-git
_basename=alsa-plugins
provides=('alsa-plugins=1.2.2')
conflicts=(alsa-plugins)
pkgver=1.2.5.r4.g66b1db7
pkgrel=1
pkgdesc="Additional ALSA plugins (with libswresample support)"
arch=(x86_64)
url="https://www.alsa-project.org"
license=(LGPL2.1)
depends=(glibc libasound.so)
optdepends=('dbus: for maemo plugin'
            'jack: for pcm_jack plugin'
            'libavtp: for pcm_aaf plugin'
            'libsamplerate: for rate_samplerate plugin'
            'libpulse: for conf_pulse, ctl_pulse and pcm_pulse plugins'
            'speexdsp: for pcm_speex and rate_speexrate plugins'
            'ffmpeg: for a52 plugin')
makedepends=(alsa-lib dbus jack libavtp libpulse libsamplerate speexdsp ffmpeg)
source=(git+https://github.com/jamrial/alsa-plugins.git#branch=new_lavc_api
        pulse-sysdefault.diff
        "https://git.harting.dev/anonfunc/alsa-plugins/commit/9cdbbb9874757b6f8fda7fb4ac2e3fc59da65946.patch")
sha256sums=(SKIP
            'd8c59b891e2913619d057ffea308293d73892b16fa5a01583d056e372e55309d'
            'f1fc4fe7d3b4c34b244b276d109af9bfb0b501554e882749b22d4e9a6f3d7596')

pkgver() {
  cd $_basename
  git describe --long | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cd $_basename

  # Make use of the pulse plugin's "fallback" feature
  # Keeps parity with our old config from pulseaudio-alsa
  patch -Np1 -i ../pulse-sysdefault.diff
 
  # Make rate plugin use libswresample
  patch -Np1 -i ../9cdbbb9874757b6f8fda7fb4ac2e3fc59da65946.patch

  autoreconf -fvi
}

build() {
  cd $_basename
  ./configure \
    --disable-usbstream \
    --prefix=/usr \
    --sysconfdir=/etc \
    --enable-maemo-plugin \
    --enable-maemo-resource-manager
  make
}

package() {
  cd $_basename
  make DESTDIR="$pkgdir" install
  install -Dt "$pkgdir/usr/share/doc/$_basename" -m644 doc/README* doc/*.txt

  # remove maemo plugin configuration (it overrides defaults for pcm and ctl),
  # until a better way is found to package default overrides:
  # https://bugs.archlinux.org/task/65440
  rm -v "${pkgdir}/etc/alsa/conf.d/98-maemo.conf"

  # make a proper off-by-default config template out of the example file
  mv -v "${pkgdir}/etc/alsa/conf.d/99-pulseaudio-default.conf.example" \
    "${pkgdir}/usr/share/alsa/alsa.conf.d/99-pulseaudio-default.conf"
}

I built this package then installed it and alsa-lib from [extra]:

$ makechrootpkg -c -r $CHROOT
$ pacman -U --asdeps alsa-plugins-libswresample-git-1.2.5.r4.g66b1db7-1-x86_64.pkg.tar.zst
$ pacman -S --asdeps alsa-lib

---------------------------------------

The sound quality from the plugin is really too bad to use, but producing sound at all is progress (especially with the install process streamlined to this point). It's still possible to disable pulseaudio (or just set a digital stereo profile for the card) and configure individual apps to pass-through ac3 directly to the external amp to get full quality.

There are two more things we need to get working on for a52's future: use 32bit sampling in alsa-plugins, have IdleGandalf's libswresample patch upstreamed.

UPDATE: It may be time to end the cargo-cult of the a52 configuration, and the alsa-lib-a52pcm package with it. This configuration is not needed to use the plugin with pulseaudio, which can (now) configure the card by loading the appropriate profile from preconfiguration provided by the alsa-plugins package. Not sure how users of standalone ALSA without pulseaudio are to access the module however (the module ought to be "plug:a52", but speaker-test is broken; could be because of the sample rate).

Last edited by quequotion (2021-06-12 02:55:23)

Online

#58 Today 03:25:43

manio
Member
Registered: 2021-05-05
Posts: 7

Re: A52 plugin with alsa-plugins >1.1.6

Good news: thanks to @tiwai we have a crystal clear sound back with recent changes smile
Development work is in progress...

Offline

Board footer

Powered by FluxBB