You are not logged in.

#1 2013-03-17 08:41:48

LordOfInsomnia
Member
Registered: 2011-10-13
Posts: 69

Simultaneous audio playback does not work

I have tried everything from wiki:

https://wiki.archlinux.org/index.php/Ad … ack_Issues

I have even uninstalled PulseAudio. Still i cannot play two sounds from diffrent apps in same time

Any ideas?
Thanks.

Offline

#2 2013-03-17 09:13:49

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: Simultaneous audio playback does not work

More info needed. 2 speakers, or more than 2? Use speaker-test and show an error message.

See example config in my sig.

Offline

#3 2013-03-17 09:19:08

LordOfInsomnia
Member
Registered: 2011-10-13
Posts: 69

Re: Simultaneous audio playback does not work

I use two spekers and this is an output

speaker-test 1.0.26

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
ALSA lib pcm.c:2217:(snd_pcm_open_noupdate) Unknown PCM CA0106:front
Playback open error: -2,No such file or directory

Offline

#4 2013-03-17 09:45:49

LordOfInsomnia
Member
Registered: 2011-10-13
Posts: 69

Re: Simultaneous audio playback does not work

I have tried speaker-test with root user and output is like this

speaker-test 1.0.26

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 2048 to 8192
Period size range from 1024 to 1024
Using max buffer size 8192
Periods = 4
was set period_size = 1024
was set buffer_size = 8192
 0 - Front Left
Time per period = 2.827384
 0 - Front Left
Time per period = 2.986543
 0 - Front Left
Time per period = 2.986651
 0 - Front Left
Time per period = 2.986716
...

Offline

#5 2013-03-17 09:46:52

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: Simultaneous audio playback does not work

Unknown PCM CA0106:front

Try the weird edits mentioned at:

http://alexpb.com/notes/articles/2012/1 … pberry-pi/
http://forums.gentoo.org/viewtopic-p-72 … ml#7258710

Edit: Ah, it works as root? Then it's a permissions problem - blame systemd wink

First a quick check of the group:

ls -l /dev/snd

Last edited by brebs (2013-03-17 09:54:17)

Offline

#6 2013-03-17 13:28:00

LordOfInsomnia
Member
Registered: 2011-10-13
Posts: 69

Re: Simultaneous audio playback does not work

This is output for ls -l /dev/snd


total 0
drwxr-xr-x 2 root root       60 Mar 17 14:10 by-path
crw-rw---- 1 root audio 116, 11 Mar 17 14:10 controlC0
crw-rw---- 1 root audio 116,  2 Mar 17 14:10 midiC0D0
crw-rw---- 1 root audio 116, 10 Mar 17 14:10 pcmC0D0c
crw-rw---- 1 root audio 116,  9 Mar 17 14:20 pcmC0D0p
crw-rw---- 1 root audio 116,  8 Mar 17 14:10 pcmC0D1c
crw-rw---- 1 root audio 116,  7 Mar 17 14:10 pcmC0D1p
crw-rw---- 1 root audio 116,  6 Mar 17 14:10 pcmC0D2c
crw-rw---- 1 root audio 116,  5 Mar 17 14:10 pcmC0D2p
crw-rw---- 1 root audio 116,  4 Mar 17 14:10 pcmC0D3c
crw-rw---- 1 root audio 116,  3 Mar 17 14:10 pcmC0D3p
crw-rw---- 1 root audio 116,  1 Mar 17 14:10 seq
crw-rw---- 1 root audio 116, 33 Mar 17 14:10 timer

I have tried http://alexpb.com/notes/articles/2012/1 … pberry-pi/
and it solved some problems. Now skype and vlc can be reproduce sound at same time, but (skype or vlc) and chrome cannot.

It's not systemD's fault, because I am (still) using initscripts.

Last edited by LordOfInsomnia (2013-03-17 13:28:22)

Offline

#7 2013-03-17 15:43:15

the sad clown
Member
From: 192.168.0.X
Registered: 2011-03-20
Posts: 837

Re: Simultaneous audio playback does not work

Also check your login session:

loginctl session-status 1

Your session may not be '1'.  You can find it with loginctl 'list-sessions'.

Edit: Nvm, just saw your edit where you aren't using systemd.  Btw, your output for /dev/snd looks fine.  Are you a member of 'audio' group?

