Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Linux] [ALSA] It is not possible to specify a capture device for ALSA and not work with USB web-camera #5380

Closed
IlyaIndigo opened this issue Nov 11, 2018 · 28 comments

Comments

@IlyaIndigo
Copy link

IlyaIndigo commented Nov 11, 2018

Steps to reproduce

  1. Remove pulseaudio and config sound with ALSA.
  2. Run Telegram and try call or send voice message.

Expected behaviour

A Telegram must be able to specify a capture device (hw:0,0) (at least through an environment variable).
With ALSA, the default capture device does not work, since dmix works only with the playback device.

Actual behaviour

Mute capture device.

Configuration

Any GNU/Linux with ALSA only (openSUSE Tumbleweed).
Version of Telegram Desktop:
2.3.2 for GNU/Linux (KDE)

In log empty.

QEventLoop: Cannot be used without QApplication
QApplication: invalid style override passed, ignoring it.

@stek29
Copy link
Contributor

stek29 commented Nov 12, 2018

@IlyaIndigo you've mixed up expected and actual behavior :)

@IlyaIndigo
Copy link
Author

IlyaIndigo commented Nov 12, 2018

@IlyaIndigo Благодарю! :-)

@IlyaIndigo
Copy link
Author

IlyaIndigo commented Feb 5, 2019

In 1.5.11 for GNU/Linux, the options for setting up playback and capture devices appeared, but they do not work.

When you click on "Output device" or "Input device", the application freezes.
stdout is empty!
When I click on "Test microphone", in stdout.

E/tgvoip: pa_context_connect failed: Access denied
W/tgvoip: PulseAudio available but not working; trying ALSA

And the microphone is still mute.

@grishka
Copy link
Contributor

grishka commented Feb 6, 2019

А можете попробовать запустить под gdb и скинуть стек, в каком месте главный поток виснет?

@IlyaIndigo
Copy link
Author

Благодарю Вас за быстрый ответ, да ещё и на родном языке! :-)
Прямо сейчас, как оказалось, нет. Меинтайнер не включил в сборку debuginfo. :-(
Я создал свою сборку в хомяке https://build.opensuse.org/package/show/home:13ilya/telegram-desktop как только она соберётся я приложу сюда отладочный стек.

Предполагаю, что приложение ожидает обнаружить pulseaudio, возможно даже отключённый, а не обнаружив его в принципе не знает что делать дальше.

P.S. Никогда ранее не использовал gdb.
Нужно просто установить соответствующий debuginfo-пакет и выполнить
gdb telegram-desktop (> /tmp/stack.log)
Или что то ещё?

@grishka
Copy link
Contributor

grishka commented Feb 6, 2019

Не, не настолько просто (к сожалению). Запускать да, через gdb telegram-desktop, потом run, потом воспроизвести зависание, нажать в консоли Ctrl+C и вывести стек через bt. Можно даже для всех потоков сразу через thread apply all bt, но я сам так не пробовал.

@IlyaIndigo
Copy link
Author

Понятно, когда же надо начинать изучать работу с отладчиком, вот и повод. ;-)

@IlyaIndigo
Copy link
Author

IlyaIndigo commented Feb 6, 2019

Сразу после запуска gdb telegram-desktop:.

GNU gdb (GDB; openSUSE Tumbleweed) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-suse-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.opensuse.org/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from telegram-desktop...Reading symbols from /usr/lib/debug/usr/bin/telegram-desktop-1.5.11-20.1.x86_64.debug...../../gdb/cp-support.c:1581: demangler-warning: unable to demangle '_ZNSt11_Tuple_implILm0EJN3rpl8producerIN4base5flagsIN11MTPDchannel4FlagEEENS0_8no_errorEZNS0_7details10map_helperIZN4Data18FlagsValueWithMaskINSA_5FlagsIS6_Lj2147486693EE6ChangeES7_ZNS8_11then_helperISE_S7_ZNKS0_12event_streamISE_E6eventsEvEUlRKT_E_EclISE_S7_ZNS0_6singleISE_EEDaOSI_EUlSK_E_SE_S7_EEDaONS1_ISI_T0_T1_EEEUlSK_E_EEDaSU_NSI_4TypeEEUlRKSE_E0_EclISE_S7_ZNS8_13filter_helperIZNSB_ISE_S7_SV_EEDaSU_SW_EUlSY_E_EclISE_S7_SV_vEEDaSU_EUlSK_E_S6_EEDaSU_EUlSK_E_EENS1_IbS7_ZNS9_IZNSA_15SingleFlagValueINSC_INS3_IN19MTPDchatAdminRights4FlagEEELj4294967295EE6ChangeES7_ZNSF_IS1E_S7_ZNKSG_IS1E_E6eventsEvEUlSK_E_EclIS1E_S7_ZNSO_IS1E_EEDaSP_EUlSK_E_S1E_S7_EEDaSU_EUlSK_E_EEDaSU_NSI_4EnumEEUlS1C_E_EclIS1C_S7_ZNS9_IZNSB_IS1E_S7_S1K_EEDaSU_SW_EUlRKS1E_E0_EclIS1E_S7_ZNS12_IZNSB_IS1E_S7_S1K_EEDaSU_SW_EUlS1Q_E_EclIS1E_S7_S1K_vEEDaSU_EUlSK_E_S1C_EEDaSU_EUlSK_E_bEEDaSU_EUlSK_E_EENS1_IbS7_ZNS9_IZNS19_INSC_INS3_IN20MTPDchatBannedRights4FlagEEELj4294967295EE6ChangeES7_ZNSF_IS25_S7_ZNKSG_IS25_E6eventsEvEUlSK_E_EclIS25_S7_ZNSO_IS25_EEDaSP_EUlSK_E_S25_S7_EEDaSU_EUlSK_E_EEDaSU_S1L_EUlS23_E_EclIS23_S7_ZNS9_IZNSB_IS25_S7_S2B_EEDaSU_SW_EUlRKS25_E0_EclIS25_S7_ZNS12_IZNSB_IS25_S7_S2B_EEDaSU_SW_EUlS2G_E_EclIS25_S7_S2B_vEEDaSU_EUlSK_E_S23_EEDaSU_EUlSK_E_bEEDaSU_EUlSK_E_EES2Q_EED2Ev' (demangler failed with signal 11)
Unable to dump core, use `ulimit -c unlimited' before executing GDB next time.
../../gdb/cp-support.c:1595: demangler-warning: unable to demangle '_ZNSt11_Tuple_implILm0EJN3rpl8producerIN4base5flagsIN11MTPDchannel4FlagEEENS0_8no_errorEZNS0_7details10map_helperIZN4Data18FlagsValueWithMaskINSA_5FlagsIS6_Lj2147486693EE6ChangeES7_ZNS8_11then_helperISE_S7_ZNKS0_12event_streamISE_E6eventsEvEUlRKT_E_EclISE_S7_ZNS0_6singleISE_EEDaOSI_EUlSK_E_SE_S7_EEDaONS1_ISI_T0_T1_EEEUlSK_E_EEDaSU_NSI_4TypeEEUlRKSE_E0_EclISE_S7_ZNS8_13filter_helperIZNSB_ISE_S7_SV_EEDaSU_SW_EUlSY_E_EclISE_S7_SV_vEEDaSU_EUlSK_E_S6_EEDaSU_EUlSK_E_EENS1_IbS7_ZNS9_IZNSA_15SingleFlagValueINSC_INS3_IN19MTPDchatAdminRights4FlagEEELj4294967295EE6ChangeES7_ZNSF_IS1E_S7_ZNKSG_IS1E_E6eventsEvEUlSK_E_EclIS1E_S7_ZNSO_IS1E_EEDaSP_EUlSK_E_S1E_S7_EEDaSU_EUlSK_E_EEDaSU_NSI_4EnumEEUlS1C_E_EclIS1C_S7_ZNS9_IZNSB_IS1E_S7_S1K_EEDaSU_SW_EUlRKS1E_E0_EclIS1E_S7_ZNS12_IZNSB_IS1E_S7_S1K_EEDaSU_SW_EUlS1Q_E_EclIS1E_S7_S1K_vEEDaSU_EUlSK_E_S1C_EEDaSU_EUlSK_E_bEEDaSU_EUlSK_E_EENS1_IbS7_ZNS9_IZNS19_INSC_INS3_IN20MTPDchatBannedRights4FlagEEELj4294967295EE6ChangeES7_ZNSF_IS25_S7_ZNKSG_IS25_E6eventsEvEUlSK_E_EclIS25_S7_ZNSO_IS25_EEDaSP_EUlSK_E_S25_S7_EEDaSU_EUlSK_E_EEDaSU_S1L_EUlS23_E_EclIS23_S7_ZNS9_IZNSB_IS25_S7_S2B_EEDaSU_SW_EUlRKS25_E0_EclIS25_S7_ZNS12_IZNSB_IS25_S7_S2B_EEDaSU_SW_EUlS2G_E_EclIS25_S7_S2B_vEEDaSU_EUlSK_E_S23_EEDaSU_EUlSK_E_bEEDaSU_EUlSK_E_EES2Q_EED2Ev' (demangler failed with signal 11)
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) y

This is a bug, please report it.  For instructions, see:
<http://bugs.opensuse.org/>.

Это ошибка gdb, патчей в openSUSE, telegram-desktop, или я что-то сделал не так?

@IlyaIndigo
Copy link
Author

IlyaIndigo commented Apr 7, 2019

Решил для себя проблему настройкой ALSA
~.asoundrc

pcm.!default {
	type asym
		playback.pcm "plug:dmix"
		capture.pcm "plughw:0,0"
	hint.description "Default with dmix"
	hint.show on
}
pcm.!sysdefault default

Теперь телеграм на устройстве default видит моё hw:0,0 и работает с ним.
Даже проверка микрофона заработала (полоски двигаются).
Но вот при попытке открыть диалог выбора устройства воспроизведения или захвата также намертво виснет.

@IlyaIndigo
Copy link
Author

К сожалению ещё не всё работает. :-(
На встроенной звуковой карте работает, но если подключить веб-камеру, то получается очень странное поведение у телеграм.
Родные приложения на Qt и WxWidgets (audacity) работают с default нормально.
Телеграм же работает по разному.

Голосовые сообщения он отправляет прекрасно, без вывода ошибок в stdout.

Но при проверке микрофона в настройках микрофон молчит и в stdout выводит

E/tgvoip: pa_context_connect failed: Access denied
W/tgvoip: PulseAudio available but not working; trying ALSA

и после прекращения проверки

E/tgvoip: snd_pcm_readi failed: Ошибка ввода/вывода`

