pulseaudio can't record on LineageOS 20 / Android 13?

So, I have a Xiaomi Smart Clock running LineageOS 20 (Android 13) that I'm trying to get Wyoming in Termux (https://github.com/T-vK/wyoming-satellite-termux/tree/main) running on. I am able to get everything installed and running ... but it seems like the mic isn't getting any input. If I use termux-microphone-record I'm able to record audio and play it back with termux-media-player but when I try to use sox (via rec) or parecord , the output file is exclusively 0x00 data. This is even if I run pactl load-module module-sles-source immediately before. I granted mic permission to Termux:API and the fact that the mic works with termux-microphone-record makes me think this isn't an Android permissions issue. I am seeing the green microphone icon in the status bar when I run rec or parecord but still getting 0x00 output in files. If I run pulseaudio with the following command line pulseaudio -L module-sles-source -D --log-level=4 --log-target=file:/data/data/com.termux/files/home/pa.log --log-time=0 and then run rec yay.wav I see the attached in the log which doesn't show any obvious issue. The only notable thing in the output of rec is that the time increments much much much slower than wall time (e.g. it takes more than 5 seconds to record 5 seconds of audio)
GitHub
GitHub - T-vK/wyoming-satellite-termux: A set of scripts allowing y...
A set of scripts allowing you to run wyoming-satellite on Android with Termux - T-vK/wyoming-satellite-termux
13 Replies
jasonanovak
jasonanovakOP5mo ago
In case it is helpful, here's the output of termux-info
~ $ termux-info
Termux Variables:
TERMUX_API_VERSION=0.51.0
TERMUX_APK_RELEASE=GITHUB
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=3481
TERMUX_APP__BUILD_DATA_DIR=/data/data/com.termux
TERMUX_APP__DATA_DIR=/data/user/0/com.termux
TERMUX_APP__LEGACY_DATA_DIR=/data/data/com.termux
TERMUX_APP__SE_FILE_CONTEXT=u:object_r:app_data_file:s0:c139,c256,c512,c768
TERMUX_APP__SE_INFO=default:targetSdkVersion=28:complete
TERMUX_IS_DEBUGGABLE_BUILD=1
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.2
TERMUX__HOME=/data/data/com.termux/files/home
TERMUX__PREFIX=/data/data/com.termux/files/usr
TERMUX__ROOTFS=/data/data/com.termux/files
TERMUX__SE_PROCESS_CONTEXT=u:r:untrusted_app_27:s0:c139,c256,c512,c768
TERMUX__USER_ID=0
Packages CPU architecture:
arm
Subscribed repositories:
# sources.list
deb https://mirror.vern.cc/termux/termux-main stable main
Updatable packages:
All packages up to date
termux-tools version:
1.45.0
Android version:
13
Kernel build information:
Linux localhost 4.14.141+ #1 SMP PREEMPT Tue Dec 14 13:16:21 UTC 2021 armv7l Android
Device manufacturer:
unknown
Device model:
Phh-Treble vanilla
Supported ABIs:
SUPPORTED_ABIS: armeabi-v7a,armeabi
SUPPORTED_32_BIT_ABIS: armeabi-v7a,armeabi
SUPPORTED_64_BIT_ABIS:
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec-ld-preload.so
Installed termux plugins:
com.termux.api versionCode:1000
~ $
~ $ termux-info
Termux Variables:
TERMUX_API_VERSION=0.51.0
TERMUX_APK_RELEASE=GITHUB
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=3481
TERMUX_APP__BUILD_DATA_DIR=/data/data/com.termux
TERMUX_APP__DATA_DIR=/data/user/0/com.termux
TERMUX_APP__LEGACY_DATA_DIR=/data/data/com.termux
TERMUX_APP__SE_FILE_CONTEXT=u:object_r:app_data_file:s0:c139,c256,c512,c768
TERMUX_APP__SE_INFO=default:targetSdkVersion=28:complete
TERMUX_IS_DEBUGGABLE_BUILD=1
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.2
TERMUX__HOME=/data/data/com.termux/files/home
TERMUX__PREFIX=/data/data/com.termux/files/usr
TERMUX__ROOTFS=/data/data/com.termux/files
TERMUX__SE_PROCESS_CONTEXT=u:r:untrusted_app_27:s0:c139,c256,c512,c768
TERMUX__USER_ID=0
Packages CPU architecture:
arm
Subscribed repositories:
# sources.list
deb https://mirror.vern.cc/termux/termux-main stable main
Updatable packages:
All packages up to date
termux-tools version:
1.45.0
Android version:
13
Kernel build information:
Linux localhost 4.14.141+ #1 SMP PREEMPT Tue Dec 14 13:16:21 UTC 2021 armv7l Android
Device manufacturer:
unknown
Device model:
Phh-Treble vanilla
Supported ABIs:
SUPPORTED_ABIS: armeabi-v7a,armeabi
SUPPORTED_32_BIT_ABIS: armeabi-v7a,armeabi
SUPPORTED_64_BIT_ABIS:
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec-ld-preload.so
Installed termux plugins:
com.termux.api versionCode:1000
~ $
jasonanovak
jasonanovakOP5mo ago
For completeness: - Installing the pulseaudio build without memfd from https://github.com/termux/termux-packages/issues/21660 doesn't fix it - Changing the config to use aaudio as a sink doesn't fix it - https://github.com/termux/termux-packages/issues/19623#issuecomment-2123168051 - And because this isn't running OneUI, I don't have /system/lib64/libskcodec.so to preload
GitHub
[Bug]: PulseAudio not working on 32bit Android · Issue #21660 · t...
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 setti...
GitHub
[Bug]: PulseAudio cannot hook to OpenSL ES after One UI 6.1 update ...
Problem description So not too long ago my device (Samsung Galaxy S23 Ultra) gotten One UI 6.1 update and then after I noticed that exact same environment I use does not reproduce any audio. At fir...
Saul Goodman
Saul Goodman4mo ago
Hi, I have the exact same config and sadly the exact same problem as you. Did you manage to figure this out? I'm thinking about testing this on a lower version of Android... maybe that would help.
jasonanovak
jasonanovakOP4mo ago
I haven’t been able to figure it out. The only notable new data is that I can sometimes get rec to record audio if I first run and then quit termux-microphone-record but I can’t get it to work reliably and the fact that termux-microphone-record won’t allow you to either a) write to an existing file or b) stream to stout means that it can’t be used as a drop in replacement for rec.
Saul Goodman
Saul Goodman4mo ago
This really sucks because StreamAssist is currently buggy (memleaks) and other options are not usable on Android 12+. So I guess the only current option is to repack a GSI based on an older Android and try both Termux and HassMic method and hope one of them works. Or maybe we can try to fix the HassMic so it works also on later versions of Android, but I don't know how much work that would be.
jasonanovak
jasonanovakOP4mo ago
There was one person on the viewassist discord who said they got hassmic working on this config?
owokitty
owokitty4mo ago
@jasonanovak I am able to reproduce your problem, and I believe you should be able to fix it by changing your command to this pulseaudio -L module-sles-source -D --log-level=4 --log-target=file:/data/data/com.termux/files/home/pa.log --log-time=0 --exit-idle-time=-1 specifically, add --exit-idle-time=-1 to the pulseaudio command I don't really know why, but for some reason, adding the argument --exit-idle-time=-1 seems to work around multiple pulseaudio-related problems in Termux successfully for example, in this case, doing that and then using the command rec -d yay.wav and then Ctrl+C twice afterward makes yay.wav have a recording from my device microphone, instead of silence
jasonanovak
jasonanovakOP4mo ago
@owokitty thanks. I’ll give that a shot. What hardware are you running this on?
owokitty
owokitty4mo ago
Samsung Galaxy A70 SM-A705FN LineageOS 20 Android 13
jasonanovak
jasonanovakOP4mo ago
Fascinating. Thanks
jasonanovak
jasonanovakOP4mo ago
@owokitty gave that command a shot but sadly didn't seem to fix the issue. Still seeing 0x00 output in files and that in rec, the time increments much much much slower than wall time (e.g. it takes more than 5 seconds to record 5 seconds of audio)
owokitty
owokitty4mo ago
I see , that is unfortunate. it must mean your device has a different problem that I can't reproduce. Here is what I see in my pa.log file from these commands: pulseaudio -L module-sles-source -D --log-level=4 --log-target=file:/data/data/com.termux/files/home/pa.log --log-time=0 --exit-idle-time=-1 rec test.wav ffplay test.wav and i can hear the recording

Did you find this page helpful?