Last edited by the sad clown (2013-03-17 15:45:17)


I laugh, yet the joke is on me

Offline

#8 2013-03-17 17:30:00

LordOfInsomnia
Member
Registered: 2011-10-13
Posts: 69

Re: Simultaneous audio playback does not work

As admin I have been member of audio group, but my root account has not.
I added audio group to root, and restarted my pc, but there is no change. hmm

Offline

#9 2013-03-25 21:55:43

LordOfInsomnia
Member
Registered: 2011-10-13
Posts: 69

Re: Simultaneous audio playback does not work

Anybody, any other ideas? hmm

Offline

#10 2013-03-31 11:20:32

LordOfInsomnia
Member
Registered: 2011-10-13
Posts: 69

Re: Simultaneous audio playback does not work

the sad clown wrote:

Also check your login session:

loginctl session-status 1

Your session may not be '1'.  You can find it with loginctl 'list-sessions'.

Edit: Nvm, just saw your edit where you aren't using systemd.  Btw, your output for /dev/snd looks fine.  Are you a member of 'audio' group?

I have finally switch to systemd. smile

As you suspected my session is 1.

I cannot find how to change it. smile

Offline

#11 2013-04-01 17:22:58

rasertux
Member
From: Florianópolis, Brazil
Registered: 2012-03-03
Posts: 46

Re: Simultaneous audio playback does not work

I don't know if works for you but for me with pulseaudio i install paprefs, open it and go to "simultaneous output"

"Sorry for my english"

Offline

#12 2013-04-01 18:26:22

LordOfInsomnia
Member
Registered: 2011-10-13
Posts: 69

Re: Simultaneous audio playback does not work

rasertux wrote:

I don't know if works for you but for me with pulseaudio i install paprefs, open it and go to "simultaneous output"

"Sorry for my english"

Thank you, but you did not understand me. One of paprefs feature is "simultaneous" output for two sound cards. I have duplex problems. One application locks sound card, and other applications cannot use it.

Offline

#13 2013-04-02 06:04:52

Max-P
Member
Registered: 2011-06-11
Posts: 164

Re: Simultaneous audio playback does not work

By default, ALSA only supports a single stream at a time.

There are a few options for this to work: you can either use PulseAudio for that, or use dmix.

Post your /etc/asoundrc.conf and your ~/.asoundrc (as user), and also make sure you are part of the audio group. Root bypasses any privilege check, so you have to be able to run speaker-test as a user before getting further.

Solution 1: Using PulseAudio
- First make sure the pulseaudio daemon is running using any task manager.
- Then, make sure your app is outputting to PulseAudio: run pavucontrol, and check the playback tab. Your apps should list there. If they don't but still produce sound, your app one or both of your apps are not using PulseAudio and you need to fix that.

Solution 2: Using dmix
- Completely disable pulseaudio by setting its autospawn to false in /etc/pulse/client.conf
- Erase any .asoundrc setting PulseAudio as the output
- Setup dmix in your /etc/asoundrc.conf according to the Wiki: https://wiki.archlinux.org/index.php/AL … .28dmix.29
- Setup your applications to output to dmix (some will try PulseAudio before ALSA, so you need to fix those, like Gstreamer, which by default tries PA first, then other backends)

Offline

#14 2013-04-02 07:58:42

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: Simultaneous audio playback does not work

Haha. What you've just said is a strange mixture of half-truths. But not quite truthful enough.

The default ALSA PCM for output is named "default" - a good name, and it's what the vast majority of apps use as their, er, default. For example, Adobe Flash uses it.

This "default" PCM gets set up as stereo speakers, outputting via dmix. Usually. The configuration is in /usr/share/alsa/, and it's been abstracted WAAAY too much.

There's a few things that trip people up:

