banner
Previous Page
PCLinuxOS Magazine
PCLinuxOS
Article List
Disclaimer
Next Page

Solving Audio Problems With YouTube Videos On PCLinuxOS


by Alessandro Ebersol (Agent Smith)

One of the most annoying things about Linux is having to deal with audio. Yes, despite PulseAudio, which brings more problems and headaches than it is worth, often we install our favorite Linux, PCLinuxOS, on computers with HDMI output and there goes the sound down the drain.

Something does not work, the sound does not come out the browser, or YouTube videos are muted. Then we proceed to use Pulse Audio, and apparently the problems end.

But maybe not, since PA also inserts some problems at the other end. Notably, emulators and other programs that do not work with PA, or Windows programs via Wine are left with horrible sound.



We end up with two choices: Either use PA and have sound in all applications (and horrible sound in Wine and other programs), or we don't use PA, and have good sound in all programs, but muted in some applications (You Tube, for example).

It was a matter of choice, but without being able to have it both ways: Whether one was happy or ate the cake, but to be happy and eat the cake was impossible ...

Until now ...

Yes, you can enable audio in PCLinuxOS, even with HDMI output, so that only the computer's sound card is used, and the sound will not be muted in the browser or other programs, without resorting to PA.

But how? First, let's see how the audio works, and why you don't get audio on "speakers" when there are HDMI devices connected (or built into the chipset).


HDMI: A second sound source

Yes, the HDMI audio output is a second sound source. When the sound is configured, during installation of PCLinuxOS, usually the HDMI output is automatically selected as the default output.

That would be great if it were not tragic. It turns out that this would only make sense if we all had monitors with audio output. Because this feature is common only in TV's, desktop computers setting the standard output to HDMI adapter is useless, causes great frustration, and makes the user to resort to PulseAudio.

But, you can change the default ALSA setting, to point to the computer audio output and forget the HDMI output.

Not very obvious, but not too difficult either.


Asoundrc - The extra sound configuration file.

As listed here, asoundrc is a configuration file which is usually located in the $HOME/.asoundrc directory. For each of the computer users, there is a file asoundrc. This file allows greater control over the sound output, sampling rates and redirecting standard output.

This is the file we will need to modify to change the default ALSA output.

What happens is that during the configuration when the system is installed, the first sound card is identified as the standard output. Often, it is the HDMI sound card.


Changing the Audio Standard Configuration

Now that we know why things are as they are, we will learn how to change this setting that we do not want.

How to do that? Follow the steps below:

1. Identify the sound cards recognized in the system. I'll give the example of the configuration that I work on an HP machine with Intel chipset (sound, graphics and HDMI output).

Open a terminal and type: cat /proc/asound/cards

My result was:

0 [HDMI ]: HDA-Intel - HDA Intel HDMI
HDA Intel HDMI at 0xf7c34000 irq 45
1 [PCH ]: HDA-Intel - HDA Intel PCH
HDA Intel PCH at 0xf7c30000 irq 46

Two sound cards are recognized. Card “0” is the HDMI output, and card “1” is the regular computer sound card output.

2. Now we have to see how the sound system is configured in .asoundrc file.

Do so in a terminal instance - type cat .asoundrc

My result was:

# playback PCM device: using loopback subdevice 0,0
pcm.amix {
type dmix
ipc_key 219345
slave.pcm "hw:Loopback,2,0"
}

# capture PCM device: using loopback subdevice 0,1
pcm.asnoop {
type dsnoop
ipc_key 219346
slave.pcm "hw:Loopback,0,1"
}

# duplex device combining our PCM devices defined above
pcm.aduplex {
type asym
playback.pcm "amix"
capture.pcm "asnoop"
}

# ------------------------------------------------------
# for jack alsa_in and alsa_out: looped-back signal at other ends
pcm.ploop {
type plug
slave.pcm "hw:Loopback,1,1"
}

pcm.cloop {
type dsnoop
ipc_key 219348
slave.pcm "hw:Loopback,1,0"
}

# ------------------------------------------------------
# default device

pcm.!default {
type plug
slave.pcm "aduplex"
}

Now, we see that the sound output is set to the HDMI output, in the #default device section.

3. Now, with a text editor, open your .asoundrc file and look for the #default device section. Change what is in the file for the following:

# default device

pcm.!default {
type hw
card 1
}

We changed the default audio output, HDMI (card 0) to the computer sound output (card 1).

Now, end your session, logout and login again, and the sound of Firefox browser, Google Chrome and so many other programs will go through the computer's speakers, not the HDMI interface, and there will be no more silence. Ehehehehehe.

Well, some details should be noted:

  • First of all, watch which is your sound configuration in cat /proc/asound/cards. For this example I wrote here was for an Intel chipset video and audio. There is a need to study each case, as there may be a very different combination of hardware (Nvidia video cards, external sound cards or USB microphones, and etc ...). But the instructions are the same, and you only need to adapt to each case.

  • Always make a backup of your file .asoundrc before changing it. If there is any problem, it may be reversed easily by restoring the backup.

Finally, disable PulseAudio, which is a dead weight, eating computer processing, when it is so simple to make the change.

Ok?

Further reading:

http://dallarosa.tumblr.com/post/19626256742/fixing-no-sound-in-browser-problem-on-linux
http://www.alsa-project.org/main/index.php/Asoundrc

Update: Our dear “friends” at Google changed the YouTube API, to force HTML5 videos in YouTube. Well, HDMI audio doesn't work well with Firefox; the videos are muted, but it works great in Chrome. Hmmm, that reminds me of MS and its old tricks. To have sound enabled with YouTube playing in Firefox, you have to do one thing now: install an addon in Firefox, called YouTube Flash Player for Firefox, version 1.4.0.

Ok? Install it and you'll have sound again in Firefox YouTube videos, with HDMI capable machines.



Previous Page              Top              Next Page