User:Andy Crowd/sandbox/Fix no sound problem in Skype

From ArchWiki
Now only "pulseaudio -vvvv" examples are taken from the PulseAudio article, could not reproduce error with watches for kernel by myself.
See also Skype and PulseAudio articles in this wiki.
PerfectSetup - documentation.

If sound doesn't work in Skype with pulseaudio then here you can find descriptions about some of pulseaudio sound problems and necessary basic configuration of it to make sound work.

Configure pulseadio

The easiest way always is when you are using tools that can make the automatic configuration or at least temporary that you can dump into the configuration file such as pavucontrol sound mixer for PulseAudio.



One of the default and commented options is ; resample-method = speex-float-1 where instead of the speex-float-1 value recommended to use auto: resample-method = auto. And those two options must stay commented: ; exit-idle-time = 20 and ; scache-idle-time = 20 and uncomment all other remaining options.. The dl-search-path option must contain path to the pulseaudio modules, e.g. dl-search-path = /usr/lib/pulse-5.0/modules.

Determinate supported frequency by your sound card with qarecordAUR:

$ arecord -f dat -r 60000 -D hw:0,0 -d 5 /tmp/test.wav
Recording WAVE '/tmp/test.wav' : Signed 16 bit Little Endian, Rate 60000 Hz, Stereo
Warning: rate is not accurate (requested = 60000Hz, got = 48000Hz)
         please, try the plug plugin

Here are settings for sound rates where you can set correct freq for the alternate-sample-rate that contains in the got = 48000Hz settings output of the arecord command.

default-sample-rate = 48000
alternate-sample-rate = 44100

Contains configuration about sinks which to use and configuration of their settings.

If you set up sinks manually then you will need to disable modules that auto-detects sink devices.

# load-module module-udev-detect
# load-module module-detect

The dmix device is used for sound cards output that doesn't support a hardware mixing.

load-module module-alsa-sink device=dmix

The dsnoop is used for input or recording of sound for sound-cards that doesn't support a hardware mixing

load-module module-alsa-source device=dsnoop

Example of configuration where OSS modules are used for output instead of ALSA

load-module module-alsa-source source_name=input device=hw:2
#load-module module-alsa-sink sink_name=combined
#load-module module-alsa-sink sink_name=alsa_output.pci-0000_04_01.0.analog-stereo
load-module module-oss device=/dev/dsp sink_name=alsa_output.pci-0000_04_01.0.analog-stereo mmap=1

See also - man page

List sinks

You can get full list available of sinks only if load-module module-udev-detect and load-module module-detect are not commented otherwise it will show only them that you set manually. You must chose correct input and output sources to make sound work. If you don't know name of a correct output/input then you can test one by one but don't forget to restart pulseaudio with commands pulseaudio -k && sleep 2 && pulseaudio --start each time you make changes.

Sink output

In this example you will see only a part of a whole output

$ pactl list-sinks
Sink #0
	Name: alsa_output.dmix
	Description: CMI8738/CMI8768 PCI Audio (CMI8738/C3DX PCI Audio Device)
	Driver: module-alsa-sink.c
	Sample Specification: s16le 2ch 48000Hz
	Channel Map: front-left,front-right
	Owner Module: 5
	Mute: no
Sink #1
	Name: combined
	Description: Simultaneous output to CMI8738/CMI8768 PCI Audio (CMI8738/C3DX PCI Audio Device)
	Driver: module-combine-sink.c
	Sample Specification: s16le 2ch 44100Hz

The sink name you can find in a line that contains something like Name: alsa_output.dmix and option for it will be sink_name=alsa_output.dmix.

Example of a configuration line in

  • For ALSA modules
load-module module-alsa-sink sink_name=alsa_output.dmix
  • For OSS modules
load-module module-oss device=/dev/dsp sink_name=alsa_output.pci-0000_04_01.0.analog-stereo mmap=1
Note: The "alsa_output.dmix" is used by dmix device, e.g. load-module module-alsa-sink device=dmix

