LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Software audio mixing (simultaneous audio streams) in Slackware? (https://www.linuxquestions.org/questions/slackware-14/software-audio-mixing-simultaneous-audio-streams-in-slackware-879618/)

malloc 05-09-2011 05:24 AM

Software audio mixing (simultaneous audio streams) in Slackware?
 
If you have a "proper" sound card like a Sound Blaster X-Fi, like I do in my desktop, then you have hardware mixing support. This means that when simultaneous audio streams are used, they are actually played simultaneously -- and the hardware itself provides this functionality.

If you have audio functionality integrated in the chipset, chances are hardware mixing is not supported, or at least not implemented in the drivers you will see in GNU/Linux. Thus this must be done in software instead.

The latter is the case for my laptop, which has a:

Code:

Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 03)
Which uses the snd-hda-intel driver.

My question is, what do I need to do in order to allow for software mixing as the device clearly does not have hardware mixing supported?
I.e. I want to be able to play audio with xmms simultaneously while I play audio from e.g. mplayer, or Firefox/flash.

I see that the dmix plugin for ALSA is supposedly able to provide this, but what configuration do I need? I've tried all of the examples at http://alsa.opensrc.org/Dmix in my ~/.asoundrc and /etc/alsa.conf.

The error I receive when I try to play simultaneous audio streams is as follows:

(From mplayer when xmms has hooked the audio device)

Code:

[AO OSS] audio_setup: Can't open audio device /dev/dsp: Device or resource busy
[AO_ALSA] alsa-lib: pcm_hw.c:1293:(snd_pcm_hw_open) open '/dev/snd/pcmC0D0p' failed (-16): Device or resource busy
[AO_ALSA] alsa-lib: pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave
[AO_ALSA] Playback open error: Device or resource busy
[AO ESD] esd_open_sound failed: Connection timed out
[AO SDL] Samplerate: 44100Hz Channels: Stereo Format s16le
[AO_ALSA] alsa-lib: pcm_hw.c:1293:(snd_pcm_hw_open) open '/dev/snd/pcmC0D0p' failed (-16): Device or resource busy
[AO_ALSA] alsa-lib: pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave
[AO SDL] Unable to open audio: No available audio device


NoStressHQ 05-09-2011 05:27 AM

Just verify that you REALLY are using ALSA in your software instead of the so common default OSS...

malloc 05-09-2011 09:42 AM

Quote:

Originally Posted by NoStressHQ (Post 4350769)
Just verify that you REALLY are using ALSA in your software instead of the so common default OSS...

You can see from the log i posted in my original post that:

[AO_ALSA] alsa-lib: pcm_hw.c:1293:(snd_pcm_hw_open) open '/dev/snd/pcmC0D0p' failed (-16): Device or resource busy

I.e. mplayer attempts to use ALSA, in fact it tries all of the most common interfaces to play sound, all of them failing.

XMMS is also set up to use ALSA as output.

However, I obviously want this to work with OSS as well as ALSA, i.e. software mixing. If you look at the dmix tutorial, this should be perfectly possible, although it doesn't work for me.

dimm0k 05-09-2011 09:48 AM

Can you post your dmix settings?

dugan 05-09-2011 10:15 AM

You could try the OSS4Front drivers.

http://slackbuilds.org/repository/13.37/system/oss/

In the current versions of Slackware, ALSA should have software mixing enabled by default. As long as all your programs are outputting through ALSA, no further configuration should be needed. That is not to say, of course, that it will work for everyone.

NoStressHQ 05-09-2011 10:43 AM

Quote:

Originally Posted by malloc (Post 4350996)
You can see from the log i posted in my original post that:

[AO_ALSA] alsa-lib: pcm_hw.c:1293:(snd_pcm_hw_open) open '/dev/snd/pcmC0D0p' failed (-16): Device or resource busy

I.e. mplayer attempts to use ALSA, in fact it tries all of the most common interfaces to play sound, all of them failing.

XMMS is also set up to use ALSA as output.

However, I obviously want this to work with OSS as well as ALSA, i.e. software mixing. If you look at the dmix tutorial, this should be perfectly possible, although it doesn't work for me.