1. "default" is only set up for stereo, so it will not mix e.g. 5.1 surround sound - see the config in my sig, for a much better dmix, and examples of other ALSA config tricks.
2. Apps can use the ALSA API to deliberately bypass dmix - this is fixed by the user configuring the app (e.g. the "mpd" music player) properly.
3. The first app to open the sound device (until it's closed again) gets to set important parameters, e.g. period_size and buffer_size. Unless these are set by the user's config - like mine does, to ensure the values are sensible.
4. Thanks to udev, the soundcard order at bootup can be random - it needs to be specified, if more than one soundcard.

So, anyone with sound problems should read the aforementioned config, try to understand it, and then use it, tweaked as appropriate for their hardware.

Edit: Added point 4.

Last edited by brebs (2013-04-20 11:41:56)

Offline

#15 2013-04-02 08:19:29

Max-P
Member
Registered: 2011-06-11
Posts: 164

Re: Simultaneous audio playback does not work

Where's the half-truth so I can fix myself?

dmix never got enabled by default on my system.

Regular ALSA outputs (the hw devices, not the dmix ones), can only support one stream at a time, unless the hardware supports multiple channels on the same output.This is pretty rare, so we have to do it in software.

Maybe the Arch config changed meanwhile, but when I installed my system, dmix was off by default. All I got was the hw:0 and hw:1 cards, and the default mapped to hw:0. If sound was played through "default", it went through "hw:0.0", which locked that card, and only that app could output to default and hw:0. hw:1 was still available though!

Also, apps do NOT bypass dmix. They output to an alsa channel that doesn'y go through the dmix plugin. If I output to hw:0 directly (say, I run jackd on it), it then gets exclusive use of the card. In my example, jackd didn't bypass dmix; it just used an output that isn't routed through dmix.

When an app uses the dmix output (which is usually also set as the default one when setted up), dmix then opens the connected hw:xx device (or actually, anything else, it's even possible to put dmix between the apps and pulseaduio if you want, even if it's completely pointless), and output to it. Where it gets cool, is that dmix accepts more than one stream, and it will mix them together before routing the sound back to the real hw device.

PulseAudio is another ALSA plugin/device just like dmix, but it runs in userland, offers neat functions and interfaces, at the cost of more CPU. Also, I don't know if it changed, but if I remember, dmix can't resample, while PulseAudio does (horribly, but it still does).

I'm still waiting to see where I'm wrong. Just tell me where, and I will correct myself. But for now this is my understanding of the ALSA config, and being a programmer and having played a lot with ALSA, PulseAudio and Jack (all at the same time even!), that concept of stream routing come back again and again.

Offline

#16 2013-04-02 08:49:16

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: Simultaneous audio playback does not work

Max-P wrote:

do NOT bypass dmix

"Bypass" in the sense that users wanted the sound to automagically go through dmix, but it didn't. Do you really want to argue about the meaning of bypass?

dmix can't resample

Yes it can. E.g., /usr/share/alsa/alsa.conf contains:

defaults.pcm.dmix.rate 48000

And I use the "rate" keyword in my config.

I'm still waiting to see where I'm wrong

LOL, that's how angry trolls speak. Calm down, relax, have a beer, this is the great anonymous Internet where things aren't personal.

Offline

#17 2013-04-02 08:58:10

Max-P
Member
Registered: 2011-06-11
Posts: 164

Re: Simultaneous audio playback does not work

brebs wrote:
Max-P wrote:

do NOT bypass dmix

"Bypass" in the sense that users wanted the sound to automagically go through dmix, but it didn't. Do you really want to argue about the meaning of bypass

That's a bit of playing with the words, but yeah, depends on the point of view. From you post, I understand apps are coded to work around dmix, which isn't the case, they just don't follow the dmix path by default. But we can call that bypass if you want.

dmix can't resample

Yes it can. E.g., /usr/share/alsa/alsa.conf contains:

defaults.pcm.dmix.rate 48000

And I use the "rate" keyword in my config.

Yeah, if you notice my post, a few words before I say "if I remember". I kind of advertised there that I could really be wrong.

I'm still waiting to see where I'm wrong

LOL, that's how angry trolls speak. Calm down, relax, have a beer, this is the great anonymous Internet where things aren't personal.

I'm not angry, but telling I'm half wrong without telling why or at least where, it's not really helpful. By the way, you still haven't pointed anything wrong in my original post smile

Offline

#18 2013-04-02 20:57:53

LordOfInsomnia
Member
Registered: 2011-10-13
Posts: 69

Re: Simultaneous audio playback does not work

Max-P wrote:

By default, ALSA only supports a single stream at a time.

I did not know that. Thank you. smile

Max-P wrote:

Solution 1: Using PulseAudio
- First make sure the pulseaudio daemon is running using any task manager.
- Then, make sure your app is outputting to PulseAudio: run pavucontrol, and check the playback tab. Your apps should list there. If they don't but still produce sound, your app one or both of your apps are not using PulseAudio and you need to fix that.

/etc/asoundrc.conf  is empty, this is my ~/.asoundrc

pcm.!default CA0106:front

Situation is better. smile Mpd, and chrome(youtube/flash) have problem with pulseaudio. I will try to fix them. Thank you.

Until I fix problems with mpd and chrome, this issue will be opened.

mpd has known issue "[pulse]: pa_context_connect() has failed: Connection refused", but i cannot figure it out yet. smile


brebs wrote:

The default ALSA PCM for output is named "default" - a good name, and it's what the vast majority of apps use as their, er, default. For example, Adobe Flash uses it.

This "default" PCM gets set up as stereo speakers, outputting via dmix. Usually. The configuration is in /usr/share/alsa/, and it's been abstracted WAAAY too much.

I think this is my problem with chrome. smile

Thank you brebs and max-p.

Offline

#19 2013-04-02 21:12:56

Max-P
Member
Registered: 2011-06-11
Posts: 164

Re: Simultaneous audio playback does not work

Ok, since your asound.conf is empty, try putting that into it:

(This is normally provided by the pulseaudio-alsa package)

# Use PulseAudio by default
pcm.!default {
  type pulse
  fallback "sysdefault"
  hint {
    show on
    description "Default ALSA Output (currently PulseAudio Sound Server)"
  }
}

ctl.!default {
  type pulse
  fallback "sysdefault"
}

As for mpd, it can't connect to PulseAudio. Does it run as a seperate user? Does it run inside your X session or does it runs in the background outside of an X session?

You might need to start PA differently depending on your case, and pass it the path to the PulseAudio socket through environment variables.

Offline

#20 2013-04-02 21:55:10

LordOfInsomnia
Member
Registered: 2011-10-13
Posts: 69

Re: Simultaneous audio playback does not work

Max-P wrote:

As for mpd, it can't connect to PulseAudio. Does it run as a seperate user? Does it run inside your X session or does it runs in the background outside of an X session?

It's started in background from systemd. I am trying to find PulseAudio service in systemd, so I can make dependency for mpd to start after PulseAudio. hmm

Offline

#21 2013-04-02 22:00:34

Max-P
Member
Registered: 2011-06-11
Posts: 164

Re: Simultaneous audio playback does not work

LordOfInsomnia wrote:
Max-P wrote:

As for mpd, it can't connect to PulseAudio. Does it run as a seperate user? Does it run inside your X session or does it runs in the background outside of an X session?

It's started in background from systemd. I am trying to find PulseAudio service in systemd, so I can make dependency for mpd to start after PulseAudio. hmm

PulseAudio is not a systemd service. It is autostarted when apps tries to play sound or query the mixer levels (mixer applets usually do that, so it's always auto-started).

That way, you probably either want to start PulseAudio as a system-wide daemon, or make some script to start pulseaudio at boot as your user before MPD.

Offline

#22 2013-09-08 07:43:13

GoDuck
Member
From: Argentina
Registered: 2013-09-08
Posts: 8

Re: Simultaneous audio playback does not work

Hey everyone,
I'm wondering if anyone still has this problem. This is how I solved (?) the problem on my machine:

When I first got everything set up I was getting no audio, ended up writing a couple of things into the /etc/asound.conf file.
That fixed the sound but after that I've noticed that simultaneous playback wasn't working, after fidling about, installing and uninstalling PulseAudio and a number of other steps that I ended up reverting.
I added

pcm.!default { type hw card 0} 
ctl.!default { type hw card 0}

and that fixed my initial no-sound issue.
Later I added

pcm.dsp { type plug slave.pcm "dmix" }

And that didn't help with simultanious playback, but after removing the first enrties (pcm.!default and ctl.!default) and leaving pcm.dsp sound was still working and simultaneous playback started working.
To be honest this is my 2nd day using linux and I have no idea why this actually worked but maybe someone else can shed some light on the matter and hopefully it can help someone else reading the thread.


Telling people to delete their system32 folder isn't as fun here as it was on the Windows forums.

Offline

Board footer

Powered by FluxBB