[KDE] HDMI sound goes through regular sound card

Everything about X, Gnome, KDE, ... and everything running on it

[KDE] HDMI sound goes through regular sound card

Postby tomek-k » 2016-08-13 23:30

Hi all,

I have a strange problem. I've connected a TV to my graphics card using the HDMI port and then I wanted to watch some video using a web browser (HTML5, not flash) on that TV with the sound going through the TV speakers, but when playing the video, the sound was played back on the speakers connected to my sound card. So I opened the KDE SystemSettings, went to the Multimedia section (Phonon - Audio and Video) and moved the device that corresponds to the graphics card's audio device right to the very top of the devices list. Clicked 'Apply', went back to the web browser, clicked 'Play' again, and… no change – the sound is still being played back through the regular sound card… So, went back to the SystemSettings, and tested the aforementioned device with the "play" button visible below the list – the test sound plays through the sound card speakers… Then I started testing every single device listed, but the sound was being played back either from the sound card speakers or not at all.

So I searched the Web and found a suggestion to do:
Code: Select all
aplay -l

in order to find out the device name of my graphics card's audio device, which turned out to be:
Code: Select all
card 1: HDMI [HDA ATI HDMI], device 3: HDMI 0 [HDMI 0]

which means Card 1, Device 3.
A quick look at the list of audio devices in SystemSettings, and the tooltip displayed above the device I moved to the top says
Code: Select all
alsa: dmix:CARD=HDMI,DEV=3

Everything's correct here.
Let's do the following, then:
Code: Select all
aplay -D plughw:1,3 /usr/share/sounds/alsa/Front_Right.wav

And… a miracle! The sound can be heard on the TV! Let's try with VLC this time – I've opened a video file using VLC, gone to menu Sound -> Audio devices and selected "HDA ATI HDMI, HDMI 0 Direct sample mixing device" and again sound is being played back on the TV!

So the problem here seems to be that when the sound is being played back through KDE (or more specifically – phonon?), then the output audio device setting is ignored and it is being directed to the default audio device. When trying to play the sound through an application that lets you select the audio device directly, then everything works correctly.

I've searched the Web to find a solution, and even found that some people experienced similar problems, but no solution whatsoever.

I'm aware that this is most probably a bug in KDE/phonon, but still I'm asking here, on the Debian forum, for a reason – I also have another system running Kubuntu, and there the problem doesn't occur. This means that this problem is distro-specific. Perhaps in Kubuntu the problem doesn't occur because there, in KDE's SystemSettings->Multimedia section, there is a third tab (next to "Device preference" and "Backend") called "Audio Hardware Setup", where I can explicitly select the output audio device for KDE/phonon (rather than a "preferred device" for a selected playback category, like "Music", "Video", "Notifications", etc.). Here, in Debian's KDE installation, this one is missing (and I don't remember it ever being here in Debian).

So here come the questions I'm seeking answers for:
1. Why the problem is occurring at all? (seriously, I'm really curious)
2. How to solve it? (answers like "use another software/hardware/distro/whatever" are extremely unwelcome! If there is no solution for KDE and/or Debian, then don't be afraid to admit it)
3. Why in Debian the "Audio Hardware Setup" tab in SystemSettings is missing and what to do to have it there? Is it something Ubuntu-specific? Or maybe I'm missing something in my Debian installation? Or is it because currently in Debian testing the KDE desktop is a mix of KDE4 and KDE5?

I'm using the latest Debian testing/stretch, my graphics card is AMD and I'm using the radeon driver:
Code: Select all
Linux localhost 4.6.0-1-amd64 #1 SMP Debian 4.6.4-1 (2016-07-18) x86_64 GNU/Linux
phonon: 4:4.9.0-4
xserver-xorg-video-radeon: 1:7.7.0-1

As far as I can tell, pulseaudio is not installed.
tomek-k
 
Posts: 36
Joined: 2007-10-14 16:28

Re: [KDE] HDMI sound goes through regular sound card

Postby pendrachken » 2016-08-14 00:06

Did you restart the browser after changing the audio out device? As far as I know, many times the browser checks for default devices at startup and just continues to output to that device.

Also, I haven't used KDE in a while, but sometimes you had to log out ( note this is just log out to the greeter / CLI, NOT have to restart the computer ) to get phonon to switch default audio cards in the earlier 4.x releases. Maybe that has changed, maybe not, it would be worth a try.


Also, remember I haven't used KDE in quite some time, but did you move the HDMI audio card to the top of the list AND make it the default output? I vaguely remember KDE having sound card order AND default cards.
fortune -o
Your love life will be... interesting.
:twisted: How did it know?

The U.S. uses the metric system too, we have tenths, hundredths and thousandths of inches :-P
pendrachken
 
Posts: 1291
Joined: 2007-03-04 21:10
Location: U.S.A. - WI.

Re: [KDE] HDMI sound goes through regular sound card

Postby tomek-k » 2016-08-14 11:44

pendrachken wrote:Did you restart the browser after changing the audio out device? As far as I know, many times the browser checks for default devices at startup and just continues to output to that device.

Didn't help.

pendrachken wrote:Also, I haven't used KDE in a while, but sometimes you had to log out ( note this is just log out to the greeter / CLI, NOT have to restart the computer ) to get phonon to switch default audio cards in the earlier 4.x releases. Maybe that has changed, maybe not, it would be worth a try.

Didn't help.

pendrachken wrote:Also, remember I haven't used KDE in quite some time, but did you move the HDMI audio card to the top of the list AND make it the default output? I vaguely remember KDE having sound card order AND default cards.

How can I make it to be the default output? Don't see such option in the SystemSeettings. Does it have something to do with the order of sound devices in the system? In /lib/modprobe.d/aliases.conf file I have the order explicitly set this way:
Code: Select all
options snd_ctxfi index=0
options snd_hda_intel index=1
options cx88_alsa index=2

where snd_hda_intel is the sound device on the AMD card (yeah, looks funny – Intel sound device on an AMD gfx card). Now, removing this explicitly enforced ordering is not an option for me – before I added the above options to aliases.conf, the kernel was discovering the sound devices in a random order. This caused the primary (default) audio device to also be random, which was not only annoying (KDE asking me about "removed" sound devices at every second boot), but also was making me reconfigure phonon all the time, so that I could hear sound at all.

But wait... let me think again... Back then, when I was fighting with the sound device ordering, I remember that the hda_intel device never produced any sound output when using the "Test" button in SystemSettings. Regardless whether it was detected as the first, second or third sound device by the kernel... So this would mean that something must have been changed in phonon since then – phonon used to direct the sound to the selected device back then; now it seems to ignore this selection and just directs the sound always to the primary (default) sound device? That could be an answer to my first question ("why?"). If it's true, then what's the purpose of having the "Device preference" list in SystemSettings at all?

Too many questions, too little answers.

And, as a hint, I can add that I'm using vlc as the phonon backend; xine never worked for me, gstreamer produced ugly sound (sounded like way too much bass; it was hurting my speakers). But on the other hand, as already pointed out in the first post, when running the VLC Player itself, there is no problem with switching sound output devices, even during playback, so VLC is not the problem here.
tomek-k
 
Posts: 36
Joined: 2007-10-14 16:28

Re: [KDE] HDMI sound goes through regular sound card

Postby pendrachken » 2016-08-14 19:21

Well, lets try to narrow it down further then. And one more question, just to get it out of the way and make sure there are no "omfg, how could I forget that" ( I've had a few of these myself :oops: ) moments.... after setting the HDMI card as the highest IN ALL AREAS OF PHONON did you remember to hit apply?


If VLC works with the audio out set to the HDMI audio, what happens when you set the HDMI audio as the default in phonon and then set VLC to use the default audio device?



The other thing to look for is if the web browser is actually using the default audio out from phonon, or if it always using the onboard audio card. Look up how to find out what audio output is being used for your particular browser.
fortune -o
Your love life will be... interesting.
:twisted: How did it know?

The U.S. uses the metric system too, we have tenths, hundredths and thousandths of inches :-P
pendrachken
 
Posts: 1291
Joined: 2007-03-04 21:10
Location: U.S.A. - WI.

Re: [KDE] HDMI sound goes through regular sound card

Postby tomek-k » 2016-08-14 20:55

pendrachken wrote:[...] after setting the HDMI card as the highest IN ALL AREAS OF PHONON did you remember to hit apply?

Yep – when I reopen the SystemSettings, everything is in the order I left it.

pendrachken wrote:If VLC works with the audio out set to the HDMI audio, what happens when you set the HDMI audio as the default in phonon and then set VLC to use the default audio device?

Still not sure how you want me to change the default audio device in phonon. Should I reorder the devices in ALSA? Or is there a more civilised way?

pendrachken wrote:The other thing to look for is if the web browser is actually using the default audio out from phonon, or if it always using the onboard audio card. Look up how to find out what audio output is being used for your particular browser.

Now this is a very good point – the browser in question is Firefox, and after searching the Web it seems that Firefox is not using phonon, but just uses the ALSA's default audio device for its sound output. But this is still a guess as I haven't found any straightforward answer like "yes, Firefox uses phonon" or "no, Firefox does not use phonon". But when trying to select the libhonon4 and libphonon4qt5-4 packages for removal, it doesn't want to remove also firefox, so the browser doesn't depend on phonon and most probably doesn't use it.

If it doesn't use phonon, then fixing the phonon-related problem won't fix the problem in Firefox. And I cannot see any option in Firefox for selecting the audio output device.

However, there is still that "SystemSettings" -> "Multimedia" -> "Audio Hardware Setup", which is there in Kubuntu, but not in Debian. Will try to find out if it is possible to have it in Debian also. This tab has settings that do work system-wide (so if I select HDMI output there, then Firefox outputs its sound to HDMI). But this is on a laptop, which has only one sound card as seen by ALSA (with two devices: DEV=0 - the analogue audio output to speakers, and DEV=3 - the HDMI audio output). On the desktop with Debian, on the other hand, these are on two separate sound cards.

As for the sound card itself, it is not an onboard card (which I have disabled in BIOS) – it is a PCI-Express card. It used to cause problems of its own long time ago, it was shortly after Creative open-sourced the kernel driver for it (snd_ctxfi), but since the kernel team cleaned it up, it works flawlessly. But who knows – could it be that phonon has some problems with the driver (is it even possible)?

Besides all the above, I've checked once again, and now I'm sure that I have PulseAudio installed on my system (libpulse0_9.0-1.1, etc.). Don't know whether this has any meaning, though – I've never understood what PulseAudio or Phonon are responsible for and what is the relation between both.
tomek-k
 
Posts: 36
Joined: 2007-10-14 16:28

Re: [KDE] HDMI sound goes through regular sound card

Postby pendrachken » 2016-08-14 21:50

First, I would try chromium / chrome and see if it works through there, meaning it is definitely 100% a firefox problem.



https://ubuntuforums.org/showthread.php ... 22&page=19


Here is something to start your search. setting up an audio sink through asound seems to work for at the least flash content, maybe it will work for HTML5 content as well.


That and check out what pulse is actually doing on your system... I don't use it, ever (straight ALSA on my hardware and VMs), so can't really help you there.


AND PLEASE, FOR CRYING OUT LOUD read up on asound before you just start poking around, the sound system can be a huge confusing unholy mess. DOCUMENT ALL CHNGES YOU MAKE so you can either revert to a semi-working setup like you have now, or know how to setup the sound in case of a re-install once you get it working. Sound is probably one of the most pain in the butt things other than video in Linux. 99% of the time audio works fine, then the last 1% is like getting teeth pulled without anesthetics.
fortune -o
Your love life will be... interesting.
:twisted: How did it know?

The U.S. uses the metric system too, we have tenths, hundredths and thousandths of inches :-P
pendrachken
 
Posts: 1291
Joined: 2007-03-04 21:10
Location: U.S.A. - WI.

Re: [KDE] HDMI sound goes through regular sound card

Postby tomek-k » 2016-08-24 10:45

don't have a possibility at the moment to test the above suggestions, but in the mean time I've checked running a Kubuntu from a live-dvd on the desktop. There that "SystemSettings" -> "Multimedia" -> "Audio Hardware Setup" was available, so it turns out that its presence is not hardware dependent (so it is either missing from Debian altogether, or only from my set-up). However, changing any settings there doesn't help – as I thought, the HDMI sound works on a laptop+kubuntu (after selecting it in the "Audio Hardware Setup") only because it is part of the same sound device (at least as seen by the operating system) as the built-in speakers sound output. When I changed the sound output on desktop+kubuntu_dvd to be the gfx card's audio device instead of the primary sound card, the sound was still missing.

What's even worse, on this setup (desktop+kubuntu_dvd), the VLC media player didn't allow me to select the HDMI output directly – it always reverted back to the X-Fi sound card (detected as the first audio device) when I selected the HDMI output from the menu). But I guess this was caused by the phonon and/or pulseaudio configuration (don't remember at the moment, but I think that kubuntu_dvd used gstreamer phonon backend and apart from this, there were more pulseaudio packages installed than on my debian system).
tomek-k
 
Posts: 36
Joined: 2007-10-14 16:28

Re: [KDE] HDMI sound goes through regular sound card

Postby tomek-k » 2017-03-20 12:25

SOLVED!

1. Install pulseaudio and pulseaudio-utils packages
3. Go to "SystemSettings" -> "Multimedia" and notice that the list of available audio devices in the first tab is reduced to just sound cards (previously it displayed a list of available outputs from all of the sound cards)
2. If not all of your sound cards are displayed in the first tab, don't panic – that "Audio Hardware Setup" tab is now there(!!) and in that tab you can turn on the missing sound cards
3. Switch to the "Audio Hardware Setup" tab, select the other Sound Card you wan't to enable (let's call it the secondary sond card) and make sure that the Profile for this card is set to some output instead of "turned off".

After that (and perhaps a restart of the "System Settings") you will see the secondary sound card listed in the first tab of "SystemSettings" -> "Multimedia", next to the primary one.

And a little hint – while reconfiguring your soundcard order as described below, don't bother to click that Test button available in "SystemSettings" -> "Multimedia" – it doesn't seem to be working properly (the test sound isn't played back at all, or is played back from the wrong device, but the settings do work regardless of this).

Now, if you want Firefox (52 or later!) to playback the sound through the secondary sound card, then you have to obviously move the card to the top of the "preferred devices" list but not for the Video category or the Music category, but for the main Sound Playback category. Now restart Firefox and the sound from YouTube et. al should go to the secondary sound card.

For VLC you can still select the sound device directly from its menu, which I think is the most convinient way, but you can also select "Playback/recording through the PulseAudio sound server" option, which will let the PulseAudio decide. It seems that VLC also doesn't fall into the Video nor Music categories in "SystemSettings" -> "Multimedia" and, as in case of Firefox, you need to modify the sound card preference in the main Sound Playback category for VLC to be affected. No VLC restart is required.

I've also tried messing with Amarok, and here a surprise – it is categorised in KDE as a Video playback software, so you need to modify the sound card preference in the Video category. Also, no Amarok restart is required.


And one more thing. As you may have noticed, I've emphasised that Firefox needs to be in version 52 or later. This is because since this version Firefox uses PulseAudio. And this is how I found the solution to my problem described in the thread. Firefox upgrade forced me to properly install PulseAudio and then I thought I'll retry with the HDMI output thing, which turned out to be working fine now.
tomek-k
 
Posts: 36
Joined: 2007-10-14 16:28


Return to Desktop & Multimedia

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable