LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Software audio mixing (simultaneous audio streams) in Slackware? (http://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.


All times are GMT -5. The time now is 09:21 PM.