Arch Audio Alsa

Hey guys!!

I’ve returned to Arch (YAY!) but I’m still having a slight problem with audio. Last time I was using Pulseaudio and it caused no end of problems. This time I’m going to stick to ALSA. I would like to use my soundcard (Xonar DS) instead of the onboard sound.

The problem I am having is getting it to work across the whole system. My audio player (deadbeef) works fine and I can get mplayer to work as long as I modify the command;

ALSA_CARD=DS mplayer movie_file.avi

How can I set this so I don’t need to do that everytime?

Also I can’t get sound to work in Firefox.

aplay -l

**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC888 Analog [ALC888 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: ALC888 Digital [ALC888 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: DS [Xonar DS], device 0: Multichannel [Multichannel]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: DS [Xonar DS], device 1: Digital [Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

lspci | grep Audio

00:1b.0 Audio device: Intel Corporation 82801JI (ICH10 Family) HD Audio Controller
09:00.0 Multimedia audio controller: C-Media Electronics Inc CMI8788 [Oxygen HD Audio]

Anything else you need just ask.

Cheers in advance.

Try this … Open a terminal and run:

gedit ~/.asoundrc

When gedit opens an EMPTY file, make it read:-

pcm.!default {
type hw
card 1
}

ctl.!default {
type hw
card 1
}

SAVE the file … and REBOOT to test.

Cheers Mark, that has helped.

Sort of…

Now mplayer works without any modification to the command but Firefox still has no sound. Also if I play a song in deadbeef I then need to quit the application before mplayer will work again.

Is this something to do with ALSA’s dmix feature?

Output of mplayer with deadbeef still open after a song;


[output omitted]
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS)
==========================================================================
[AO_ALSA] alsa-lib: pcm_hw.c:1293:(snd_pcm_hw_open) open '/dev/snd/pcmC1D0p' failed (-16): Device or resource busy
[AO_ALSA] Playback open error: Device or resource busy
Failed to initialize audio driver 'alsa'
Could not open/initialize audio device -> no sound.
Audio: no sound
Starting playback..
[output omitted]

Have you considered just disabling the onboard soundcard in the BIOS ?

You’ll then have to get rid of the ~/.asoundrc you just created

I hadn’t thought of that!! Damn simple solutions!.. I’ll give it a go…

Unfortunately disabling the onboard sound in BIOS hasn’t solved the error. Firefox still doesn’t have sound.

aplay -l now shows;


**** List of PLAYBACK Hardware Devices ****
card 0: DS [Xonar DS], device 0: Multichannel [Multichannel]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: DS [Xonar DS], device 1: Digital [Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

So I’ve definitely only got the one soundcard option.

Mplayer now shows the following after playing a song in deadbeef;


[output omitted]

==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 48000 Hz, 2 ch, s16le, 1536.0 kbit/100.00% (ratio: 192000->192000)
Selected audio codec: [ffdca] afm: ffmpeg (FFmpeg DTS)
==========================================================================
[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
Failed to initialize audio driver 'alsa'
Could not open/initialize audio device -> no sound.
Audio: no sound
Starting playback...

[output omitted]

what’s the contents of /etc/asound.conf ?

[AO_ALSA] alsa-lib: pcm_dmix.c:1018:(snd_pcm_dmix_open) unable to open slave
It looks like the slave is not created, you may want to look at the following: http://alsa.opensrc.org/AlsaTips#Share_a_single_card_with_multiple_applications http://alsa.opensrc.org/DmixPlugin

@Mark - I don’t seem to have /etc/asound.conf. Not sure why, I never had to manually set it up when I was installing the system. Should it be created automatically?

@SeZo - Cheers for those links, I will look through them today.

I tried Firefox again last night before I gave up for the evening and Youtube decided to have sound. Not sure what was different as I hadn’t changed anything since the reboot. At least it is working.

I can still hear sound in mplayer after listening to youtube, I just can’t have deadbeef and mplayer at the same time. Not a massive issue as this is a workable solution until I can get them to share the card. At least I’ve got sound!

Cheers for the help guys, I’ll have another look tonight after reading up on Dmix.

Try making ~/.asoundrc read:-

pcm.!default {
	type plug
	slave.pcm "dmixer"
}

pcm.dmixer  {
 	type dmix
 	ipc_key 1024
 	slave {
		pcm "hw:1,0"
		period_time 0
		period_size 1024
		buffer_size 4096
		rate 44100
	}
	bindings {
		0 0
		1 1
	}
}

ctl.dmixer {
	type hw
	card 0
}

you’ll then have to reboot or at least reload alsa.

reference:
http://www.alsa-project.org/main/index.php/Asoundrc#dmix

it MAY be that the line:-

		pcm "hw:1,0"

needs changing to:-

		pcm "hw:0,0"

but you can always test it both ways :wink:

Cheers Mark. I’ll check it tonight after work and let you know.