termux / termux-packages

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

[Bug]: sdl2 audio drivers missing? #10072

Closed Randrianasulu closed 2 years ago

Randrianasulu commented 2 years ago

Problem description

I try to learn a bit about audio programming with sdl2

I copied code from https://gist.github.com/armornick/3447121 it compiles but gives me error on sdl_init. I added sdl function listing audio drivers and it returns

$ gcc -o playwav-2 playwav-2.c -lSDL2 $ ./playwav-2 Using default wav file: "1.wav" Audio driver 0: pulseaudio Audio driver 1: disk Audio driver 2: dummy SDL_Init(SDL_INIT_AUDIO) < 0, err = Could not connect to PulseAudio

i see sdl itself have opensl es and android audio drivers. https://github.com/libsdl-org/SDL/tree/main/src/audio

can they be enabled for termux?

What steps will reproduce the bug?

compile and run wav-playing sdl2 code in termux, without pulseaudio running

What is the expected behavior?

example plays sound

System information

termux-info:

$ termux-info
Application version:
unsupported
Packages CPU architecture:
arm
Subscribed repositories:
# sources.list
deb https://grimler.se/termux-packages-24/ stable main
# x11-repo (sources.list.d/x11.list)
deb https://packages.termux.org/apt/termux-x11 x11 main
Updatable packages:
mc/stable 4.8.27-4 arm [upgradable from: 4.8.25-3]
Android version:
10
Kernel build information:
Linux localhost 4.14.141+ termux/termux-packages#1 SMP PREEMPT Tue Feb 15 19:38:32 CST 2022 armv8l Android
Device manufacturer:
HUAWEI
Device model:
KOB2-L09
$
xtkoba commented 2 years ago

Not reproducible for me (Android 8.1.0 aarch64 asus ASUS_X01AD). The example just exits normally. What is shown in your logcat output?

Randrianasulu commented 2 years ago

On Tuesday, April 12, 2022, xtkoba @.***> wrote:

Not reproducible for me (Android 8.1.0 aarch64 asus ASUS_X01AD). The example just exits normally. What is shown in your logcat output?

04-12 11:27:30.065 13774 13774 I HwViewRootImpl: removeInvalidNode all the node in jank list is out of time 04-12 11:27:30.084 13774 13774 D DecorView: showOrHideHighlightView: hasFocus=true; winMode=1; isMrgNull=true 04-12 11:27:30.087 13774 13774 W InputMethodManager: startInputReason = 1 04-12 11:27:34.533 13774 13774 I Hwaps : APS: EventAnalyzed: initAPS: version is 10.1.0.18 04-12 11:27:34.534 13774 13774 D Hwaps : Fpsrequest create,type:EXACTLY_IDENTIFY 04-12 11:27:34.538 13774 13774 I hwaps : HwAps: JNI_OnLoad 04-12 11:27:34.539 13774 13774 D Hwaps : Fpsrequest create,type:EXACTLY_IDENTIFY 04-12 11:27:34.539 13774 13774 D Hwaps : Fpsrequest create,type:OPENGL_SETTING 04-12 11:27:34.539 13774 13774 D Hwaps : FpsController create 04-12 11:27:34.544 13774 13774 D Hwaps : APS: EventAnalyzed: reInitFpsPara :mBaseFps = 60; mMaxFps = 60 04-12 11:27:34.602 13774 13774 W HwApsManager: HwApsManagerService, registerCallback, start ! 04-12 11:27:34.605 13774 13774 D Hwaps : APS: EventAnalyzed: registerCallbackInApsManagerService, mPkgName:com.termux; result = true 04-12 11:27:34.607 13774 13774 V AudioManager: querySoundEffectsEnabled... 04-12 11:27:36.014 15162 15162 W bash : type=1400 audit(0.0:5093697): avc: granted { execute } for pid=15162 name="playwav" dev="mmcblk0p55" ino=546307 scontext=u:r:untrusted_app_27:s0:c116,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c116,c256,c512,c768 tclass=file 04-12 11:27:36.018 15162 15162 W bash : type=1400 audit(0.0:5093698): avc: granted { execute } for pid=15162 name="playwav" dev="mmcblk0p55" ino=546307 scontext=u:r:untrusted_app_27:s0:c116,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c116,c256,c512,c768 tclass=file 04-12 11:27:36.018 15162 15162 W bash : type=1400 audit(0.0:5093699): avc: granted { execute_no_trans } for pid=15162 path="/data/data/com.termux/files/home/playwav" dev="mmcblk0p55" ino=546307 scontext=u:r:untrusted_app_27:s0:c116,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c116,c256,c512,c768 tclass=file 04-12 11:27:36.022 15162 15162 W playwav : type=1400 audit(0.0:5093700): avc: granted { execute } for pid=15162 path="/data/data/com.termux/files/home/playwav" dev="mmcblk0p55" ino=546307 scontext=u:r:untrusted_app_27:s0:c116,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c116,c256,c512,c768 tclass=file 04-12 11:27:36.082 15162 15162 W playwav : type=1400 audit(0.0:5093701): avc: granted { execute } for pid=15162 path="/data/data/com.termux/files/usr/lib/pulseaudio/libpulsecommon-14.2.so" dev="mmcblk0p55" ino=529636 scontext=u:r:untrusted_app_27:s0:c116,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c116,c256,c512,c768 tclass=file 04-12 11:27:36.082 15162 15162 W playwav : type=1400 audit(0.0:5093702): avc: granted { execute } for pid=15162 path="/data/data/com.termux/files/usr/lib/libXau.so" dev="mmcblk0p55" ino=82893 scontext=u:r:untrusted_app_27:s0:c116,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c116,c256,c512,c768 tclass=file 04-12 11:27:36.086 15162 15162 W playwav : type=1400 audit(0.0:5093703): avc: granted { execute } for pid=15162 path="/data/data/com.termux/files/usr/lib/libopus.so" dev="mmcblk0p55" ino=393685 scontext=u:r:untrusted_app_27:s0:c116,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c116,c256,c512,c768 tclass=file 04-12 11:27:36.086 15162 15162 W playwav : type=1400 audit(0.0:5093704): avc: granted { execute } for pid=15162 path="/data/data/com.termux/files/usr/lib/libvorbisenc.so" dev="mmcblk0p55" ino=372661 scontext=u:r:untrusted_app_27:s0:c116,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c116,c256,c512,c768 tclass=file 04-12 11:27:38.765 13774 13774 V AudioManager: querySoundEffectsEnabled... 04-12 11:27:39.450 15163 15163 W bash : type=1400 audit(0.0:5093728): avc: granted { execute } for pid=15163 name="logcat" dev="mmcblk0p55" ino=539595 scontext=u:r:untrusted_app_27:s0:c116,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c116,c256,c512,c768 tclass=file 04-12 11:27:39.454 15163 15163 W bash : type=1400 audit(0.0:5093729): avc: granted { execute } for pid=15163 name="logcat" dev="mmcblk0p55" ino=539595 scontext=u:r:untrusted_app_27:s0:c116,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c116,c256,c512,c768 tclass=file 04-12 11:27:39.454 15163 15163 W bash : type=1400 audit(0.0:5093730): avc: granted { execute_no_trans } for pid=15163 path="/data/data/com.termux/files/usr/bin/logcat" dev="mmcblk0p55" ino=539595 scontext=u:r:untrusted_app_27:s0:c116,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c116,c256,c512,c768 tclass=file 04-12 11:27:39.454 15163 15163 W bash : type=1400 audit(0.0:5093731): avc: granted { execute } for pid=15163 name="dash" dev="mmcblk0p55" ino=514602 scontext=u:r:untrusted_app_27:s0:c116,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c116,c256,c512,c768 tclass=file 04-12 11:27:39.458 15163 15163 W logcat : type=1400 audit(0.0:5093732): avc: granted { execute } for pid=15163 path="/data/data/com.termux/files/usr/bin/dash" dev="mmcblk0p55" ino=514602 scontext=u:r:untrusted_app_27:s0:c116,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c116,c256,c512,c768 tclass=file

04-12 11:27:47.390 13774 13774 D InputTransport: history resample interval is too short, cannot uses it to resample!! 04-12 11:27:47.490 13774 13774 D InputTransport: history resample interval is too short, cannot uses it to resample!! 04-12 11:27:48.539 13774 13774 I InputTransport: Fun_filterMotionEvent reportMoveEvent! 04-12 11:27:48.623 13774 13774 D InputTransport: history resample interval is too short, cannot uses it to resample!! 04-12 11:27:49.621 13774 13774 I InputTransport: Fun_filterMotionEvent reportMoveEvent! 04-12 11:27:50.421 13774 13774 I InputTransport: Fun_filterMotionEvent reportMoveEvent! 04-12 11:27:50.838 13774 13774 I InputTransport: Fun_filterMotionEvent reportMoveEvent! 04-12 11:27:53.885 13774 13774 D InputTransport: history resample interval is too short, cannot uses it to resample!! 04-12 11:27:53.918 13774 13774 D InputTransport: history resample interval is too short, cannot uses it to resample!! 04-12 11:27:55.384 13774 13774 D InputTransport: history resample interval is too short, cannot uses it to resample!! 04-12 11:28:05.543 13774 13774 D InputTransport: history resample interval is too short, cannot uses it to resample!! 04-12 11:28:05.693 13774 13774 D InputTransport: history resample interval is too short, cannot uses it to resample!! 04-12 11:28:05.743 13774 13774 D InputTransport: history resample interval is too short, cannot uses it to resample!! 04-12 11:28:08.376 13774 13774 V AudioManager: querySoundEffectsEnabled

— Reply to this email directly, view it on GitHub <termux/termux-packages#10072>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJSS7TMXGGPUUZ2R7IMFIHLVEUNNZANCNFSM5TFOZY2Q . You are receiving this because you authored the thread.Message ID: @.***>

Randrianasulu commented 2 years ago

ah, sorry - it works if I start pulseaudio manually. (was confused by termux vs termux-x11)

Randrianasulu commented 2 years ago

so, i hacked configure.ac from sdl 2.0.20 (added "|linux" for existing android audio case), more audio drivers appeared in summary, build was ok, but link is not:


LTLINK build/libSDL2.la                                                
LTLINK build/libSDL2main.la                                            
LTLINK build/libSDL2_test.la
ld.lld: error: unable to find library -l:libclang_rt.builtins-arm-android.a                                                                   clang-13: error: linker command failed with exit code 1 (use -v to see invocation)                                                            
make: *** [Makefile:158: build/libSDL2.la] Error 1
Randrianasulu commented 2 years ago

also, there is second, more convient to use sdl2 example: https://gist.github.com/LaughingSun

(no need to recompile for new sound file - i made wav file by running mplayer with -ao pcm:waveheader)

Randrianasulu commented 2 years ago

so, new llvm 14 broke even compilation of those audio drivers.

i looked up error text, found https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=262634

removed Werror=no-declaration-after-statement from Makefile (put there by configure generated from configure.ac), and back to linking error.

CMake build can't even configure itself (complain about cpufeatures.c missing) .. And I can't see way to enable Android audio outputs via options in ccmake

stale[bot] commented 2 years ago

This issue/PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

xtkoba commented 2 years ago

Actually this is already resolved: https://github.com/termux/termux-packages/issues/10072#issuecomment-1102306997. I do not know why PulseAudio did not start automatically, but that is another issue. And the rest is completely off-topic.