This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Audio in KDE4 - Someone Should be Ashamed

Tags: None
(comma "," separated)
Twenynge
Registered Member
Posts
8
Karma
0
OS
The current state of audio in KDE is atrocious. I'm running Gentoo, and I installed KDE a few days ago (kde-base:meta, kde-admin:meta, kde-multimedia:meta) with the hopes that I'd be able to replace my vanilla Ubuntu 9.10 (Gnome) with the slick new KDE4. It's becoming clear to me that, even though the KDE version I'm running is 4.3.4 (not a beta or .0 release, mind you) this desktop environment is clearly not ready for prime time.

My first action after installing the above packages was to start tinkering with the system settings. I use Skype quite a bit, so the first place I went was "Multimedia". I've got a USB headset, so I went ahead and moved it to the preferred device for all audio. System sounds came through my headset, so it must have worked, right? Dead wrong.

I tried to watch a few flash videos on Youtube, and much to my chagrin, audio played out of my speakers and not the headset. Fast forward 48 hours and, after I had finally created an /etc/asound.conf file to set my defaults, success! After spending the afternoon cursing Adobe for releasing such a buggy flash player (ironic), I decided to celebrate by playing an .mp3...

...and borked. Both Dragon Player and JuK seem to REALLY like my speakers and loathe my headset. They don't seem to give a rat's **** that my USB Headset is defined as my default sound card in my asound.conf file, nor that the Multimedia settings in KDE have all been switched so that the headset is preferred. I decided to go back into my multimedia settings and bumped my preferred device to the newly generated "default". Once again, success! Audio was no longer coming from my speakers...

...it wasn't coming out of anything at all. On top of that, I got a few (potentially unrelated) JuK crashes. Both Dragon Player and JuK refuse to even play .mp3 files. I checked out my ~ directory for any KDE4 config files that may correct the issue to no avail. I changed my backend from Xine to GStreamer, but that did nothing (obviously). The only think I can think to do at this point is install PulseAudio and effectively break Skype. Unfortunately, that was the whole reason I left Gnome in the first place.

I guess I was crazy to think that KDE applications such as JuK and Dragon Player should have no problems with KDE's own multimedia configuration tool. If the System Settings -> Multimedia settings only affect system sounds, why bother with giving the user an option to select preferred devices for music, videos, etc.? Why am I dealing with this in a X.3.4 release?

Okay, I feel better. Having got that out of my system, I am fully prepared to be informed by some insightful poster that I am the problem, not KDE. It may even be an issue with Gentoo's packages for all I know, but my money is on either my own idiocy or KDE's half baked release.

Has anybody else experienced this and is there a solution? Please tell I'm just an idiot. I'm intrigued by KDE's inherent sexiness and would love to continue to use it.

P.S. I don't have Amarok installed as I don't know what it is. If installing it will fix the problems I'm having, I'll download it in a heartbeat.

Edit: As it turns out, if I download an .mp3 to my home directory and play it, my headset works fine. If I try to play an .mp3 without downloading, I get a Phoron message telling me my USB headset doesn't work. Clicking on the file again in JuK will play it from my speakers. Could I have a file permissions issue?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
The Multimedia control panel in System Settings only controls Phonon applications by default. In current trunk, if built with Pulseaudio and it is available, it will send this information to Pulseaudio as well.

The default specified in asound.conf is overridden by the Multimedia panel for Phonon apps.

I would recommend removing ~/.config/kde.org/libphonon.conf outside of KDE.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
Twenynge
Registered Member
Posts
8
Karma
0
OS
I think I figured out what was going on. The website I was trying to play the .mp3 off of also had an embedded flash movie that had control of ALSA. Even though the movie was paused, I think it still had my sound card locked up, so when JuK/Dragon Player attempted to play the .mp3 the sound card appeared as if it wasn't available. Phonon then directed the sound to the next available device causing the audio to be played from the device with a lower priority.

The problem is obviously not with KDE, although advertising that the multimedia settings ONLY applied to KDE and KDE apps would have cut down on the frustration. That being said, has anyone figured out a way to have both phonon and non-phonon apps to access the same device at the same time? Dmix settings in asound.conf, perhaps?
User avatar
annew
Manager
Posts
1155
Karma
11
OS
Twenynge wrote: That being said, has anyone figured out a way to have both phonon and non-phonon apps to access the same device at the same time? Dmix settings in asound.conf, perhaps?


Oddly enough, that's what the much-maligned PulseAudio is attempting to address - and does so successfully on some systems, though not all, as yet.


annew, proud to be a member of KDE forums since 2008-Oct and a KDE user since 2002.
Join us on http://userbase.kde.org
User avatar
dpalacio
Registered Member
Posts
240
Karma
2
OS
annew wrote:
Twenynge wrote: That being said, has anyone figured out a way to have both phonon and non-phonon apps to access the same device at the same time? Dmix settings in asound.conf, perhaps?


Oddly enough, that's what the much-maligned PulseAudio is attempting to address - and does so successfully on some systems, though not all, as yet.

Could not Phonon do that as well? Setting the default Alsa output on the current user.


connect(post, SIGNAL(readSignature()), qapp, SLOT(quit()));
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
I would recommend checking that DMix is setup correctly on your audio devices, as this shouldn't happen.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
Twenynge
Registered Member
Posts
8
Karma
0
OS
From the ALSA wiki:
NOTE: For ALSA 1.0.9rc2 and higher you don't need to setup dmix. Dmix is enabled as default for soundcards which don't support hw mixing.


I am currently running ALSA 1.0.20, so I assumed setting up Dmix was unnecessary, but apparently that isn't the case so I changed my /etc/asound.conf file to:
Code: Select all
pcm.!default {
 type plug
 slave.pcm "dmixer"
 }
 pcm.dsp0 {
 type plug
 slave.pcm "dmixer"
 }
 pcm.dmixer {
 type dmix
 ipc_key 1024
 slave {
 pcm "hw:1,0"
 period_time 0
 period_size 1024
 buffer_size 8192
 rate 44100 #many new cards are 48000 only
 }
 bindings {
 0 0
 1 1
 }
 hint {
 show on
 description "USB Headset (Dmix)"
 }
 }
 ctl.dmixer {
 type hw
 card 1
 }


Card 1 is my usb headset. I can now successfully play .mp3 files from sites that have embedded flash videos. Unfortunately, with the above config file, when I unplug my usb headset flash (video and audio) break. Phonon is correctly routing sound to my sound card but non-Phonon applications do not.

The asound.conf file I used is a cut and paste job so I do not understand much of what is in it. Is there any way I can edit the file so that, when my usb headset is unplugged alsa applications do not freak out and stop working?

Edit: I just checked on my Ubuntu 9.10 partition (with pulseaudio removed) and it has no problems playing an .mp3 from a site with embeded flash videos. There are no /etc/asound.conf or /home/.asoundrc files to speak of which tells me that Dmix shouldn't need to be set up at all, as was indicated on the ALSA wiki (see quote above).

Phonon breaks Dmix. The problem IS with KDE. Can it be unbroken? Can I scrap Phonon and still use KDE?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Phonon is the KDE Multimedia framework. All KDE applications use it to play audio.
Unfortunately, my searching has not revealed a way for ALSA to "fallback" automatically in a way that both Phonon and Pulseaudio are able to.

The reason why you needed to configure DMix manually is because you overrode the pcm.default device in /etc/asound.conf.

One thing you could try, is blank asound.conf except for the following entry:
Code: Select all
defaults.pcm.card 1


I do not know if ALSA will fallback however.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
Twenynge
Registered Member
Posts
8
Karma
0
OS
Code: Select all
defaults.pcm.card 1


That is essentially what I had prior to changing it to what is shown in my post above. Dmix seems to work fine with your suggested asound.conf when two "alsa sources" are accessing my card, but not when one "alsa source" (flash player) and one "Phonon source" (JuK) attempt to access simultaneously.

Phonon is the KDE Multimedia framework. All KDE applications use it to play audio.
Unfortunately, my searching has not revealed a way for ALSA to "fallback" automatically in a way that both Phonon and Pulseaudio are able to.

The reason why you needed to configure DMix manually is because you overrode the pcm.default device in /etc/asound.conf.


Got it. Not being anything even close to a developer, is there any chance we'll see a Phonon release that can utilize dmix without having to create an asound.conf file?

I must admit, I'm quite confused by the whole sound situation that has developed with Linux. I suppose that there are some technical limitations or reasons why alsa hasn't been developed to provide the functionality that packages like Phonon and Pulseaudio provide, but the entire state of audio in Linux seems a bit of a mess to the uninitiated layperson, i.e. me. With respect to Pulseaudio, I don't *need* a sound server, nor do I need the latency that comes with it. What I do need is an audio mixer that just works, and works all the time.

As an aside, I've noticed that the kmix volume slider can control the volume of my sound card, but not my USB headset. Is this normal?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
For KMix, you should see two tabs, just underneath its menu bar that allow you to switch between the two cards.

Phonon shouldn't require anything special with regards to DMix configuration. I don't have a asound.conf file and it works fine with multiple apps accessing it.

When you tested the two ALSA sources, which ones did you use? Flash player doesn't play well with anything ( it actually uses OSS, the only reason it works is because ALSA has a OSS emulation layer.

You may also wish to check http://www.gentoo-wiki.info/ALSA/Softwa ... ype_.26_Co


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
Twenynge
Registered Member
Posts
8
Karma
0
OS
For KMix, you should see two tabs, just underneath its menu bar that allow you to switch between the two cards.


The USB headset tab works just fine, however the master volume slider in the system tray doesn't control the volume of my headset. Whether or not that is normal behavior is what I was wondering.

Phonon shouldn't require anything special with regards to DMix configuration. I don't have a asound.conf file and it works fine with multiple apps accessing it.


But it does. I just responded to a post on the Gentoo forums from someone who has the very same problem I do. Additionally, you can do a Google search for the terms "phonon" and "dmix" and get plenty of hits for this very issue. In fact, I even believe I found a bug on the KDE bug tracking website for a very similar issue. Unfortunately, I think that the ultimate determination on the bug was that it was "operator error" and not a KDE issue, but I don't recall.

When you tested the two ALSA sources, which ones did you use?


I went to the site http://www.geico.com/about/commercials/music/ringtones/. There is an embedded flash video that starts when you open the page. After the video completed, I attempted to click on the boss's ringtone preview and open with JuK. Phonon informed me that my USB headset was unavailable (or something to that effect) and proceeded to play the audio through my speakers. I then moved over to my Ubuntu 9.10 partition with Pulseaudio removed and no asound.conf or .asoundrc, repeated the same steps, and had no issue at all playing both sounds from my headset. You can try it on your setup, if you like.

Flash player doesn't play well with anything ( it actually uses OSS, the only reason it works is because ALSA has a OSS emulation layer.


I read that Flash uses OSS, so as an experiment I recompiled my kernel so that ALSA did not support OSS or OSS emulation and verified that the module "snd-pcm-oss" was not loaded by the kernel or by alsa. I played the Flash video in question with no issues. Is it possible that newer versions of Flash no longer use OSS emulation?

You may also wish to check http://www.gentoo-wiki.info/ALSA/Softwa ... ype_.26_Co


The link in question references Firefox and aRts, however I have the issue with Konqueror and have specifically disabled aRts support when compiling all of my packages.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
The Master volume slider does not change automatically between cards.
You can change it by right clicking on KMix's tray icon and selecting "Select Master Channel".

I just tested it now, and both Dragon Player and Amarok in addition to Flash at the site you mentioned functioned perfectly fine together, all playing simultaneously. I only have a single sound card though.

It is quite possible that newer versions of Flash do not use OSS anymore.

It is possible that distributions have patched underlying subsystems to prevent any locking of sound devices what so ever and enforce use of DMix ( which would explain why it works in Ubuntu and openSUSE without a asound.conf ).


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
deadeyes
Registered Member
Posts
34
Karma
0
I had the exact same issue.

I fixed it by creating a file called .asoundrc in my home dir.
I put the following in it:
Code: Select all
pcm.!default front:Headset


"Headset" is the part retrieved from
Code: Select all
cat /proc/asound/cards


However when the headset is not connected I something get problems not hearing anything in my headphones (dont know if it is the same for the build in speakers of my laptop but I think it is).

It still tries to use that headset then, but it does not work.
THen other times I get audio by using dragon player, not by using vlc or smplayer.

Anyone has a good fix for this?


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], lockheed