При звонке, к сожалению, микрофон тоже молчит, и далее привожу краткий лог вывода

D/tgvoip: === Updating voip config ===
D/tgvoip: {"audio_frame_size":60,"jitter_min_delay_60":2,"jitter_max_delay_60":10,"jitter_max_slots_60":20,"jitter_losses_to_reset":20,"jitter_resync_threshold":0.5,"audio_congestion_window":1024,"audio_max_bitrate":20000,"audio_max_bitrate_edge":16000,"audio_max_bitrate_gprs":8000,"audio_max_bitrate_saving":8000,"audio_init_bitrate":16000,"audio_init_bitrate_edge":8000,"audio_init_bitrate_gprs":8000,"audio_init_bitrate_saving":8000,"audio_bitrate_step_incr":1000,"audio_bitrate_step_decr":1000,"use_system_ns":true,"use_system_aec":true,"force_tcp":false,"jitter_initial_delay_60":2,"adsp_good_impls":"(Qualcomm Fluence)","bad_call_rating":true,"use_ios_vpio_agc":false,"use_tcp":false,"audio_medium_fec_bitrate":20000,"audio_medium_fec_multiplier":0.1,"audio_strong_fec_bitrate":7000}
Invalid return value 0 for stream protocol
....
W/tgvoip: Set remote endpoints, allowP2P=1, connectionMaxLayer=92
V/tgvoip: Adding endpoint: xxx, UDP
I/tgvoip: update data saving mode, config 0, enabled 0, reqd by peer 0
W/tgvoip: Starting voip controller
V/tgvoip: trying bind to port 32414
D/tgvoip: Bound to local UDP port 32414
I/tgvoip: Receive thread starting
V/tgvoip: Socket 40 is ready to send
W/tgvoip: Send udp pings
V/tgvoip: Sending UDP ping to ****
....
I/tgvoip: before create audio io
E/tgvoip: pa_context_connect failed: Access denied
W/tgvoip: PulseAudio available but not working; trying ALSA
I/tgvoip: Detected IPv4 connectivity, will not try IPv6
V/tgvoip: Received UDP ping reply from xxx
....
I/tgvoip: AEC: 1 NS: 1 AGC: 1
I/tgvoip: Audio initialization took 0,206437 seconds
V/tgvoip: Call state changed to 2
....

Судя потому, что микрофон через default с другими приложениями работает, а также работает при записи и отправке голосовых сообщений но не работает при проверке микрофона и звонках, то что- всё же не так в телеграм.
Конфиг alsa

pcm.!default {
	type asym
		playback.pcm "plug:dmix"
		capture.pcm "plughw:1,0"
	hint.description "Default"
	hint.show on
}
pcm.!sysdefault default

