LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-09-2011, 05:24 AM   #1
malloc
Member
 
Registered: Jul 2010
Posts: 111

Rep: Reputation: 4
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
 
Old 05-09-2011, 05:27 AM   #2
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

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

Last edited by NoStressHQ; 05-09-2011 at 06:12 AM. Reason: My rubbish english was fixed :)
 
Old 05-09-2011, 09:42 AM   #3
malloc
Member
 
Registered: Jul 2010
Posts: 111

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by NoStressHQ View Post
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:1293snd_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.
 
Old 05-09-2011, 09:48 AM   #4
dimm0k
Member
 
Registered: May 2008
Location: Brooklyn ZOO
Distribution: Slackware64 14.2
Posts: 564

Rep: Reputation: 56
Can you post your dmix settings?
 
Old 05-09-2011, 10:15 AM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,241

Rep: Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322
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.

Last edited by dugan; 05-09-2011 at 10:23 AM.
 
Old 05-09-2011, 10:43 AM   #6
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by malloc View Post
You can see from the log i posted in my original post that:

[AO_ALSA] alsa-lib: pcm_hw.c:1293snd_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...

Last edited by NoStressHQ; 05-09-2011 at 10:47 AM.
 
Old 05-09-2011, 11:02 AM   #7
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,241

Rep: Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322Reputation: 5322
Quote:
Originally Posted by NoStressHQ View Post
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.
 
Old 05-09-2011, 11:29 AM   #8
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Rep: Reputation: 221Reputation: 221Reputation: 221
Alright, I didn't know this detail. Anyway it's a bug in the OSS emulation layer and not in the straight ALSA interface.
 
Old 05-09-2011, 12:10 PM   #9
tdos20
Member
 
Registered: Aug 2006
Location: London
Distribution: Slackware
Posts: 132

Rep: Reputation: 39
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.
 
Old 05-09-2011, 01:28 PM   #10
malloc
Member
 
Registered: Jul 2010
Posts: 111

Original Poster
Rep: Reputation: 4
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
}
 
Old 05-09-2011, 01:49 PM   #11
disturbed1
Senior Member
 
Registered: Mar 2005
Location: USA
Distribution: Slackware
Posts: 1,133
Blog Entries: 6

Rep: Reputation: 224Reputation: 224Reputation: 224
Quote:
Originally Posted by malloc View Post
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.
 
Old 05-09-2011, 02:13 PM   #12
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 232Reputation: 232Reputation: 232
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.
 
Old 05-09-2011, 02:29 PM   #13
dimm0k
Member
 
Registered: May 2008
Location: Brooklyn ZOO
Distribution: Slackware64 14.2
Posts: 564

Rep: Reputation: 56
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?
 
Old 05-09-2011, 04:02 PM   #14
adamk75
Senior Member
 
Registered: May 2006
Posts: 3,091

Rep: Reputation: 399Reputation: 399Reputation: 399Reputation: 399
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
 
Old 05-09-2011, 06:18 PM   #15
linuxs64
Member
 
Registered: Jun 2010
Posts: 116

Rep: Reputation: 47
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Software mixing : Audio chip VT1708S Skcrog86 Linux - Hardware 1 10-20-2010 02:49 AM
amixer / no audio capture from software mixing in Feisty ordealbyfire83 Linux - Software 0 11-28-2007 05:00 PM
Want to develop audio mixing software: Where to start?? tzouse Programming 2 08-04-2006 12:01 AM
audio mixing problem jonhewer Linux - Newbie 6 05-05-2005 11:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration