Trying to port alsamixer with ncurses

240 views
Skip to first unread message

Huy Minh Bui

unread,
Jun 5, 2020, 12:02:20 PM6/5/20
to Android-x86
Hi, I'm trying to compile alsamixer tool for nougat-x86. I'm using libncurses source from LineageOS : https://github.com/LineageOS/android_external_libncurses 
After modified Android.mk and aconfig.h to point it into libncurses and try to build it. But I'm having some linking problem here.

[ 14% 1/7] target Executable: alsamixer (out/target/product/x86_64/obj/EXECUTABLES/alsamixer_intermediates/LINKED/alsamixer)
FAILED: /bin/bash -c "prebuilts/clang/host/linux-x86/clang-2690385/bin/clang++ -pie -nostdlib -Bdynamic -Wl,-dynamic-linker,/system/bin/linker64 -Wl,--gc-sections -Wl,-z,nocopyreloc  -Lout/target/p
roduct/x86_64/obj/lib -Wl,-rpath-link=out/target/product/x86_64/obj/lib out/target/product/x86_64/obj/lib/crtbegin_dynamic.o             out/target/product/x86_64/obj/EXECUTABLES/alsamixer_intermed
iates/alsamixer/card_select.o out/target/product/x86_64/obj/EXECUTABLES/alsamixer_intermediates/alsamixer/cli.o out/target/product/x86_64/obj/EXECUTABLES/alsamixer_intermediates/alsamixer/colors.o
out/target/product/x86_64/obj/EXECUTABLES/alsamixer_intermediates/alsamixer/device_name.o out/target/product/x86_64/obj/EXECUTABLES/alsamixer_intermediates/alsamixer/die.o out/target/product/x86_64
/obj/EXECUTABLES/alsamixer_intermediates/alsamixer/mainloop.o out/target/product/x86_64/obj/EXECUTABLES/alsamixer_intermediates/alsamixer/mem.o out/target/product/x86_64/obj/EXECUTABLES/alsamixer_i
ntermediates/alsamixer/mixer_controls.o out/target/product/x86_64/obj/EXECUTABLES/alsamixer_intermediates/alsamixer/mixer_display.o out/target/product/x86_64/obj/EXECUTABLES/alsamixer_intermediates
/alsamixer/mixer_widget.o out/target/product/x86_64/obj/EXECUTABLES/alsamixer_intermediates/alsamixer/proc_files.o out/target/product/x86_64/obj/EXECUTABLES/alsamixer_intermediates/alsamixer/textbo
x.o out/target/product/x86_64/obj/EXECUTABLES/alsamixer_intermediates/alsamixer/utils.o out/target/product/x86_64/obj/EXECUTABLES/alsamixer_intermediates/alsamixer/volume_mapping.o out/target/produ
ct/x86_64/obj/EXECUTABLES/alsamixer_intermediates/alsamixer/widget.o        -Wl,--whole-archive   -Wl,--no-whole-archive   out/target/product/x86_64/obj/STATIC_LIBRARIES/libcompiler_rt-extras_inter
mediates/libcompiler_rt-extras.a   /media/Work/nougat-x86/prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9/bin/../lib/gcc/x86_64-linux-android/4.9/../../../../x86_64-linux-android/lib/../lib64/
libatomic.a /media/Work/nougat-x86/prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9/bin/../lib/gcc/x86_64-linux-android/4.9/libgcc.a -lasound -lncurses -lc++ -ldl -lc -lm  -o out/target/product
/x86_64/obj/EXECUTABLES/alsamixer_intermediates/LINKED/alsamixer   -m64 -flto -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--build-id=md5 -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--gc-s
ections -Wl,--hash-style=gnu -Wl,--no-undefined-version    -target x86_64-linux-android -Bprebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9/x86_64-linux-android/bin   -Wl,--no-undefined out/targ
et/product/x86_64/obj/lib/crtend_android.o"
external/alsa-utils//alsamixer/card_select.c:146: error: undefined reference to 'unpost_menu'
external/alsa-utils//alsamixer/card_select.c:147: error: undefined reference to 'free_menu'
external/alsa-utils//alsamixer/card_select.c:149: error: undefined reference to 'free_item'
external/alsa-utils//alsamixer/card_select.c:232: error: undefined reference to 'new_item'
external/alsa-utils//alsamixer/card_select.c:235: error: undefined reference to 'set_item_userptr'
external/alsa-utils//alsamixer/card_select.c:253: error: undefined reference to 'new_menu'
external/alsa-utils//alsamixer/card_select.c:256: error: undefined reference to 'set_menu_fore'
external/alsa-utils//alsamixer/card_select.c:257: error: undefined reference to 'set_menu_back'
external/alsa-utils//alsamixer/card_select.c:258: error: undefined reference to 'set_menu_mark'
external/alsa-utils//alsamixer/card_select.c:260: error: undefined reference to 'set_current_item'
external/alsa-utils//alsamixer/card_select.c:261: error: undefined reference to 'set_menu_spacing'
external/alsa-utils//alsamixer/card_select.c:262: error: undefined reference to 'menu_opts_on'
external/alsa-utils//alsamixer/card_select.c:267: error: undefined reference to 'post_menu'
external/alsa-utils//alsamixer/card_select.c:115: error: undefined reference to 'scale_menu'
external/alsa-utils//alsamixer/card_select.c:128: error: undefined reference to 'set_menu_win'
external/alsa-utils//alsamixer/card_select.c:129: error: undefined reference to 'set_menu_sub'
external/alsa-utils//alsamixer/card_select.c:50: error: undefined reference to 'current_item'
external/alsa-utils//alsamixer/card_select.c:52: error: undefined reference to 'item_userptr'
external/alsa-utils//alsamixer/card_select.c:80: error: undefined reference to 'menu_driver'
external/alsa-utils//alsamixer/card_select.c:135: error: undefined reference to 'unpost_menu'
external/alsa-utils//alsamixer/card_select.c:138: error: undefined reference to 'post_menu'
external/alsa-utils//alsamixer/device_name.c:170: error: undefined reference to 'new_field'
external/alsa-utils//alsamixer/device_name.c:173: error: undefined reference to 'field_opts_off'
external/alsa-utils//alsamixer/device_name.c:174: error: undefined reference to 'field_opts_off'
external/alsa-utils//alsamixer/device_name.c:175: error: undefined reference to 'set_field_fore'
external/alsa-utils//alsamixer/device_name.c:176: error: undefined reference to 'set_field_back'
external/alsa-utils//alsamixer/device_name.c:177: error: undefined reference to 'set_field_buffer'
external/alsa-utils//alsamixer/device_name.c:179: error: undefined reference to 'new_field'
external/alsa-utils//alsamixer/device_name.c:182: error: undefined reference to 'field_opts_off'
external/alsa-utils//alsamixer/device_name.c:183: error: undefined reference to 'field_opts_off'
external/alsa-utils//alsamixer/device_name.c:185: error: undefined reference to 'set_field_fore'
external/alsa-utils//alsamixer/device_name.c:186: error: undefined reference to 'set_field_back'
external/alsa-utils//alsamixer/device_name.c:187: error: undefined reference to 'set_field_buffer'
external/alsa-utils//alsamixer/device_name.c:189: error: undefined reference to 'new_form'
external/alsa-utils//alsamixer/device_name.c:196: error: undefined reference to 'post_form'
external/alsa-utils//alsamixer/device_name.c:129: error: undefined reference to 'set_form_win'
external/alsa-utils//alsamixer/device_name.c:130: error: undefined reference to 'set_form_sub'
external/alsa-utils//alsamixer/device_name.c:43: error: undefined reference to 'form_driver'
external/alsa-utils//alsamixer/device_name.c:44: error: undefined reference to 'dynamic_field_info'
external/alsa-utils//alsamixer/device_name.c:46: error: undefined reference to 'field_buffer'
external/alsa-utils//alsamixer/device_name.c:86: error: undefined reference to 'form_driver'
external/alsa-utils//alsamixer/device_name.c:91: error: undefined reference to 'form_driver'
external/alsa-utils//alsamixer/device_name.c:136: error: undefined reference to 'form_driver'
external/alsa-utils//alsamixer/device_name.c:137: error: undefined reference to 'unpost_form'
external/alsa-utils//alsamixer/device_name.c:150: error: undefined reference to 'post_form'
external/alsa-utils//alsamixer/device_name.c:155: error: undefined reference to 'unpost_form'
external/alsa-utils//alsamixer/device_name.c:156: error: undefined reference to 'free_form'
external/alsa-utils//alsamixer/device_name.c:157: error: undefined reference to 'free_field'
external/alsa-utils//alsamixer/device_name.c:158: error: undefined reference to 'free_field'
external/alsa-utils//alsamixer/mainloop.c:77: error: undefined reference to 'update_panels'
external/alsa-utils//alsamixer/mainloop.c:77: error: undefined reference to 'update_panels'
external/alsa-utils//alsamixer/proc_files.c:132: error: undefined reference to 'new_item'
external/alsa-utils//alsamixer/proc_files.c:132: error: undefined reference to 'new_item'
external/alsa-utils//alsamixer/proc_files.c:132: error: undefined reference to 'new_item'
external/alsa-utils//alsamixer/proc_files.c:157: error: undefined reference to 'new_menu'
external/alsa-utils//alsamixer/proc_files.c:160: error: undefined reference to 'set_menu_fore'
external/alsa-utils//alsamixer/proc_files.c:161: error: undefined reference to 'set_menu_back'
external/alsa-utils//alsamixer/proc_files.c:162: error: undefined reference to 'set_menu_mark'
external/alsa-utils//alsamixer/proc_files.c:163: error: undefined reference to 'menu_opts_off'
external/alsa-utils//alsamixer/proc_files.c:168: error: undefined reference to 'post_menu'
external/alsa-utils//alsamixer/proc_files.c:92: error: undefined reference to 'scale_menu'
external/alsa-utils//alsamixer/proc_files.c:105: error: undefined reference to 'set_menu_win'
external/alsa-utils//alsamixer/proc_files.c:106: error: undefined reference to 'set_menu_sub'
external/alsa-utils//alsamixer/proc_files.c:72: error: undefined reference to 'current_item'
external/alsa-utils//alsamixer/proc_files.c:74: error: undefined reference to 'item_name'
external/alsa-utils//alsamixer/proc_files.c:55: error: undefined reference to 'menu_driver'
external/alsa-utils//alsamixer/proc_files.c:112: error: undefined reference to 'unpost_menu'
external/alsa-utils//alsamixer/proc_files.c:115: error: undefined reference to 'post_menu'
external/alsa-utils//alsamixer/proc_files.c:122: error: undefined reference to 'unpost_menu'
external/alsa-utils//alsamixer/proc_files.c:123: error: undefined reference to 'free_menu'
external/alsa-utils//alsamixer/proc_files.c:125: error: undefined reference to 'free_item'
external/alsa-utils//alsamixer/widget.c:80: error: undefined reference to 'replace_panel'
external/alsa-utils//alsamixer/widget.c:82: error: undefined reference to 'new_panel'
external/alsa-utils//alsamixer/widget.c:85: error: undefined reference to 'set_panel_userptr'
external/alsa-utils//alsamixer/widget.c:119: error: undefined reference to 'panel_below'
external/alsa-utils//alsamixer/widget.c:121: error: undefined reference to 'panel_userptr'
external/alsa-utils//alsamixer/widget.c:100: error: undefined reference to 'del_panel'
external/alsa-utils//alsamixer/widget.c:119: error: undefined reference to 'panel_below'
external/alsa-utils//alsamixer/widget.c:121: error: undefined reference to 'panel_userptr'
external/alsa-utils//alsamixer/widget.c:119: error: undefined reference to 'panel_below'
external/alsa-utils//alsamixer/widget.c:121: error: undefined reference to 'panel_userptr'
external/alsa-utils//alsamixer/widget.c:135: error: undefined reference to 'panel_below'
external/alsa-utils//alsamixer/widget.c:137: error: undefined reference to 'panel_userptr'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
make: *** [build/core/ninja.mk:149: ninja_wrapper] Error 1

I don't know how to solve this error. Hope I can get some help :D. Here are my Android.mk and  aconfig.h
 

aconfig.h
Android.mk

Huy Minh Bui

unread,
Jun 5, 2020, 12:15:31 PM6/5/20
to Android-x86
Update : I forgot that I added LTO (-flto) flag in build/core/combo
Deleted it but the error is still the same

Mauro Rossi

unread,
Jun 5, 2020, 1:22:28 PM6/5/20
to Android-x86


On Friday, June 5, 2020 at 6:15:31 PM UTC+2, Huy Minh Bui wrote:
Update : I forgot that I added LTO (-flto) flag in build/core/combo
Deleted it but the error is still the same

You need to identify the source and the static library providing for the missing symbols

Example:

error: undefined reference to 'unpost_menu'

cd external/alsamixer
cgrep  unpost_menu

then check if you need to add some source to the list for alsamixer module
or if you need to add some dependency

Mauro

Huy Minh Bui

unread,
Jun 5, 2020, 2:37:12 PM6/5/20
to Android-x86
Hi Mauro, thanks for your reply
I found that all of those references are in libncurses source. But actually, your reply made me think about reading Android.mk in that libncurses again and found out that there are 2 more libs that need to compile : libmenu and libpanel

I'll try again tomorrow. Thanks for helping me pointed it out.

Message has been deleted

Huy Minh Bui

unread,
Jun 6, 2020, 6:29:41 AM6/6/20
to Android-x86

It just alsa_amixer with ncurses UI, maybe you need a newer kernel or some modprobe trick.

Vào 13:18:28 UTC+7 Thứ Bảy, ngày 06 tháng 6 năm 2020, İlhan Atahan đã viết:
5 Haziran 2020 Cuma 21:37:12 UTC+3 tarihinde Huy Minh Bui yazdı:
> Hi Mauro, thanks for your reply
> I found that all of those references are in libncurses source. But actually, your reply made me think about reading Android.mk in that libncurses again and found out that there are 2 more libs that need to compile : libmenu and libpanel
>
> I'll try again tomorrow. Thanks for helping me pointed it out.

Hi HM, Can i fix my primeos no-sound problem via this method?

Huy Minh Bui

unread,
Jun 6, 2020, 6:45:42 AM6/6/20
to Android-x86
Final result : after compile the full libmenu, libpanel and libform, alsamixer can be compiled.
The result impressed me 


With tty everything works fine with full function as expected

Untitled.png

With some Terminal apps like Terminal Emulator and Termux ncurses is a bit broken. Changing volume work however pressing Fx keys to change deivces, see help or show info make the program broke. Maybe it act as characters instead of Fx keys since when I press it, it close my program and show some characters after that.

Anyway here is what I did :

I hope this tool can come to Android-x86 since there are many people feel it hard to use amixer command :D.

Vào 23:02:20 UTC+7 Thứ Sáu, ngày 05 tháng 6 năm 2020, Huy Minh Bui đã viết:

Chih-Wei Huang

unread,
Jun 7, 2020, 6:02:37 AM6/7/20
to Android-x86
Great achievement!
I'll try to integrate it.
Thank you!

Huy Minh Bui <buin...@gmail.com> 於 2020年6月6日 週六 下午6:45寫道:
>
> Final result : after compile the full libmenu, libpanel and libform, alsamixer can be compiled.
> The result impressed me
>
> With tty everything works fine with full function as expected



--
Chih-Wei
Android-x86 project
http://www.android-x86.org

Huy Minh Bui

unread,
Apr 1, 2021, 1:18:05 PM4/1/21
to Android-x86
It's been almost a year since I wrote this post. And I've been cleaning up the source a bit so that you can merge it easier.
One thing that I can't do so far is to copy terminfo folder into /system/etc while building the OS, so I need some help with that. Anyway, tinkering with the tool is more easier than typing amixer command, so I hope that we can have it on the next Android-x86 release.

My ncurses source :

My alsa sources :
Vào lúc 17:02:37 UTC+7 ngày Chủ Nhật, 7 tháng 6, 2020, Chih-Wei Huang đã viết:

Chih-Wei Huang

unread,
Apr 3, 2021, 2:47:17 PM4/3/21
to Android-x86
Huy Minh Bui <buin...@gmail.com> 於 2021年4月2日 週五 上午1:18寫道:
> It's been almost a year since I wrote this post. And I've been cleaning up the source a bit so that you can merge it easier.
> One thing that I can't do so far is to copy terminfo folder into /system/etc while building the OS, so I need some help with that. Anyway, tinkering with the tool is more easier than typing amixer command, so I hope that we can have it on the next Android-x86 release.
>
> My ncurses source :
> https://github.com/hmtheboy154/android_external_libncurses
>
> My alsa sources :
> https://gitlab.com/hmtheboy154/external_alsa-utils
> https://gitlab.com/hmtheboy154/external_alsa-lib

Thank you for the update.
I'm too busy recently so I almost forgot it. Sorry!
Will check it when I have time.


> Vào lúc 17:02:37 UTC+7 ngày Chủ Nhật, 7 tháng 6, 2020, Chih-Wei Huang đã viết:
>> Great achievement!
>> I'll try to integrate it.
>>

Chih-Wei Huang

unread,
Apr 4, 2021, 4:43:00 AM4/4/21
to Android-x86
Huy Minh Bui <buin...@gmail.com> 於 2021年4月2日 週五 上午1:18寫道:
>
> It's been almost a year since I wrote this post. And I've been cleaning up the source a bit so that you can merge it easier.
> One thing that I can't do so far is to copy terminfo folder into /system/etc while building the OS, so I need some help with that. Anyway, tinkering with the tool is more easier than typing amixer command, so I hope that we can have it on the next Android-x86 release.

What's the problem to copy terminfo?
I saw you used LOCAL_POST_INSTALL_CMD in Android.mk.
That should work. Isn't it?
Though adding it to ALL_DEFAULT_INSTALLED_MODULES is unnecessary.
I hope to clean it up further. For example,
I believe the generated Makefile and binaries
are not used by android. They could be removed.

Huy Minh Bui

unread,
Apr 4, 2021, 5:18:09 AM4/4/21
to Android-x86
that LOCAL_POST_INSTALL_CMD only works if /system/etc existed. So when you start to compile the whole rom from the beginning it will fail and you have to mkdir it manually. That's why I left it there

But today I saw that Jon make it work by reusing LineageOS's code : Include terminfo again · BlissRoms-x86/android_external_libncurses@f10b074 · GitHub

> I hope to clean it up further. For example,
> I believe the generated Makefile and binaries
> are not used by android. They could be removed.

I hope so, because the source seems messy after I run ./configure
Vào lúc 15:43:00 UTC+7 ngày Chủ Nhật, 4 tháng 4, 2021, Chih-Wei Huang đã viết:

Chih-Wei Huang

unread,
Jun 22, 2021, 5:52:54 PM6/22/21
to Android-x86
Huy Minh Bui <buin...@gmail.com> 於 2021年4月4日 週日 下午5:18寫道:
> that LOCAL_POST_INSTALL_CMD only works if /system/etc existed. So when you start to compile the whole rom from the beginning it will fail and you have to mkdir it manually. That's why I left it there
>
> But today I saw that Jon make it work by reusing LineageOS's code : Include terminfo again · BlissRoms-x86/android_external_libncurses@f10b074 · GitHub
>
> > I hope to clean it up further. For example,
> > I believe the generated Makefile and binaries
> > are not used by android. They could be removed.
>
> I hope so, because the source seems messy after I run ./configure

Sorry for replying so late.

I just have some time to work on it.
The alsa_alsamixer and libncurses are added to oreo-x86 and later.
I didn't use your libncurses repo directly. But it helps a lot! Thank you!
I worked out a way to generate all the files at build time.
Except Android.mk no additional file is added.

About LOCAL_POST_INSTALL_CMD issue, it's easy to be solved
by adding mkdir -p $dir to it.
But I didn't use it at all. I built libncurses with fallback support
so it doesn't need any terminfo files.
However, only term type 'linux', 'xterm', 'vt100' are supported.
I think that's enough.

Huy Minh Bui

