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
In case it is helpful, here's the output of
termux-info
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...
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.
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.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.
There was one person on the viewassist discord who said they got hassmic working on this config?
@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@owokitty thanks. I’ll give that a shot. What hardware are you running this on?
Samsung Galaxy A70 SM-A705FN
LineageOS 20 Android 13
Fascinating. Thanks
@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)
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