Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(main/cmus): Add AAudio output plugin #21069

Merged
merged 1 commit into from
Aug 11, 2024

Conversation

pgaskin
Copy link
Contributor

@pgaskin pgaskin commented Aug 7, 2024

Support native audio on Android 8.1 and later.

  • Better battery life.
  • Configurable latency.
  • Configurable capture policy.
  • Configurable sharing mode.
  • Configurable spatialization.
  • Full multi-channel audio support.
  • Supports pause_on_output_change.

cmus/cmus#1346
cmus/cmus@3880d9d

@TomJo2000
Copy link
Member

We'd likely prefer to wait for the above mentioned PR in cmus to:

  1. Be merged, and
  2. Be shipped as part of a release.

See "Don't ship WIP" for a more detailed breakdown.
If we do want to ship it before a new release that would require additional coordination with upstream.

@pgaskin
Copy link
Contributor Author

pgaskin commented Aug 7, 2024

I'm one of the upstream maintainers.

The next release of cmus is unlikely to be for a very long time (releases usually have at least a year between them since only one person can do them and they aren't usually available).

I figure since this is Android-only and Termux is the only way to run cmus on Android, it's a similar situation as the aaudio/sles PulseAudio sinks, where it's mostly done as a patch in Termux.

I'll be keeping this PR marked as a draft for at least a few days until I've thoroughly tested the plugin (I believe it's stable now, but just to be sure).

@TomJo2000
Copy link
Member

Ah okay thank you that clears things up.

@TomJo2000
Copy link
Member

Do you mind if I do a review pass while the PR is still in the draft stage?
I'm thinking we can avoid needing to inline the patch into the termux-packages repository by adding it as a second item to TERMUX_PKG_SRCURL (as well as a corresponding TERMUX_PKG_SHA256) in the build script.

@pgaskin
Copy link
Contributor Author

pgaskin commented Aug 7, 2024

Yeah, feel free to do a review. I just got the package build to work, and I've already been testing the plugin for a few days, so the code's pretty much final.

+ { NULL },
+};
+
+const int op_priority = -3; // higher priority than pulse (-2)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set this to be a higher priority than pulse since it should almost always be the better option if it's supported.

Another option could be to split the pulseaudio plugin into a subpackage, with the aaudio plugin having a lower priority.

Copy link
Member

@TomJo2000 TomJo2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to do something along the lines of what the bash package does.

termux_step_pre_configure() {
declare -A PATCH_CHECKSUMS
PATCH_CHECKSUMS[001]=f42f2fee923bc2209f406a1892772121c467f44533bedfe00a176139da5d310a
PATCH_CHECKSUMS[002]=45cc5e1b876550eee96f95bffb36c41b6cb7c07d33f671db5634405cd00fd7b8
PATCH_CHECKSUMS[003]=6a090cdbd334306fceacd0e4a1b9e0b0678efdbbdedbd1f5842035990c8abaff
PATCH_CHECKSUMS[004]=38827724bba908cf5721bd8d4e595d80f02c05c35f3dd7dbc4cd3c5678a42512
PATCH_CHECKSUMS[005]=ece0eb544368b3b4359fb8464caa9d89c7a6743c8ed070be1c7d599c3675d357
PATCH_CHECKSUMS[006]=d1e0566a257d149a0d99d450ce2885123f9995e9c01d0a5ef6df7044a72a468c
PATCH_CHECKSUMS[007]=2500a3fc21cb08133f06648a017cebfa27f30ea19c8cbe8dfefdf16227cfd490
PATCH_CHECKSUMS[008]=6b4bd92fd0099d1bab436b941875e99e0cb3c320997587182d6267af1844b1e8
PATCH_CHECKSUMS[009]=f95a817882eaeb0cb78bce82859a86bbb297a308ced730ebe449cd504211d3cd
PATCH_CHECKSUMS[010]=c7705e029f752507310ecd7270aef437e8043a9959e4d0c6065a82517996c1cd
PATCH_CHECKSUMS[011]=831b5f25bf3e88625f3ab315043be7498907c551f86041fa3b914123d79eb6f4
PATCH_CHECKSUMS[012]=2fb107ce1fb8e93f36997c8b0b2743fc1ca98a454c7cc5a3fcabec533f67d42c
PATCH_CHECKSUMS[013]=094b4fd81bc488a26febba5d799689b64d52a5505b63e8ee854f48d356bc7ce6
PATCH_CHECKSUMS[014]=3ef9246f2906ef1e487a0a3f4c647ae1c289cbd8459caa7db5ce118ef136e624
PATCH_CHECKSUMS[015]=ef73905169db67399a728e238a9413e0d689462cb9b72ab17a05dba51221358a
PATCH_CHECKSUMS[016]=155853bc5bd10e40a9bea369fb6f50a203a7d0358e9e32321be0d9fa21585915
PATCH_CHECKSUMS[017]=1c48cecbc9b7b4217990580203b7e1de19c4979d0bd2c0e310167df748df2c89
PATCH_CHECKSUMS[018]=4641dd49dd923b454dd0a346277907090410f5d60a29a2de3b82c98e49aaaa80
PATCH_CHECKSUMS[019]=325c26860ad4bba8558356c4ab914ac57e7b415dac6f5aae86b9b05ccb7ed282
PATCH_CHECKSUMS[020]=b6fc252aeb95ce67c9b017d29d81e8a5e285db4bf20d4ec8cdca35892be5c01d
PATCH_CHECKSUMS[021]=8334b88117ad047598f23581aeb0c66c0248cdd77abc3b4e259133aa307650cd
PATCH_CHECKSUMS[022]=78b5230a49594ec30811e72dcd0f56d1089710ec7828621022d08507aa57e470
PATCH_CHECKSUMS[023]=af905502e2106c8510ba2085aa2b56e64830fc0fdf6ee67ebb459ac11696dcd3
PATCH_CHECKSUMS[024]=971534490117eb05d97d7fd81f5f9d8daf927b4d581231844ffae485651b02c3
PATCH_CHECKSUMS[025]=5138f487e7cf71a6323dc81d22419906f1535b89835cc2ff68847e1a35613075
PATCH_CHECKSUMS[026]=96ee1f549aa0b530521e36bdc0ba7661602cfaee409f7023cac744dd42852eac
for PATCH_NUM in $(seq -f '%03g' ${_PATCH_VERSION}); do
PATCHFILE=$TERMUX_PKG_CACHEDIR/bash_patch_${PATCH_NUM}.patch
termux_download \
"https://mirrors.kernel.org/gnu/bash/bash-${_MAIN_VERSION}-patches/bash${_MAIN_VERSION/./}-$PATCH_NUM" \
$PATCHFILE \
${PATCH_CHECKSUMS[$PATCH_NUM]}
patch -p0 -i $PATCHFILE
done
unset PATCH_CHECKSUMS PATCHFILE PATCH_NUM
}

Although, since this is a single patch we're not going to need the whole array shenanigans.

packages/cmus/aaudio.patch Outdated Show resolved Hide resolved
@pgaskin pgaskin force-pushed the cmus-aaudio branch 3 times, most recently from de4ce69 to 03e9e67 Compare August 8, 2024 14:10
@pgaskin
Copy link
Contributor Author

pgaskin commented Aug 8, 2024

  • Changed the build script to download the patch from GitHub.
  • Fixed the link error due to Termux using -Wl,--as-needed and libaaudio using weak symbols.
  • Did some minor refactoring of the AAudio output plugin.

The build failure is unrelated to this change (it was fine when I tested it just now).

@pgaskin pgaskin requested a review from TomJo2000 August 8, 2024 14:17
@pgaskin pgaskin marked this pull request as ready for review August 8, 2024 14:17
@pgaskin
Copy link
Contributor Author

pgaskin commented Aug 8, 2024

The build failure is caused by clang: error: unknown argument: '-fno-openmp-implicit-rpath' because pkg-config --libs ncurses is -L/data/data/com.termux/files/usr/lib -Wl,-rpath=/data/data/com.termux/files/usr/lib -fopenmp -static-openmp -fno-openmp-implicit-rpath -Wl,--enable-new-dtags -lncursesw (it was -lncurses -ltinfo before #20935).

@Biswa96
Copy link
Member

Biswa96 commented Aug 8, 2024

The build failure is caused by clang: error: unknown argument: '-fno-openmp-implicit-rpath'

Please wait for #21038

Copy link
Member

@TomJo2000 TomJo2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple nits, but no showstoppers.
Thanks a lot of putting in the effort.

packages/cmus/build.sh Outdated Show resolved Hide resolved
packages/cmus/build.sh Outdated Show resolved Hide resolved
packages/cmus/build.sh Outdated Show resolved Hide resolved
packages/cmus/build.sh Show resolved Hide resolved
Copy link
Member

@TomJo2000 TomJo2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@TomJo2000 TomJo2000 requested a review from Biswa96 August 11, 2024 14:49
@Biswa96 Biswa96 removed their request for review August 11, 2024 14:53
@Biswa96
Copy link
Member

Biswa96 commented Aug 11, 2024

No idea 😔

Support native audio on Android 8.1 and later.

- Better battery life.
- Configurable latency.
- Configurable capture policy.
- Configurable sharing mode.
- Configurable spatialization.
- Full multi-channel audio support.
- Supports `pause_on_output_change`.

Also includes fix for pause_on_output change with softvol enabled
since aaudio doesn't have volume control.

cmus/cmus#1346
cmus/cmus#1353
@TomJo2000 TomJo2000 merged commit c84e647 into termux:master Aug 11, 2024
4 checks passed
@TomJo2000
Copy link
Member

@pgaskin thank you for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants