News for hackers. Stuff that matters.
Re:PulseAudio under the hood by bandrami on Friday September 22, 2017 @09:54AM (#15312151)
Sigh.

Once upon a time, sound cards were files in the /dev tree. To play sound, you wrote pcm data to the file representing a sink. To record, you read pcm data from a file representing a source. Things were better then. I'm sure there are people with use cases that have required the four (and counting!) solutions crufted on since then, but I've never been one of them, and it irks me that the interfaces get more and more complex and brittle with each iteration.

Re:PulseAudio under the hood by ashark on Friday September 22, 2017 @10:09AM (#15312275)
I was entirely happy with alsa and still don't know of any use-case I have that's better served by the more fragile, more resource-hungry PulseAudio. I assume it's useful to someone.
Re:PulseAudio under the hood by lathiat on Friday September 22, 2017 @10:19AM (#15312370)
Spoken confidently like someone that never tried to play sound in two applications at once.
Re:PulseAudio under the hood by simias on Friday September 22, 2017 @10:48AM (#15312650)
I keep seeing this argument in this thread and quite frankly I'm dumbfounded. Last time I've had this issue was more than a decade ago on FreeBSD and it was solved by tweaking my OSS config to enable multiple channels. I've never, ever had this issue with Alsa. And I'm not a fan of Alsa either, PA just managed to be even more opaque and less reliable in my experience.

Now, it's just anecdotic evidence of course but basic audio mixing is not exactly rocket science, you shouldn't need something as convoluted as PulseAudio to get it right. I mean, what the hell: https://gavv.github.io/blog/pulseaudio-under-the-hood/diagra...

Some power users might need these additional features, I don't. I wouldn't mind having all of that if the basics just worked reliably but they don't.

These days disabling PA is my go-to first step while troubleshooting audio issues on linux and more often than not I don't have to go to step #2.

Re:PulseAudio under the hood by loeg on Friday September 22, 2017 @12:03PM (#15313349)
FreeBSD's OSS is not ALSA.

ALSA refused to do mixing in software for some time. Maybe it still doesn't do it, I don't know. So if you had a hardware sound card that would do mixing, you could play multiple channels with ALSA, but if you didn't, you were SOL.

Re:PulseAudio under the hood by digi_owl on Friday September 22, 2017 @01:22PM (#15314032)
Alsa has had dmix for quite some time. The thing was that until something like a decade ago it had to be manually enabled via a .asoundrc edit. These days Alsa will enable it automatically on any device known to not have a hardware mixer.
Re:PulseAudio under the hood by loeg on Friday September 22, 2017 @03:58PM (#15315268)
Maybe so, but I did try to fix it without resorting to a hardware sound card and couldn't at the time. IIRC the syntax of the ALSA configuration files was particularly arcane.

Not sure why that deserves downvoting.

Re:PulseAudio under the hood by LukeShu on Friday September 22, 2017 @12:39PM (#15313695)
Also spoken confidently like someone that never tried to play sound in two applications at once.

This has worked well in ALSA for years now. Now, ALSA won't let you set the volume of each application separately, but most applications have their own volume control for that anyway.

And you'll never have to deal with the application's volume Pulse's volume for that source disagreeing, and scratching your head as to why even though you set the volume to max, it isn't getting very loud. To be fair, maybe this has been entirely solved; the last time I used Pulse was ~5 years ago[0], so I might be a bit out of date. But not more out-of-date than the claim that ALSA can't play sound in two applications at once!

[0]: I don't have anything against Pulse, I just don't see the point in installing it. What does adding it to my stack get me?

Re:PulseAudio under the hood by digi_owl on Friday September 22, 2017 @01:24PM (#15314047)
Another "lovely" thing about PA is that will allow the loudest of the "apps" (groan) to ramp up the master control (do not recall the "feature" name right now).

Do wonder how much future hearing loss it has created by sudden spikes in volume...

Re:PulseAudio under the hood by Symen on Saturday September 23, 2017 @03:32AM (#15318658)
You are talking about "flat-volumes", I also recommend disabling it. Even forgetting the issue you mentionned, it just makes volumes harder to handle and reason about.

I wonder if they would have ever implemented this "feature" if it wasn't the default (and only) behavior on Windows...

Re:PulseAudio under the hood by LukeShu on Friday September 22, 2017 @05:39PM (#15316095)
Oh! When all of the GUIs say sound is at max, but it's either really quiet or silent, and it turns out that it's because even though the PA volume is up, somehow ALSA (which PA ultimately uses on the backend) got muted. But this is a PA box, so you have no GUI tools to set the ALSA volume!
Re:PulseAudio under the hood by notalaser on Friday September 22, 2017 @10:34AM (#15312524)
This has worked reliably in ALSA before it has worked reliably in PulseAudio (and, in fact, way before PulseAudio received any meaningful adoption, when Fedora enrolled everyone in PA's beta testing).
Re:PulseAudio under the hood by wereHamster on Friday September 22, 2017 @10:39AM (#15312573)
Well, maybe in the later days, but there was a long time when it didn't work well at all. I remember having to mess with the ALSA configuration to make it work. And then you also had apps which only supported OSS and getting them to work together with ALSA was an additional pain.
Re:PulseAudio under the hood by digi_owl on Friday September 22, 2017 @11:31AM (#15313057)
The reason for that was that while dmix was available for a long time, it was not enabled automatically on hardware without hardware mixing. More recent versions will silently (heh) enable it on hardware thats known to not have hardware mixing.
Re:PulseAudio under the hood by notalaser on Friday September 22, 2017 @12:45PM (#15313743)
What later days? Software mixing worked fine in ALSA in 2004-2005, and OSS emulation had been working reliably way before that. The first PulseAudio release was in 2004, and it wasn't adopted by Fedora until way, way later.
Re:PulseAudio under the hood by fiddlerwoaroof on Friday September 22, 2017 @10:29AM (#15312480)
dmix works just fine for "normal users" and has since the first time I used it (sometime in 2005 or so)
Re:PulseAudio under the hood by Aissen on Friday September 22, 2017 @10:39AM (#15312569)
How did you ensure one app wasn't much louder than the other ?
Re:PulseAudio under the hood by bandrami on Friday September 22, 2017 @11:49AM (#15313221)
I'm trying to think of a software audio source that doesn't have its own volume control and I'm failing.
Re:PulseAudio under the hood by loeg on Friday September 22, 2017 @12:06PM (#15313371)
Chrome, for example. Remember http://packet.city/ from a few days ago? All Chrome supports is mute or unmute.
Re:PulseAudio under the hood by jancsika on Friday September 22, 2017 @04:37PM (#15315579)
Hm...

* default Alsa setup: set master to level that seems comfortable-- i.e., "to taste"

vs.

* default Pulse setup: set Chrome's app level to taste

Bug: packet.city plays an annoying sound with a perceived loudness that the user did not predict.

* Alsa solution: lower the master volume to a level that doesn't result in painful output from packet.city, and adjust all other apps accordingly

vs.

* Pulse: lower Chrome app audio, but leave yourself open to similarly unpredictable painful events from other apps

It seems in this case that the limitations of Alsa actually force the user to do the safe thing wrt perceived loudness.

Re:PulseAudio under the hood by loeg on Friday September 22, 2017 @05:21PM (#15315915)
Your proposed Alsa solution: Now all other apps with reasonable dynamic range, e.g., movies, are too quiet.
Re:PulseAudio under the hood by jancsika on Friday September 22, 2017 @06:25PM (#15316446)
At the same time, all other apps are at a level that won't cause painful audio to hit your ears.

If you trust VLC and you trust the video file you're watching, then turn the master audio back up during the loud "Universal Pictures" intro or whatever is an equivalent introductory sound at the beginning of the movie you're about to watch.

On my chromebook, there are two volume buttons and one mute button that are by far the most convenient way to adjust (master) audio for such a situation. So you turn down for random browsing and turn up for watching movies or whatever.

Btw-- those are almost certainly the controls someone would use to turn down or mute the sound of that horrible website audio listed above. In such a case the fact that pulse can give you an app volume for Chrome doesn't help anything-- for example, the user who adjusted Pulse app volume down to avoid pain will need to adjust it back up when watching a movie on Youtube for the same reason you mentioned. But they can't adjust the app volume with the keyboard controls. So to make use of that feature forces a more complicated UI that takes longer to use.

Re:PulseAudio under the hood by LukeShu on Friday September 22, 2017 @05:43PM (#15316116)
Then you tell your movie player to just make it louder, discarding that beautiful dynamic range. If you're paying close enough attention to the movie to care about the loss of dynamic range, then you probably aren't doing something else that might make sound, so you won't mind turning the master volume up.
Re:PulseAudio under the hood by LukeShu on Friday September 22, 2017 @05:48PM (#15316153)
So how do you ensure that one tab wasn't much louder than the other?

In this case, it doesn't make much sense to treat the browser as a single application, but each site as one (does Chrome export each tab as a separate source to PA? IDK, I haven't checked). And, I can't think of a single thing that I actually want producing sound (and don't mind just muting) from my web browser that doesn't have its own volume control.

Re:PulseAudio under the hood by loeg on Saturday September 23, 2017 @02:29AM (#15318457)
In my use, zero or one tabs is producing sound at any one time, so the distinction doesn't really matter to me.
Re:PulseAudio under the hood by LukeShu on Saturday September 23, 2017 @05:29PM (#15321845)
And in most people's use, zero or one applications is producing sound at any one time, so the distinction doesn't really matter to them.
Re:PulseAudio under the hood by fiddlerwoaroof on Friday September 22, 2017 @10:40AM (#15312583)
I haven't had a problem with that at all, so I'm not sure :)
Re:PulseAudio under the hood by ro_sharp on Friday September 22, 2017 @09:57AM (#15312185)
I think the use cases you're describing are quite distinct from a "Linux on the desktop" user. The audio experience for this kind of user (myself included) has improved dramatically in the past few years.
Re:PulseAudio under the hood by bandrami on Friday September 22, 2017 @10:01AM (#15312210)
I'm a desktop Linux user; I preferred the old way. I do get that most people like multiplexing (I don't; I want exactly one sound source at a given time), and I'll grant that has improved.

I banged my head against my desk for a couple of days when Slackware switched to Pulse with 14.2, allegedly because it was needed for bluetooth. I still have difficulty believing that people actually use bluetooth for audio, but apparently some people love it.

Re:PulseAudio under the hood by kbenson on Friday September 22, 2017 @10:10AM (#15312281)
> I don't; I want exactly one sound source at a given time

Really? So you want all app feedback to cease if you're playing music? No IM or new email notifications? That just seems like a pain to me.

Re:PulseAudio under the hood by bandrami on Friday September 22, 2017 @10:16AM (#15312344)
I hate app feedback and notification sounds. I hate notifications in general; I prefer to poll for information I need on my schedule. This is also why I hate desktop environments and use a simple full screen window manager. One task at a time. Hell, lately I don't even bring up X every day if I don't need to. Tl;dr: I'm old.
Re:PulseAudio under the hood by rhaps0dy on Friday September 22, 2017 @10:24AM (#15312427)
Or wise, and you take control of your own attention.

Multiplexing can be handy if you like gaming, and having music from another application at the same time.

Also sometimes it's useful to have a reference manual in one side of the screen and your text editor in the other, or a PDF viewer on one side and a LaTeX editor in the other.

Re:PulseAudio under the hood by zeveb on Friday September 22, 2017 @10:51AM (#15312679)
I'm with you regarding the value of multiplexing. I don't use it much, but it was really annoying back in the day when one program would block another program's sound.

> Also sometimes it's useful to have a reference manual in one side of the screen and your text editor in the other, or a PDF viewer on one side and a LaTeX editor in the other.

True. An emacs which supported the framebuffer could do this (but GNU emacs currently only supports vt100, X, macOS & Windows, IIRC).

Re:PulseAudio under the hood by bandrami on Friday September 22, 2017 @11:51AM (#15313247)
There are some framebuffer[1] consoles[2] that work really well when you do need to mux outside of X.

[1] https://www.freedesktop.org/wiki/Software/kmscon/

[2] https://code.google.com/archive/p/fbterm/

Re:PulseAudio under the hood by dvtv75 on Saturday September 23, 2017 @04:19AM (#15318772)
There's nothing quite as jarring as having a pleasant piece of music turned up, only to have some off-key and out-of-time bell ding because an email arrived. Want to let me know there's a new email? Put a little envelope on the task bar so I can see it. Don't invade my music!
Re:PulseAudio under the hood by adambyrtek on Friday September 22, 2017 @10:38AM (#15312565)
> I still have difficulty believing that people actually use bluetooth for audio

So you don't believe that somebody would like to be able to use wireless headphones?

Re:PulseAudio under the hood by bandrami on Friday September 22, 2017 @11:48AM (#15313210)
Exactly. Why would you trade something that doesn't require power, has the most reliable, secure, and lossless transmission channel known, and is "configured" by plugging in hardware for something that requires power, has a less reliable transmission channel that can be easily snooped or forged, has to be configured in software? I literally don't understand why anyone would ever choose the latter.
Re:PulseAudio under the hood by milcron on Friday September 22, 2017 @07:58PM (#15317049)
I want to own exactly one wireless headset/microphone so that I can get up from my computer without having to excuse myself from voice chat.
Re:PulseAudio under the hood by jononor on Monday September 25, 2017 @07:37AM (#15329565)
Like a laptop or smartphone has over a stationary computer, wireless headsets have a freedom-of-movement benefit over wired.
Re:PulseAudio under the hood by zeveb on Friday September 22, 2017 @10:49AM (#15312659)
I don't: wireless headphones seem strictly worse in every way than wired. They require batteries and charging; they introduce lag; they are expensive; they are easier to lose; they don't have a convenient cable to hang on to.

I am completely and totally flabbergasted by their popularity. It's as though millions of people were turning their noses up at fine, free homemade French food and paying for McDonald's instead.

Re:PulseAudio under the hood by hamax on Friday September 22, 2017 @10:57AM (#15312733)
> seem strictly worse in every way than wired.

The same as wifi, right? Strictly worse in every way. Except for the not needing wires way.

Re:PulseAudio under the hood by khedoros1 on Friday September 22, 2017 @07:45PM (#15316973)
Although...different use-cases there, for me. I've got a dozen audio sources, either connected to speakers (the TVs) or within a couple feet of me when I'm using it (phone, media player, tablet, laptop). So, a bunch of sources, a couple of which I might be listening to at once. All either in short enough distance for cords, or loud enough that it's moot.

Wifi: The internet comes from one (inconvenient) place in the home that I can't choose. I've got a couple of powerline ethernet adapters, but I've also got a lot of devices that handle wifi, but not ethernet. The choice is between using wifi or skipping the network connection. It's great as a last- (or only)-resort connection option, and it's usually sufficient, but then my uses for it are usually pretty tame anyhow.

Re:PulseAudio under the hood by bandrami on Friday September 22, 2017 @11:50AM (#15313235)
Wifi has encryption. Bluetooth means I'm broadcasting my audio stream to anybody who feels like snooping on me.
Re:PulseAudio under the hood by digi_owl on Friday September 22, 2017 @01:20PM (#15314022)
Not quite.

Bluetooth was originally encrypted, but gained the option of non-encrypted channels with version 1.1.

On top of that Bluetooth use frequency hopping.

Until recently there was no real hardware for scanning/sniffing Bluetooth traffic, at least not anything easily available compared to a wifi card in promiscuous mode.

Re:PulseAudio under the hood by zeveb on Friday September 22, 2017 @11:07AM (#15312834)
As a matter of fact, my desktop & my laptop are both wired, and I hate how flaky WiFi is on my phone & tablet. Just moving to different rooms in my (small house) does horrible things to my network connexion speed — but Ethernet keeps on chugging along.
Re:PulseAudio under the hood by Spivak on Friday September 22, 2017 @10:50AM (#15312670)
Or want to play music from my laptop to my stereo speakers?
Re:PulseAudio under the hood by khedoros1 on Friday September 22, 2017 @07:25PM (#15316851)
> allegedly because it was needed for bluetooth

The bluetooth stack dropped support for ALSA with Bluez 5.0. About a year ago, dev started on a "bluez-alsa" or BlueALSA package the re-integrates an ALSA backend. I've used it briefly; it seems to work as advertised.

I think that Bluez 5.0 came out about the time that Slackware 14.0 did, so it makes some sense that versions before 14.2 would've provided Bluez 4.x for the bluetooth stack.

Re:PulseAudio under the hood by loeg on Friday September 22, 2017 @12:01PM (#15313334)
Well, it improved years ago (like, ten!) and I haven't had to worry about it in recent years.

I still remember buying a hardware sound card (soundblaster emu10k) to enable ALSA to mix multiple sources (game audio + teamspeak or whatever voice chat people used back then) back in the early 2000s.

Re:PulseAudio under the hood by digi_owl on Friday September 22, 2017 @01:32PM (#15314111)
A massive sad part of all this is that so much of what is going on in Linux DE land right now seems to be driven by a pipe dream called multiseat. Or effectively using software to turn a Linux desktop install into a desktop mainframe.

This by attaching a bunch of peripherals and use software to assign them to groups that effectively form the equivalent of a graphical terminal.

All this supposedly in the hopes of introducing affordable computing to schools in the developing world. But said schools have already tested and discarded this idea, so why the DEs keep pushing it is a mystery.

Re:PulseAudio under the hood by gmueckl on Friday September 22, 2017 @05:25PM (#15315946)
Serious question: I remember claims that poorer countries basically switched to smartphones instead of PCs and phones are supposed surprisingly ubiquitous there. Can anybody confirm that?

Seats never made much sense to me and if the smartphone story has any truth to it, then I do not see any valid use case for that idea these days.

Re:PulseAudio under the hood by bandrami on Saturday September 23, 2017 @12:17PM (#15320362)
It's certainly true in urban India (and becoming more true in rural India). And this has the added bonus of bringing people into the banking system because you can store, send, and withdraw cash from your mobile account (this started in sub-saharan Africa but is becoming more of a thing in rural India too).
Re:PulseAudio under the hood by esaym on Friday September 22, 2017 @03:36PM (#15315089)
And what happened when two processes wrote to that file? And what if they where each in a different sample rate? ....
Re:PulseAudio under the hood by gmueckl on Friday September 22, 2017 @05:12PM (#15315843)
Well, sound mixing and resampling are a thing. Other operating systems do that where it belongs: in the kernel. OSS gets it right, for example.