Thinstation / thinstation

A framework for making thin and light Linux based images for x86 based machines and thinclients.
https://www.thinstation.net/
804 stars 187 forks source link

USB camera and headset do not work #811

Open Aleksa2022 opened 7 months ago

Aleksa2022 commented 7 months ago

USB headset and USB camera do not want to work properly. In the headset the sound comes with artifacts - gurgling, wheezing, etc. Through the mini-jack 3.5 mm everything works normally. The camera does not work at all. I thought updating the ports would help - I did, it didn't help.

These errors were recorded in the logs: Wa(03) usbArb USBGL: Failed to open '/sys/bus/usb/devices/8-1/serial', error(0x2). Wa(03) usbArb USBGL: Failed to open '/sys/bus/usb/devices/8-1/serial', error(0x2). Wa(03) usbArb USBGL: Failed to open '/sys/bus/usb/devices/1-3/manufacturer', error(0x2).

Added to buildtime: MOUNT_1="usbdevfs /proc/bus/usb usbdevfs devmode=0666,noauto 0 0 0"

That didn't help either - the camera doesn't work, it behaves as if it's not alive at all. I plugged it into another port and the system froze completely - it's the first time I've seen such a trick.

There is no USB: /proc/bus/ - nothing mounted. The camera seems to be connected: Bus 001 Device 002: ID 046d:0817 Logitech, Inc.

In the list of USB devices, by camera shows this: T: Bus=01 Lev=01 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=480 MxCh= 0 D: Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=046d ProdID=0817 Rev=00.10 S: SerialNumber=83177780 C: #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA I: If#=0x0 Alt= 0 #EPs= 1 Cls=0e(video) Sub=01 Prot=00 Driver=(none) I: If#=0x1 Alt= 0 #EPs= 0 Cls=0e(video) Sub=02 Prot=00 Driver=(none)

There are no problems with this one: Bus 008 Device 003: ID 04ca:009c Lite-On Technology Corp. USB Keyboard Bus 008 Device 002: ID 04ca:008a Lite-On Technology Corp. USB Optical Mouse

T: Bus=08 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=1.5 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 P: Vendor=04ca ProdID=008a Rev=01.00 S: Manufacturer=PixArt S: Product=USB Optical Mouse C: #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA I: If#=0x0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=usbhid

T: Bus=08 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 3 Spd=1.5 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 P: Vendor=04ca ProdID=009c Rev=02.65 S: Manufacturer=Lite-On Technology Corp S: Product=USB Keyboard C: #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=100mA I: If#=0x0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=01 Driver=usbhid I: If#=0x1 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=usbhid

What else can I do? I can't think of anything practical to do yet..... Kernel: 6.1.78 Vmview: 8.12

Aleksa2022 commented 7 months ago

I solved the USB camera problem by updating the firmware and adding a line to buildtime: USB_MOUNT_DIR="/proc/bus/usb" But, it didn't solve the problem with sound through USB-headset - there are still artifacts - sound is gurgling and lags behind (sometimes it goes exactly with video, sometimes it lags behind by some milliseconds). If you just switch to a regular headset with a 3.5 mm plug, the problems disappear immediately - the sound works perfectly.

I haven't thought of anything else to try yet....

Maksim-Garikov commented 7 months ago

Hello! I've also noticed some interesting behavior. When connecting USB headphones or a webcam, the microphone and camera work, but there is no sound. However, with 3.5mm jack headphones, the situation is reversed. The sound works, but the microphone does not.

Currently, I'm trying to fix the audio output through these two commands. I'm attaching them here in case you come up with a solution. They need to be added to thinstation.conf.buildtime.

pactl set-card-profile 0 "output:analog-stereo+input:analog-stereo" pactl set-sink-port "alsa_output.pci-0000_00_1b.0.analog-stereo" "analog-output-headphones"

Thinstation commented 7 months ago

Have a look at this ts/build/packages/alsa/build/extra/etc/init.d/audio

This script is executed once during system init. Possibly you could write a rule that will re-execute it when a usb headphone is plugged/unplugged.

Aleksa2022 commented 7 months ago

pactl set-card-profile 0 "output:analog-stereo+input:analog-stereo" pactl set-sink-port "alsa_output.pci-0000_00_1b.0.analog-stereo" "analog-output-headphones"

Hello! Didn't help. When assembling, errors were generated: Connection failure: Connection refused pa_context_connect() failed: Connection refused The image assembled normally, but the sound is with artifacts. Not only that, maybe now I paid special attention to it, - video is also slowed down. Video from webcam works fine. But video, for example, from youtube, with an analog headset connected works fine - both video and sound. The error pa_context_connect() failed is clear: "The regular systemctl, the PID 1, indeed cannot access the environement variables of the current user when launching a service. Since pactl relies on those variables to find what instance of pulseaudio it needs to connect to, it is unable to do so when launched though a service." If we use this solution, we need to insert a script launch by event somewhere. Although, in our build everything works under root - in this case we will have to add something else. In general, everything is interesting because in old builds USB-headsets did not work at all. Now they work, shitty, but they work. Progress is evident! If only all this beauty worked properly - it would be worth it.

Maksim-Garikov commented 7 months ago

I noticed a strange thing. Before this, my USB_MOUNT_DIR parameter was set to "/mnt/usbdevice/sda1." I changed it to "/proc/bus/usb," as you have, and this miracle started working. The sound appeared in the USB headphones, the microphone was functioning, and the webcam was working. However, after a reboot, everything stopped working. Moreover, the boot is through PXE, so each time there's a new session on boot. This was also the case when I initially set the parameter to "/mnt/usbdevice/sda1," but it stopped working after a reboot.

It might indeed be worth trying to fix ts/build/packages/alsa/build/extra/etc/init.d/audio.

Aleksa2022 commented 7 months ago

My parameters are as follows: AUDIO_LEVEL=90 MIC_LEVEL=90


Other parameters


USB_MOUNT_DIR="/mnt/usbdevice" USB_MOUNT_DIR="/proc/bus/usb"

Aleksa2022 commented 7 months ago

In /packages/base/base/etc/udev/rules.d I added a line for my headset, similar to other devices described there. SUBSYSTEM=="usb" etc. I tried specifying a reference to /etc/init.d/audio RUN+="/etc/init.d/audio" didn't help. I made my own file with parameters and specified in udev:

pactl set-card-profile 0 "output:analog-stereo+input:analog-stereo"
pactl set-sink-port "alsa_output.pci-0000_00_1b.0.analog-stereo" "analog-output-headphones".

Didn't help either. The changes I made had no effect on the result - video and sound are with artifacts, and even slower than they should be. I don't understand what kind of retarder is glued on. Video goes as soon as I disconnect the USB headset and connect the analog headset, everything is fine. I switch back to USB, without stopping the video, the brakes and gurgling come back again.

Maksim-Garikov commented 7 months ago

Are changes to /build/packages/alsa/build/extra/etc/init.d/audio really affecting the image? I made edits to the code, but I don't see any changes. Could there be any dependency on the pulseaudio package in ThinStation?

Aleksa2022 commented 7 months ago

God is in you - how can pulseaudio affect the image? Sound quality - yes, its presence - too, but it has nothing to do with the picture. These are system components and everyone can bring problems and joys from themselves. Sound - pulseaudio, alsa. That's the minimum. Images, video - Xorg, etc. Although even here everything is not so clear-cut - one can influence and interfere with the other. I have already had the good fortune to encounter such things - it's Linux! - It's a big constructor with a lot of stuff. :-)

Maksim-Garikov commented 7 months ago

Yes, I understand. It's just that my situation is the opposite. The webcam and microphone are working, but there's no sound in the headphones. However, if I connect headphones via the 3.5mm jack, the sound works but not the microphone. Are you using 6.2-stable? The video camera, by the way, started working after adding parameters to thinstation.conf.buildtime is USB_SYNC_ON and USB_MOUNT_DIR.

Maksim-Garikov commented 7 months ago

Forgot the mentioned parameter USE_XRANDR

Aleksa2022 commented 7 months ago

Yes, I'm using 6.2-stable. I thought maybe there was something in the 6.1 kernel that caused these problems, but no. Rolled the kernel back to 5.15.150, updated the firmware and reassembled - everything is exactly the same. I tweaked the kernel config:

Aleksa2022 commented 7 months ago

ALSA has a file for configuring USB-Audio!

/alsa/lib/alsa/cards/USB_Audio.conf

Here you can write rules for working with USB-devices. I added a rule for my headset Logitech Clear Chat Comfort USB Headset. After the build it started working better. Artifacts are there, slowdowns are there. Ugly, but not as ugly. Now "wave-like" slowdowns with artifacts - then slowed down, then at normal speed. There are fewer artifacts. Still looking suspiciously at the bitrate of the audio stream. But I'm not sure. I need to dig some more... There is a feeling that some small thing is missing.

Maksim-Garikov commented 7 months ago

Please advise, in which section should I add the device name in the code? Is it in USB-Audio.pcm.iec958_device? And should I enter the device name as it appears in lsusb output?

Maksim-Garikov commented 7 months ago

Or you named it separately and added parameters that are present in the config. For example:

USB-Audio.pcm.default."YourUSBDevice" { @args [ CARD ] @args.CARD { type string }

Doncuppjr commented 7 months ago

If your using freerdp with usb redirection, perhaps that is the issue. Instead of just sending audio, it might be sending the whole usb stream and letting the server do the conversion. Maybe there is a filter that can be enabled in freerdp to prevent that.  For testing I would recommend trying to playback some local media without making a freerdp connection.

Sent from Yahoo Mail for iPhone

On Wednesday, March 6, 2024, 4:58 AM, Alesandro @.***> wrote:

ALSA has a file for configuring USB-Audio!

/alsa/lib/alsa/cards/USB_Audio.conf

Here you can write rules for working with USB-devices. I added a rule for my headset Logitech Clear Chat Comfort USB Headset. After the build it started working better. Artifacts are there, slowdowns are there. Ugly, but not as ugly. Now "wave-like" slowdowns with artifacts - then slowed down, then at normal speed. There are fewer artifacts. Still looking suspiciously at the bitrate of the audio stream. But I'm not sure. I need to dig some more... There is a feeling that some small thing is missing.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

Maksim-Garikov commented 7 months ago

@Doncuppjr Hello, Donald. I'm trying to set up sound, microphone, and video playback in the ThinStation image. After that, I test it on a remote desktop through Citrix. I added specific parameters to thinstation.conf.buildtime for sound, video, and microphone redirection.

ICA_AUDIO=ON ICA_AUDIO_QUALITY=High ICA_WFCLIENT_AllowAudioInput=True ICA_WFCLIENT_HDXWebCamDevice=True

If sound and microphone work in USB headphones within the ThinStation image, everything works on the remote desktop. However, I managed to configure sound output twice after changing the USB_MOUNT_DIR parameter, but after a reboot, the settings reset, and sound output stops working. The image is loaded via PXE.

Can you advise why the ThinStation settings reset after a reboot, causing the sound output to stop working, even after configuring the parameters?

Thinstation commented 7 months ago

You would have to put the changes into the image itself or a configuration file that is read at each boot. TS was designed to not persist changes, but it can read configuration files that can make changes on every boot.

On Wed, Mar 6, 2024 at 7:45 AM Maksim-Garikov @.***> wrote:

@Doncuppjr https://github.com/Doncuppjr Hello, Donald. I'm trying to set up sound, microphone, and video playback in the ThinStation image. After that, I test it on a remote desktop through Citrix. I added specific parameters to thinstation.conf.buildtime for sound, video, and microphone redirection.

ICA_AUDIO=ON ICA_AUDIO_QUALITY=High ICA_WFCLIENT_AllowAudioInput=True ICA_WFCLIENT_HDXWebCamDevice=True

If sound and microphone work in USB headphones within the ThinStation image, everything works on the remote desktop. However, I managed to configure sound output twice after changing the USB_MOUNT_DIR parameter, but after a reboot, the settings reset, and sound output stops working. The image is loaded via PXE.

Can you advise why the ThinStation settings reset after a reboot, causing the sound output to stop working, even after configuring the parameters?

— Reply to this email directly, view it on GitHub https://github.com/Thinstation/thinstation/issues/811#issuecomment-1981028999, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVW47UCYRA4D2UBINSQ433YW4TXHAVCNFSM6AAAAABD3YZQ5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBRGAZDQOJZHE . You are receiving this because you commented.Message ID: @.***>

Maksim-Garikov commented 7 months ago

@Doncuppjr What parameter needs to be added/modified to enable sound output on USB headphones and make it work consistently? Or what should be added to the ALSA package to ensure continuous functionality of sound on USB headphones? And why did I only succeed in achieving sound output twice after changing a parameter in thinstation.conf.buildtime? After modifying the parameter, the image build remains unchanged after loading it onto the TFTP server, so sound output should work after system reboot. However, it behaves differently after reboot.

Thinstation commented 7 months ago

If you put into .buildtime it should be in the image. Maybe your tftp is still sending out an old build

On Wed, Mar 6, 2024 at 7:56 AM Maksim-Garikov @.***> wrote:

@Doncuppjr https://github.com/Doncuppjr What parameter needs to be added/modified to enable sound output on USB headphones and make it work consistently? Or what should be added to the ALSA package to ensure continuous functionality of sound on USB headphones? And why did I only succeed in achieving sound output twice after changing a parameter in thinstation.conf.buildtime? After modifying the parameter, the image build remains unchanged after loading it onto the TFTP server, so sound output should work after system reboot. However, it behaves differently after reboot.

— Reply to this email directly, view it on GitHub https://github.com/Thinstation/thinstation/issues/811#issuecomment-1981053479, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVW47VMEVVXDXTHXI2N5JTYW4VCXAVCNFSM6AAAAABD3YZQ5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBRGA2TGNBXHE . You are receiving this because you commented.Message ID: @.***>

Aleksa2022 commented 7 months ago

Please advise, in which section should I add the device name in the code? Is it in USB-Audio.pcm.iec958_device? And should I enter the device name as it appears in lsusb output?

I added my device to the same place where the other "Logitec" devices were listed, I got the name from lsusb.

Aleksa2022 commented 7 months ago

If your using freerdp with usb redirection, perhaps that is the issue. Instead of just sending audio, it might be sending the whole usb stream and letting the server do the conversion. Maybe there is a filter that can be enabled in freerdp to prevent that. For testing I would recommend trying to playback some local media without making a freerdp connection.

No, I'm using VMware Horizon. I can assume that RTAV is involved in this problem. Previously, my USB headset did not work at all. Now I've decided to do a little bit more work and started looking into the problem. That's an interesting idea about redirecting the entire stream. I suppose it could be like that. Although, VMware must have thought about thread separation and redirection of USB, MMR, etc. should not conflict or create mutual problems....

Doncuppjr commented 7 months ago

The USB_MOUNT_DIR only comes into play when mounting usb storage devices, and then only if the automount package is included. Perhaps restarting the application is producing the difference, not the changes you are making. On Wednesday, March 6, 2024 at 07:56:44 AM MST, Maksim-Garikov @.***> wrote:

@Doncuppjr What parameter needs to be added/modified to enable sound output on USB headphones and make it work consistently? Or what should be added to the ALSA package to ensure continuous functionality of sound on USB headphones? And why did I only succeed in achieving sound output twice after changing a parameter in thinstation.conf.buildtime? After modifying the parameter, the image build remains unchanged after loading it onto the TFTP server, so sound output should work after system reboot. However, it behaves differently after reboot.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

Aleksa2022 commented 7 months ago

The USB_MOUNT_DIR only comes into play when mounting usb storage devices, and then only if the automount package is included. Perhaps restarting the application is producing the difference, not the changes you are making.

Yes, but I, for example, did not take this parameter from the sky - in a number of sources I came across, it was just stated that such a mounting solves the problem with video cameras. As you can see, to a certain extent it does.

Aleksa2022 commented 7 months ago

I have errors in the log RTAV: ConnectPulseAudioDaemon - pa_context_connect() failed I'm trying to do something about it now. Default_context was disabled in the configs. I enabled it and changed some parameters at the same time. By the way, pulseaudio is very outdated. According to the existing port settings, I was able to update it to 14.2. Further, the ./configure script is excluded and meson should be used instead. I haven't managed to get the build and installation with meson yet - I don't understand something and I'm doing something wrong. Here I tried to raise the version to at least 15:

+ build
+ cd pulseaudio-15.0
+ meson setup

ERROR: Must specify at least one directory name.
=======> ERROR: Building '/ts/ports/opt/pulseaudio/pulseaudio/pulseaudio#15.0-1.pkg.tar.xz' failed.
Aleksa2022 commented 7 months ago

Changed parameters in pulseaudio configs: enabled default_context, increased parameters of working with fragments now artifacts are almost gone, but the speed (subjectively) is about 0.8-0.9 from the actual one when connecting a USB headset. I still don't understand what else is interfering. I will try to reduce the realtime-priority value - now it is 5, I will try to set it to 3. Or turn on high-priority.

Aleksa2022 commented 7 months ago

Changing these parameters did nothing - nothing changed at all. Looked in the logs again:

In(05) host-13361 RTAV: Init - Starting audio device monitor
2024-03-07T07:45:17.722Z Wa(03) host-13361 RTAV: ConnectPulseAudioDaemon - pa_context_connect() failed
2024-03-07T07:45:17.722Z Wa(03) host-13361 RTAV: StartPulseAudioDaemon - Start PulseAudio daemon failed
2024-03-07T07:45:17.722Z Wa(03) host-13361 RTAV: Init - Failed to init mAudioDevMonitor
In(05) host-13361 RTAV: Init - Started audio device monitor
In(05) host-13361 RTAV: Start - The thread starts successfully: 7FEAC40022D0.
In(05) host-13361 RTAV: Init - Starting UI config monitor
In(05) host-13361 RTAV: Init: Monitor file path: /home/mon/.vmware.
In(05)+ host-13361 
In(05) host-13361 RTAV: Start - The thread starts successfully: 7FEAC00021F8.
In(05) host-13361 RTAV: StartMonitoring: start monitoring.
In(05) host-13361 RTAV: Init - Started ConfigMonitor
In(05) host-13361 RTAV: Start - The thread starts successfully: 7FEAC0003670.
In(05) host-13361 RTAV: Init - Started video device monitor
In(05) host-13375 RTAV: DevChangeEventProcessThreadCB - Audio device changed
In(05) host-13361 RTAV: Start - The thread starts successfully: 7FEAC4003930.

I rewired this - I had a USB headset first, then took it out and plugged in an analog headset. So far I've run out of ideas on what else to tweak.