unread,
Jun 23, 2021, 2:02:46 PM6/23/21
to Android-x86
Thanks for helping me rewrite the sources, now they all look nicely done and better. :D 
Although I can't compile on nougat-x86 since there are some part on Android.mk is only available on oreo, but it's fine, we have a better source for future Android version now.
by the way, one more thing I'd like to ask is that how can I use 2 prop "audio.hal.in" and "audio.hal.out" to switch the input/output for audio. There are a few people putting it on init.sh script or build.prop but it just work like randomly (sometimes it work, sometimes it doesn't) so I want to know where should I put so that it will effectively work 100% all the time ?
Vào lúc 04:52:54 UTC+7 ngày Thứ Tư, 23 tháng 6, 2021, Chih-Wei Huang đã viết:

Chih-Wei Huang

unread,
Jun 23, 2021, 11:15:46 PM6/23/21
to Android-x86
Huy Minh Bui <buin...@gmail.com> 於 2021年6月24日 週四 上午2:02寫道:
> Thanks for helping me rewrite the sources, now they all look nicely done and better. :D
> Although I can't compile on nougat-x86 since there are some part on Android.mk is only available on oreo, but it's fine, we have a better source for future Android version now.
> by the way, one more thing I'd like to ask is that how can I use 2 prop "audio.hal.in" and "audio.hal.out" to switch the input/output for audio. There are a few people putting it on init.sh script or build.prop but it just work like randomly (sometimes it work, sometimes it doesn't) so I want to know where should I put so that it will effectively work 100% all the time ?

The properties are "hal.audio.out" and "hal.audio.in".
Typically the audio hal will select the first playback device
(usually /dev/snd/pcmC0D0p) and first capture device
(usually /dev/snd/pcmC0D0c). If they are not the devices
you want to use, you can use these properties to set the
device name, e.g., setprop hal.audio.in pcmC0D1c
Then restart audioserver by 'killall audioserver'.
Check the logcat to see if it works:

06-24 11:06:56.990 6395 6444 I audio_hw_primary: using pcmC0D1c from property
06-24 11:06:56.990 6395 6444 D audio_hw_primary: found audio in at
/dev/snd/pcmC0D1c
06-24 11:06:56.990 6395 6444 I audio_hw_primary: choose pcmC0D1c for 0

If the properties not work, probably because they are set after
audioserver started. Just restart audioserver as said above.

If you set them in /etc/init.sh but not work randomly, probably
there is a race condition between init.sh and audioserver.
I didn't check that carefully.
You may check the logcat to see what happened.

Best regards,
Chih-Wei

Huy Minh Bui

unread,
Jun 28, 2021, 1:45:27 AM6/28/21
to Android-x86

I have 2 devices currently : My internal card (Realtek ALC662 rev3) and a Webcam Mic (Logitech C270). I want to switching mic, the internal card have 2 capture devices (front and rear jack) and the webcam have 1 only. Currently all of Android-x86 version I installed so far are using the webcam one (pcmC1D0c) and I want to switch to rear one (pcmC0D0c), but I tried those commands :

setprop hal.audio.in pcmC0D0c
killall audioserver

But it still recognize my webcam mic as input, I tried many apps and it the same. Although logcat even said that pcC1D0c was ignored, it still being the main one.

I really want a way to dynamically switching I/O since a lot of users report about their mic problem can't switch to the input that they want.

Vào lúc 03:15:46 UTC ngày Thứ Năm, 24 tháng 6, 2021, Chih-Wei Huang đã viết:

Chih-Wei Huang

unread,
Jun 28, 2021, 1:04:22 PM6/28/21
to Android-x86
Huy Minh Bui <buin...@gmail.com> 於 2021年6月28日 週一 下午1:45寫道:
> I have 2 devices currently : My internal card (Realtek ALC662 rev3) and a Webcam Mic (Logitech C270). I want to switching mic, the internal card have 2 capture devices (front and rear jack) and the webcam have 1 only. Currently all of Android-x86 version I installed so far are using the webcam one (pcmC1D0c) and I want to switch to rear one (pcmC0D0c), but I tried those commands :
>
> setprop hal.audio.in pcmC0D0c
> killall audioserver
>
> But it still recognize my webcam mic as input, I tried many apps and it the same. Although logcat even said that pcC1D0c was ignored, it still being the main one.

Could you show the logcat after killall audioserver?
You may also trace hardware/libaudio/audio_hw.c
in the source tree to see what went wrong.
Reply all
Reply to author
Forward
0 new messages