I see from your log that it uses OSS... I had the exact same problem last week strongly believing that XMMS were using ALSA and not the old buggy OSS BUT it used OSS to my surprise... I might be wrong but it's a common problem on laptop with Intel audio cards... The log displays several errors when the callstack is returning error, the first one is OSS that failed, then ALSA propagates the error (it seems ALSA can be a layer on top of OSS too, I don't really know the inside work, but that's what the log suggests...).

To be short, it seems that if a single app uses OSS on those kind of setup, nothing work after (even if it's ALSA)... It's not an ALSA bug it's 100% a OSS bug.

Of course, again, it might be another thing that I missed.

Good luck !

Edit: Oh, i didn't find any configuration for that for the Flash player, but I guess that it uses ALSA, I don't know for mplayer as I use VLC, but my VLC was using OSS too...
You might find some app, not allowing you to change the audio interface, and if they're using OSS in a hardcoded way, you might be stuck with those apps...

dugan 05-09-2011 11:02 AM

Quote:

Originally Posted by NoStressHQ (Post 4351053)
To be short, it seems that if a single app uses OSS on those kind of setup, nothing work after (even if it's ALSA)... It's not an ALSA bug it's 100% a OSS bug.

On most distributions (including Slackware), OSS is an emulation layer provided by ALSA, so yes it's an ALSA bug.

NoStressHQ 05-09-2011 11:29 AM

Alright, I didn't know this detail. Anyway it's a bug in the OSS emulation layer and not in the straight ALSA interface.

tdos20 05-09-2011 12:10 PM

It might be an idea to look into JACK for software audio mixing - might not be exactly what you need but it works well - there IS flash support available from libflashsupport-jack.

malloc 05-09-2011 01:28 PM

I think you guys are mistaken.

I don't think the main issue is that ALSA's OSS emulation is at fault, or that OSS is the issue at all.

I get similar errors when I use other programs that also supposedly use ALSA:

From xmms when Firefox/flash has hooked the audio device:

Code:

Message: device: hw:0,0

** WARNING **: alsa_setup(): Failed to open pcm device (hw:0,0): Device or resource busy

From Firefox/flash when xmms has hooked the audio device:

Code:

ALSA lib pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave
As you can see, the ALSA API function call alsa_setup() and snd_pcm_dmix_open() seems to fail.

My alsa.conf follows:

Code:

pcm.!default {
    type plug
    slave.pcm "dmixer"
}
pcm.dsp0 {
    type plug
    slave.pcm "dmixer"
}
pcm.dmixer {
    type dmix
    ipc_key 1024
    slave {
        pcm "hw:0,0"
        period_time 0
        period_size 1024
        buffer_size 8192
        #periods 128
        rate 44100
    }
    bindings {
        0 0
        1 1
    }
}
ctl.mixer0 {
    type hw
    card 0
}


disturbed1 05-09-2011 01:49 PM

Quote:

Originally Posted by malloc (Post 4351232)
I think you guys are mistaken.

I don't think the main issue is that ALSA's OSS emulation is at fault, or that OSS is the issue at all.

I get similar errors when I use other programs that also supposedly use ALSA:

From xmms when Firefox/flash has hooked the audio device:

Perhaps the issue is with xmms and mpalyer attempting to lock/block the device?

I am - right now - listening to audio with Goggles Music Manager, streaming a video in Firefox, and started to play a movie with both kaffeine and parole (just to see if it would work ;) ) everything has sound at the same time.

On my girlfriend's pc, she runs firefox, seamonkey and chrome at the same time, all playing flash based games in facebook, while listening to Juk, everything has sound. And yes it's quite annoying :)
Code:

00:14.2 Audio device: ATI Technologies Inc SBx00 Azalia (Intel HDA)

00:1b.0 Audio device: Intel Corporation 82801JI (ICH10 Family) HD Audio Controller

This is without any .asoundrc or alsa.conf. What ever alsa setup as default works.

bgeddy 05-09-2011 02:13 PM

Quote:

My question is, what do I need to do in order to allow for software mixing as the device clearly does not have hardware mixing supported?
I.e. I want to be able to play audio with xmms simultaneously while I play audio from e.g. mplayer, or Firefox/flash.
This works for me too and I have Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 02) installed. I have to tell XMMS to specifically use ALSA and I get both Youtube and XMMS mixed output. I only get the one volume control though and cannot independently affect volumes of XMMS and Youtube. Maybe playing with Jack or something would fix that. I have always simply ran one or the other at once and just accepted this limitation as being default. It would be interesting if you come up with a good solution.

dimm0k 05-09-2011 02:29 PM

I went through some of these issues when I was trying to get dmix working on my notebook as well. It looks like your alsa.conf is set up properly in its barest form, so I'm curious... are you able to get sound mixing working with two different instances of mplayer?

adamk75 05-09-2011 04:02 PM

Next time you get that error run 'lsof | grep dsp' and I'm willing to bet you'll see some application grabbing the emulated OSS /dev/dsp device.

Adam

linuxs64 05-09-2011 06:18 PM

Both OSSv42 and jack-audio-connection-kit will do software mixing on slackware.

OSSv42: volume control and mixing is done via ossxmix (a bundled utility), device testing and information can be checked using osstest and ossinfo (both are terminal apps). Comprehensive wiki on OSSv42

jack: mixing of audio streams is done via qjackctl

Recommended to read and perform pre/post install steps outlined in the README.

malloc 05-11-2011 03:45 PM

I have now attempted to let two instances of mplayer execute and try to use the audio device. The test fails, the second instance is unable to open the device, from the console output I can see it tries both ALSA as well as OSS, to no avail:

Code:

Opening audio decoder: [faad] AAC (MPEG2/4 Advanced Audio Coding)
FAAD: compressed input bitrate missing, assuming 128kbit/s!
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
Selected audio codec: [faad] afm: faad (FAAD AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
[AO OSS] audio_setup: Can't open audio device /dev/dsp: Device or resource busy
[AO_ALSA] alsa-lib: pcm_hw.c:1293:(snd_pcm_hw_open) open '/dev/snd/pcmC0D0p' failed (-16): Device or resource busy
[AO_ALSA] alsa-lib: pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave
[AO_ALSA] Playback open error: Device or resource busy
[AO ESD] esd_open_sound failed: Connection timed out
[AO SDL] Samplerate: 44100Hz Channels: Stereo Format s16le
[AO_ALSA] alsa-lib: pcm_hw.c:1293:(snd_pcm_hw_open) open '/dev/snd/pcmC0D0p' failed (-16): Device or resource busy
[AO_ALSA] alsa-lib: pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave
[AO SDL] Unable to open audio: No available audio device


T3slider 05-11-2011 08:23 PM

Use
Code:

mplayer -ao alsa
I believe mplayer by default tries to use OSS, and alsa-oss will lock the device. You can also set this in mplayer's config file to avoid passing it explicitly.

malloc 05-11-2011 08:44 PM

Quote:

Originally Posted by T3slider (Post 4353826)
Use
Code:

mplayer -ao alsa
I believe mplayer by default tries to use OSS, and alsa-oss will lock the device. You can also set this in mplayer's config file to avoid passing it explicitly.

Great, thanks, that actually worked -- sorry that I didn't realize that myself, that is actually quite trivial. So in other words software mixing does indeed work with ALSA.

Now I only need to know how to make OSS programs work with software mixing.

dimm0k 05-11-2011 09:22 PM

Great to hear you have software mixing working! I suggested running two instances of mplayer to actually test it, as it is the easiest to work and switch to ALSA. That and that's what I used to test when I was trying to figure things out. I hope you realize that xmms can be made to use ALSA as well, so I'm curious as to what programs you use that use OSS specifically?

T3slider 05-11-2011 09:25 PM

Quote:

Originally Posted by malloc (Post 4353842)
Now I only need to know how to make OSS programs work with software mixing.

It won't unless you run it through a sound server (like phonon or arts or pulse or esd etc.). You should set everything you can to output via ALSA explicitly. If you have an app that will ONLY use OSS then you can start sound from one app that uses ALSA, then start the OSS app and it shouldn't lock the sound device. However, if it is the first app to output sound and it uses OSS then you're out of luck unless it can be routed through a sound server.


All times are GMT -5. The time now is 02:39 AM.