Skip to content

enhance(main/cmus): enable ALSA output #25062

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

Merged
merged 2 commits into from
Jul 9, 2025
Merged

Conversation

fukiame
Copy link
Contributor

@fukiame fukiame commented Jun 15, 2025

when paired with root, should enable bit-perfect playback with ALSA and bypass Android audio stack, useful for people who want that but do not want to / cannot use native android usb handover for e.g UAPP or Neutron Player

when paired with root, should enable bit-perfect playback with ALSA

Signed-off-by: fukiame <[email protected]>
@robertkirkman
Copy link
Contributor

It is an interesting idea, but I wondered, do you have a device where you can confirm that this is completely working?
The reason I would like to ask that is because, ALSA is rumored to be extremely difficult to use successfully in Termux all the way to audio playback (as opposed to some other audio APIs OpenSL ES, Pulseaudio, Portaudio, Miniaudio, Pipewire, JACK)
If so, could you include in your description a minimal example of the full commands necessary after installing this package, to set up and test the ALSA output on that particular device where it is working?

@TomJo2000
Copy link
Member

Just gonna throw my "testing PRs" saved reply in here for instructions.

(This is a pre-written, saved reply.)
If you want to test this PR please download the appropriate DEB package(s)
from the build artifacts of the associated PR's latest CI run.
Screenshot_20240619_232413

After downloading the build artifact, make sure to unzip and un-tar it.

Detailed instructions, if needed.

# finding out what architecture you need
# architecture is just below the TERMUX_VERSION
termux-info

# e.g.
# [...]
# TERMUX_MAIN_PACKAGE_FORMAT=debian
# TERMUX_VERSION=0.118.0
# TERMUX__USER_ID=0
# Packages CPU architecture:
# aarch64
# [...]

# =======================

# make sure `unzip` and `tar` are installed using
pkg install unzip tar

# unzip the artifact (if you have a different architecture this might be arm, i686 or x86_64 instead)
unzip debs-aarch64-*.zip

# untar the artifact
tar xf debs-aarch64-*.tar

# You should now have a debs/ directory in your current working directory
# Install the packages from the local source using
pkg install -- ./debs/*.deb

# to clean up, you can remove the debs/ directory, .tar file and .zip file
rm -rfi debs debs-aarch64-*.zip debs-aarch64-*.tar

@fukiame
Copy link
Contributor Author

fukiame commented Jun 15, 2025

It is an interesting idea, but I wondered, do you have a device where you can confirm that this is completely working? The reason I would like to ask that is because, ALSA is rumored to be extremely difficult to use successfully in Termux all the way to audio playback (as opposed to some other audio APIs OpenSL ES, Pulseaudio, Portaudio, Miniaudio, Pipewire, JACK) If so, could you include in your description a minimal example of the full commands necessary after installing this package, to set up and test the ALSA output on that particular device where it is working?

I can confirm that it's working, tested with my JadeAudio JA11 USB DAC
with it plugged in and identified via sudo aplay -l

sudo cmus
:set output_plugin alsa
:set dsp.alsa.device=hw:1,0 # 1,0 is my USB DAC

play music, check bitrate via card software, see proper bitrate changes

ALSA is rumored to be extremely difficult to use successfully in Termux all the way to audio playback

the hardest part of it would be to get root access, I do not yet know if there is a way to do so rootlessly, I assume that this is the norm for any ALSA usage, though, lmk if I'm wrong

@fukiame
Copy link
Contributor Author

fukiame commented Jun 15, 2025

Screenshot_2025-06-16-02-57-47-731_com termux
Screenshot_2025-06-16-02-57-20-651_com termux

with cmus ALSA, see proper bitrate change in FiiO Control (an app to control my USB DAC)

Screenshot_2025-06-16-03-03-18-630_com fiio control

versus a normal audio player in Android, staying at 48khz because of Android's resampling

Copy link
Contributor

@robertkirkman robertkirkman left a comment

Choose a reason for hiding this comment

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

Good, thank you for showing how to use it.

@robertkirkman
Copy link
Contributor

I will merge this in 24 hours from now if nobody has any problem with this.

@robertkirkman robertkirkman merged commit 9eca9ea into termux:master Jul 9, 2025
9 checks passed
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