ALSA: 1.1.9
Telegram: 1.7
Вебка: Genius FaceCam 1020 (USB Audio)

@IlyaIndigo IlyaIndigo changed the title [Linux] [ALSA] It is not possible to specify a capture device for ALSA [Linux] [ALSA] It is not possible to specify a capture device for ALSA and not work with USB web-camera May 28, 2019
@Aokromes
Copy link
Collaborator

#2231

@grishka
Copy link
Contributor

grishka commented Aug 28, 2019

Вообще меня уволили, так что хз кто и как теперь это исправит, и исправит ли вообще ¯\_(ツ)_/¯

@23rd
Copy link
Collaborator

23rd commented Aug 28, 2019

=(

@powerman
Copy link

@Aokromes Can you please provide a link to issue duplicated by this one?

@Aokromes
Copy link
Collaborator

Aokromes commented Feb 28, 2020

#5380 (comment) (i cannot rename tickets, but the bug is the same)

@ilya-fedin
Copy link
Contributor

ilya-fedin commented Feb 28, 2020

and not work with USB web-camera

Not a duplicate :)

@Aokromes
Copy link
Collaborator

"Steps to reproduce
Install external sound card or webcam"

@ilya-fedin
Copy link
Contributor

ilya-fedin commented Feb 28, 2020

#2231 is about openal doesn't support "fallback device" pulseaudio feature, this issue is about libtgvoip doesn't work with some hardware on ALSA

@powerman
Copy link

@Aokromes I don't see anything in common between these two issues. One is about Pulseaudio, multiple microphone sources, and not working microphone everywhere including voice messages. Another one is about ALSA and not working microphone only in voice calls but working in voice messages.

@IlyaIndigo
Copy link
Author

The problem in version 2.3.2 is still present!
1 The choice of the capture device does not freeze now, but only "Default" is available for selection, despite the fact that the system has 2 microphones!
2 You can still make a call only from the microphone connected to the sound card. From the microphone in the web camera, you can only send voice messages, but when you call it is mute.

@ilya-fedin
Copy link
Contributor

@IlyaIndigo libtgvoip was replaced with webrtc that doesn't support alsa, you should install pulseaudio

@powerman
Copy link

@ilya-fedin Is this ("you should install pulseaudio") an official position? 😠

@grishka
Copy link
Contributor

grishka commented Sep 23, 2020

My "you should not be disabling IPv6 in your kernel" pales in comparison lol.

@IlyaIndigo
Copy link
Author

@ilya-fedin Is this ("you should install pulseaudio") an official position? angry

I have a good idea of ​​what pulse-audio is.
This is just a layer, an extra abstraction that still works through alsa, introducing delays and distortions into the resulting sound path.
I don’t need its capabilities such as connecting bluetooth headsets or broadcasting sound somewhere.
At the same time, at least mpd does not work with it in client-server mode, where mpd runs from an independent user mpd and starts up to graphical mode.
Also I have enough console emulators and old games without pulseaudio support and I don't know how they will work with that.
And also, I heard that pulseaudio itself is already outdated and Redhat again came up with something to replace it.
So I don't see the point in using pulseaudio yet and for me it's wild that browser developers and then you followed the microsoft path, dropping alsa support.
Although I still use both firefox and telegram with alsa, the only problem is with the microphone.

@ilya-fedin
Copy link
Contributor

ilya-fedin commented Sep 23, 2020

So I don't see the point in using pulseaudio yet and for me it's wild that browser developers and then you followed the microsoft path, dropping alsa support.

Feel free to contribute to google's webrtc library to implement fallback to alsa when pulseaudio is inaccessible

@IlyaIndigo
Copy link
Author

My "you should not be disabling IPv6 in your kernel" pales in comparison lol.

I no longer turn off ipv6 (although I physically do not have it), but this does not affect the capture device via the web camera in any way.

@grishka
Copy link
Contributor

grishka commented Sep 23, 2020

I no longer turn off ipv6 (although I physically do not have it), but this does not affect the capture device via the web camera in any way.

I'm referring to the fact that libtgvoip used a single dual-stack UDP socket for everything to simplify code, and also because I'm lazy af. This obviously didn't work for those who disabled IPv6 for some reason (the kernel no longer understood what AF_INET6 was) and that was about the only shortcoming this approach had.

@github-actions
Copy link

github-actions bot commented Mar 4, 2021

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants