termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.38k stars 3.08k forks source link

[Bug]: PulseAudio not working on 32bit Android #21660

Open T-vK opened 1 month ago

T-vK commented 1 month ago

Problem description

On 32bit arm Android devices, PulseAudio does not appear to work properly. I'm trying to load module-sles-source in order to access the microphone.

Some people suggest setting LD_PRELOAD=/system/lib64/libskcodec.so or LD_LIBRARY_PATH=/system/lib64/, but /system/lib64/ does apparently not exist on 32bit arm and /system/lib/ does not contain any library called libskcodec.so.

What steps will reproduce the bug?

Run this on an Android device with an arm (as opposed to aarch64) CPU:

pkg up
pkg install termux-api pulseaudio
# Trigger mic permission prompt (Make sure you also have Termux:API app isntalled):
termux-microphone-record -f ./tmp.wav && termux-microphone-record -q && rm ./tmp.wav 
pactl load-module module-sles-source

The last command throws:

shared memfd open() failed: Unknown error 38

What is the expected behavior?

The expected behavior is that

pactl load-module module-sles-source

doesn't throw any errors and only returns a module id.

And after that, this command:

pactl list short sources

Should return at least one microphone (and not just a sink monitor).

System information

The device is an Amazon Fire HD 7 Tablet running LineageOS 14:

Termux Variables:
TERMUX_API_VERSION=0.50.1
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=2913
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.1
TERMUX__USER_ID=0
Packages CPU architecture:
arm
Subscribed repositories:
# sources.list
deb https://mirror.mwt.me/termux/main stable main
Updatable packages:
All packages up to date
termux-tools version:
1.43.5
Android version:
7.1.2
Kernel build information:
Linux localhost 3.10.108+ #1 SMP PREEMPT Wed Aug 28 09:32:02 BST 2019 armv7l Android
Device manufacturer:
amzn
Device model:
Fire
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
Installed termux plugins:
com.termux.api
com.termux.boot
licy183 commented 1 month ago

Your kernel doesn't have memfd support, but it is neccessay for PulseAudio to work properly.

T-vK commented 1 month ago

@licy183 Thank you, that's very valuable information to me. Do you happen to have some insight on that? Is there a specific kernel version that introduced it in its core or is there a module that provides this functionality?

licy183 commented 1 month ago

I'm afraid that this will not be fixed in the main repository, as memfd should be available on Android 7.x.

I've pushed a commit that drops the memfd usage in pulseaudio. You can download the debs in https://github.com/termux/termux-packages/actions/runs/11190633201 and test if it works.

T-vK commented 1 month ago

I just tested my old Nvidia Shiled Tablet (Android 8.1.0, Kernel 3.10.96, armv7l 32bit) and it's also missing memfd.

I also tested the provided build which drops memfd and I can confirm it does not throw the memfd error anymore, but unfortunately it's still failing:

$ pactl load-module module-sles-source
Failure: Module initialization failed

I installed the provided builds by uninstalling pulse audio first (pkg remove pulseaudio) and then installing the 32bit arm.deb files for pulseaudio and pulseaudio-glib.

licy183 commented 1 month ago

Ahhh.. I deleted these modules by accident. I'll fix it later.

licy183 commented 1 month ago

Please download the debs in https://github.com/termux/termux-packages/actions/runs/11416273339 and check if it works. Thanks!

T-vK commented 1 month ago

Sorry for the late response and thank you for your help. I've I tried the new builds you provided, but I'm still getting:

$ pactl load-module module-sles-source
Failure: Module initialization failed

Both module-sles-sink.so and module-sles-source.so (in /data/data/com.termux/files/usr/lib/pulseaudio/modules/ for the 32bit arm version) are missing from the package you provided. The official pulseaudio package has them both.

Jyers commented 2 weeks ago

@licy183 Thanks so much for looking into this! I am also having this issue and was wondering if you have any other ideas of how to solve it? I'm trying to re-purpose some old android devices and being able to run pulseaudio would be amazing.

licy183 commented 2 weeks ago

Both module-sles-sink.so and module-sles-source.so (in /data/data/com.termux/files/usr/lib/pulseaudio/modules/ for the 32bit arm version) are missing from the package you provided. The official pulseaudio package has them both.

They exist in the debs... Screenshot

Please download it from https://github.com/termux/termux-packages/actions/runs/11416273339 and install it with apt install --reinstall ./xxx.deb and try again.

Jyers commented 2 weeks ago

That seems to work! Thanks a ton!

@T-vK "Failure: Module initialization failed" Will also be thrown if the Termux:API app is not installed and or Termux isn't given microphone permission. I would try checking on both of those if you are still seeing the error with the new debs.

T-vK commented 2 weeks ago

I must have done something wrong. It is indeed working now. @licy183 Any chance of getting those changes upstream?