Sink input

The device.string variable contains "hw:" or any other hardware id that you can use in a source input command string in the load-module module-alsa-source source_name=input device=hw:2

Example of device.string:

device.string = "hw:2"
device.string = "1"
device.string = "0"
device.string = "front:0"

Example of a sink sources list:

$ pactl list-sources
Source #5
        State: SUSPENDED
        Name: alsa_input.usb-_Webcam_C170-02-C170.analog-mono
        Description: Webcam C170 Analog Mono
        Driver: module-alsa-card.c
        Sample Specification: s16le 1ch 44100Hz
        Channel Map: mono
        Owner Module: 30
        Mute: no
       = "usb-_Webcam_C170-02-C170"
                device.bus = "usb"
       = "046d"
       = "Logitech, Inc."
       = "082b"
       = "Webcam C170"
                device.serial = "_Webcam_C170"
                device.form_factor = "webcam"
                device.string = "hw:2"

Sound mute

Those commands can be used with a hotkeys for muting or unmuting both ALSA and PulseAudio:

Toggle all sinks & alsa output

pactl set-sink-mute alsa_output.dmix toggle & amixer set Master toggle & amixer set PCM toggle

Mute all sinks & alsa output

pactl set-sink-mute alsa_output.dmix 1 & amixer set Master mute & amixer set PCM mute

Unmute all sinks & alsa output

pactl set-sink-mute alsa_output.dmix 0 & amixer set Master unmute & amixer set PCM unmute

When pulseaudio-alsa is installed it makes that all applications forced to use it and sound volume can be managed both from alsamixer and pulseaudio sound mixer but they are not becoming direct connected.

A comparison example of a sound channels scheme for a better understanding

Master+PCM = 2 channels ALSA, mute/unmute per channel where only one is a global(Master) mute and only for the ALSA sound driver.
Master+Sink_name = 1 channel ALSA mute/unmute and 1 channel PulseAudio mute/unmute where are two global(Master) mutes.
Note: The combined sink name can be used instead of the alsa_output.dmix sink name for an output. e.g. a command pactl set-sink-mute combined toggle instead of pactl set-sink-mute alsa_output.dmix toggle or any other that you set for pulseaudio in the file to use.

Positive and negative with pulseaudio-alsa package

  • Positive is a more fine sound adjustment ability if all sound "Master" channels are using a same output. The pulseaudio-alsa driver connecting both drivers and makes them co-work together, simultaneously. KDE looks like Windows with a nice looking sound mixer for management of sound channels for each application if the kdeplasma-applets-veromix-gitAUR widget is installed, you may also have two mixers there, one for ALSA and one for PulseAudio.
  • Negative that can makes problem is a muting comfort, because is might be necessary to use more than one sound mixer for same and simultaneous output, if one is muted then sound disappear in other too and need to unmute muted and/or change the sound volume. Only one bar for output(Master) and one for input(Mic), no PCM is show in alsamixer except if you will run alsamixer -c 0. In KDE you might have two widgets with same icons that is irritated when they look similar but managing different sound servers.

Errors and fixes

The pavucontrol can also be used to set fall-back devices and manage many other options but it doesn't save most of settings.

No sound, cracking or broken in flash or others

Warning: Do not edit and unless you still have a problem with a sound or want change the default sink outputs/inputs for pulseaudio try first to test by changing settings with the pavucontrol sound mix. Chose which devices to set as fall-back and which to use, e.g. alsa mono output sink instead of stereo.
  • If you edited daemon.conf as it describes in from the above and still have a problem with the sound after restarting pulseaudio then try to stop pulseaudio -k pulseaduio, logout of a desktop environment and login again or reboot.
  • Try to use combined in sink_name that allows simultaneous output to all supported output sinks, you can see all of them in the Description line of pactl list sinks output command for it. When all go through same output channels it might minimize conflicts. [1].
  • Configure sinks correctly and you may need to set default sinks with {{Pkg|pavucontrol} sound mixer if pulseaudio volume sound meter is working and showing that sound bar moving when it plays through it.
  • The tsched= option is a boolean and cannot be used with oss modules. It can prevent some of sound glitches if set to 0.
  • The pax11publish -e command also cause that daemon disallow applications to use it or however sound played through PulseAudio disabled but audio in flash player works good. Use pax11publish -r and restart pulseaudio.
  • The /usr/bin/skype is a script and the Skype installer is recommending to use PULSE_LATENCY_MSEC=60 variable if sound is distorted. There are few ways to use environment variables.
Temporary if starting from same terminal or added in start up script (/etc/bash.bashrc, ~/.bash_profile or ~/.bashrc) to reload data from the script you can use a bash command like e.g. source /etc/bash.bashrc
Use in /usr/bin/skype script
exec PULSE_LATENCY_MSEC=60 skype

Daemon cannot start

Section moved to Pulseaudio#Daemon startup failed

Install to fix

The skype program is a 32 bit application and you will need to install necessary 32 bit compnets for it.

In the /etc/pacman.conf uncomment

Include = /etc/pacman.d/mirrorlist

And install lib32-libpulse and lib32-alsa-plugins to make it work properly with ALSA.

pulseaudio-alsa & alsa-plugins

Flash player crashes, hack on same spot or crashes web-browser when you start pulseaudio before you start it. If flash video/audio starts before pulseaudio then only flash audio is working.

Note: The flash player has the equal sound problems if the snd_pcm_dmix_open module is loaded. List loaded sound modules you can with lsmod | grep ^snd .


If it takes long time for applications connect to the daemon after it goes idle. And make exit-idle-time = -1 option in the daemon.conf work properly.

If audio from HTML5 works perfect when playing simultaneous with pulseaudio but not flash.

Note: To make alsa-oss work you need to load snd_pcm_oss. You can do it temporary with modprobe snd_pcm_oss or save settings into the file:
install snd_pcm_oss modprobe -i snd_pcm_oss

If neither of them are working then you can create and run modprobe as servcie to load snd_pcm_oss module [2].

phonon qt back end

It is recommended to use phonon gstreamer backend to minimize sound problems with Skype specially if you are using KDE.

v4l-utils and lib32-v4l-utils

If error like this accruing then reinstall sudo pacman -S v4l-utils lib32-v4l-utils

ERROR: object '/usr/lib32/libv4l/' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
Note: This can also be caused if you are using exec nice --adjustment=-10 "$LIBDIR/skype/skype" "$@" within /usr/bin/skype script to start skype.

CPU almost to 100% on start up

If Skype using CPU only for a short time on start up then you can reduce its CPU priority.

You can use unsafe way by using sudo or configure /etc/sudoers to make it permanently.

sudo nice --adjustment=-20 runuser username skype  

You can slightly reduce it with the nice or renicecommands.

nice --adjustment=-10 skype
skype & renice -n -10 -p $(pidof skype)

To prevent sound glitch that happen after a few sec after Skype stared with low priority you need to comment out load-module module-suspend-on-idle in the /etc/pulse/ that will disable unload of loaded modules, see also in the file. Or use this in the Skype script to run it.

pacmd "unload-module module-suspend-on-idle"
exec "$LIBDIR/skype/skype" "$@"
pacmd "load-module module-suspend-on-idle"
Note: The lowest value with no need of root rights is -10.

But you can also add user name or group name to limits.conf file. It cannot be specified for a single application but only for all applications running by user or group. It will not use to much CPU but still will be a little distorted. Set a soft higher priority to all applications and run skype with nice --adjustment=-10 skype or make an alias.

 username             soft    priority       -20
 @groupname           soft    priority       -20

See also

pax11publish that manages daemon and some of its start up problems - man page.
dmix and dsnoop - sinks devices for sound-cards which don't support hardware mixing.