You are not logged in.

#1 2013-04-10 03:47:22

andy_0
Member
Registered: 2013-04-10
Posts: 15

[Solved] Alsa, no simultaneous sound; Asus Xonar D2X

Hi,

I have one of those "My Alsa sound ist only working for one application at the same time." issue. I already tried the Alsa wiki entry and used Google as well.

I set up /etc/asound.conf and configured my sound card as primary sound card for kernel load within /etc/modprobe.d/alsa-base.conf. Sound is now working fine however I only have sound for one application at the same time. So i tried to set up ~/.mpdconf but it's not helping. The error message states "Cannot open device" or similiar. I am using an Asus Xonar D2X as primary sound card. As far as i can tell mpd is not installed on my system.

Following some config and diagnostic information.

/etc/asound.conf

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

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

/etc/modprobe.d/alsa-base.conf

options snd slots=snd_virtuoso
options snd_virtuoso index=0
options snd_hda_cdec_hdmi index=-2
options snd_hda_intel index=-2

~/.mpdconf

playlist_directory      "~/.mpd/playlists"
db_file                 "~/.mpd/mpd.db"
log_file                "~/.mpd/mpd.log"
error_file              "~/.mpd/mpd.error"

audio_output {
        type                    "alsa"
        name                    "Sound Card"
        options                 "dev=dmixer"
        device                  "plug:dmix"
}

lspci | grep Audio

00:14.2 Audio device: Advanced Micro Devices [AMD] nee ATI SBx00 Azalia (Intel HDA) (rev 40)
01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Barts HDMI Audio [Radeon HD 6800 Series]
03:04.0 Multimedia audio controller: C-Media Electronics Inc CMI8788 [Oxygen HD Audio]

arecord -l

**** List of CAPTURE Hardware Devices ****
card 0: D2X [Xonar D2X], device 0: Multichannel [Multichannel]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: D2X [Xonar D2X], device 1: Digital [Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: SB [HDA ATI SB], device 0: ALC892 Analog [ALC892 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: SB [HDA ATI SB], device 2: ALC892 Analog [ALC892 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

lsmod | grep snd

snd_hda_codec_hdmi     27848  1 
snd_hda_codec_realtek    62745  1 
snd_hda_intel          34194  2 
snd_virtuoso           33768  1 
snd_oxygen_lib         30845  1 snd_virtuoso
snd_mpu401_uart         5979  1 snd_oxygen_lib
snd_rawmidi            18831  1 snd_mpu401_uart
snd_seq_device          5268  1 snd_rawmidi
snd_hda_codec         102453  3 snd_hda_codec_realtek,snd_hda_codec_hdmi,snd_hda_intel
snd_hwdep               6428  1 snd_hda_codec
snd_pcm                78146  4 snd_hda_codec_hdmi,snd_oxygen_lib,snd_hda_codec,snd_hda_intel
snd_page_alloc          7426  2 snd_pcm,snd_hda_intel
snd_timer              18934  1 snd_pcm
snd                    60156  18 snd_hda_codec_realtek,snd_hwdep,snd_timer,snd_hda_codec_hdmi,snd_pcm,snd_rawmidi,snd_virtuoso,snd_oxygen_lib,snd_hda_codec,snd_hda_intel,snd_mpu401_uart,snd_seq_device
soundcore               5442  1 snd

modinfo snd_virtuoso

filename:       /lib/modules/3.8.5-1-ARCH/kernel/sound/pci/oxygen/snd-virtuoso.ko.gz
license:        GPL v2
description:    Asus Virtuoso driver
author:         Clemens Ladisch <clemens@ladisch.de>
alias:          pci:v000013F6d00008788sv000013F6sd00008788bc*sc*i*
alias:          pci:v000013F6d00008788sv00001043sd00008522bc*sc*i*
alias:          pci:v000013F6d00008788sv00001043sd0000838Ebc*sc*i*
alias:          pci:v000013F6d00008788sv00001043sd0000835Ebc*sc*i*
alias:          pci:v000013F6d00008788sv00001043sd0000835Dbc*sc*i*
alias:          pci:v000013F6d00008788sv00001043sd0000835Cbc*sc*i*
alias:          pci:v000013F6d00008788sv00001043sd0000834Fbc*sc*i*
alias:          pci:v000013F6d00008788sv00001043sd00008327bc*sc*i*
alias:          pci:v000013F6d00008788sv00001043sd00008314bc*sc*i*
alias:          pci:v000013F6d00008788sv00001043sd000082B7bc*sc*i*
alias:          pci:v000013F6d00008788sv00001043sd00008275bc*sc*i*
alias:          pci:v000013F6d00008788sv00001043sd00008269bc*sc*i*
depends:        snd-oxygen-lib,snd
intree:         Y
vermagic:       3.8.5-1-ARCH SMP preempt mod_unload modversions 
parm:           index:card index (array of int)
parm:           id:ID string (array of charp)
parm:           enable:enable card (array of bool)

fuser -v /dev/snd/* /dev/dsp*

Specified filename /dev/dsp* does not exist.
                     USER        PID ACCESS COMMAND
/dev/snd/controlC0:  andy       1816 F.... panel-17-mixer
/dev/snd/controlC1:  andy       1816 F.... panel-17-mixer
/dev/snd/controlC2:  andy       1816 F.... panel-17-mixer

Can you advise me on how to proceed?

Regards,

Andy

Last edited by andy_0 (2013-04-10 12:45:45)

Offline

#2 2013-04-10 05:28:20

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

Re: [Solved] Alsa, no simultaneous sound; Asus Xonar D2X

Your "default" PCM, which is the standard 2-speaker output, is outputting straight to hardware, not going through dmix first.

See config in my sig.

Offline

#3 2013-04-10 11:45:53

andy_0
Member
Registered: 2013-04-10
Posts: 15

Re: [Solved] Alsa, no simultaneous sound; Asus Xonar D2X

Thanks for your help. I copied your basic configuration and changed it to my needs. It's working fine now.

Offline

#4 2013-04-10 12:35:07

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: [Solved] Alsa, no simultaneous sound; Asus Xonar D2X

andy_0 wrote:

It's working fine now.

That's great. Please mark this thread as [solved] so that others with a similar issue may know a solution is here. Thanks.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#5 2013-04-10 12:51:40

andy_0
Member
Registered: 2013-04-10
Posts: 15

Re: [Solved] Alsa, no simultaneous sound; Asus Xonar D2X

Done.

For completeness, here my current /etc/asound.conf:

pcm.dmixed {
	type asym
	playback.pcm {
		# See plugin:dmix at http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
		type dmix

		# Don't block other users
		# http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
		ipc_key_add_uid true

		ipc_key 5678293
		ipc_perm 0660
		ipc_gid audio

		# Don't put the rate here! Otherwise it resets the rate & channels set below, as shown by:  cat /proc/asound/card0/pcm0p/sub0/hw_params
		slave {
			# 2 for stereo, 6 for surround51
			channels 2
			pcm {
				# mplayer chooses S32_LE, but others usually S16_LE
				#format S16_LE
				format S32_LE

				# 44100 or 48000
				# 44100 for music, 48000 is compatible with most h/w
				#rate 44100
				rate 48000

				# http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
				# Maybe helps
				nonblock true

				type hw
				card D2X
				device 0
				subdevice 0
			}

			# mplayer2 chooses 1024
			# period_size 512 with buffer_size 16384 stops crackling in xmame
			# 320 breaks flash - https://bbs.archlinux.org/viewtopic.php?id=129458
			#period_size 512
			period_size 1024
			# 2730 is chosen by "speaker-test"
			#period_size 512
			#period_time 20000
			#periods 8

			# 4096 makes Thief 1 in wine crackle.
			# mplayer2 chooses 8192
			#buffer_size 5460
			# 5460 (2730*2) is too small for mplayer2
			# If too large, use CONFIG_SND_HDA_PREALLOC_SIZE=2048
			buffer_size 8192
			#buffer_size 4096
			#buffer_time 682667  # 32768 samples at 48 kHz, in µs
			# 16384 seems best to stop crackling in Skype
			#buffer_size 16384

			# Seems good
			#period_size 256
			#periods 16
			#buffer_size 16384

			# Old config
			#buffer_size 10240
			#period_size 2048

			# Other options to maybe play with:
			#period_time 2
			#periods 2
		}

		bindings {
			0 0
			1 1
			2 2
			3 3
			4 4
			5 5
		}

	capture.pcm "hw:D2X"
}

# Lunar Linux:  lin ladspa-bs2b
# listplugins
# analyseplugin bs2b
pcm.bs2b {
	type ladspa
	path "/usr/lib/ladspa"
	plugins {
		0 {
			id 4221  # Bauer stereophonic-to-binaural (4221/bs2b)
			input {
				controls [ 700 6 ]
			}
		}
	}
	# http://bbs.archlinux.org/viewtopic.php?id=95582
	slave.pcm "plug:dmixed"
}


# http://quitte.de/dsp/caps.html#Narrower  from caps-plugins
# Alternative to bs2b, for music via headphones
# analyseplugin caps | grep -A14 Narrow
pcm.narrower {
	type ladspa
	path "/usr/lib/ladspa"
	plugins {
		0 {
			id 2595  # Narrower - Stereo image width reduction
			input {
				controls [ 0 0.25 ]
			}
		}
	}
	slave.pcm "plug:dmixed"
}


# speaker-test -D headphones -c 2 -t wav
# audacious uses less CPU when running bs2b as a listed plugin, probably because of samplerate_best
# Posted at http://bbs.archlinux.org/viewtopic.php?pid=626573#p626573
pcm.headphones {
	type rate
	slave {
		pcm "plug:bs2b"
		#pcm "plug:narrower"
		#rate 44100
		rate 48000
	}
	# Choices: samplerate_best samplerate_medium samplerate samplerate_order samplerate_linear
	converter "samplerate_medium"

    hint {
        show on
        description "Headphones"
    }
}

@ brebs
I have an additional question. Can you tell me how to use the asound.conf special configuration e.g. for headphones (pcm.headphones) within an application?

Offline

#6 2013-04-10 13:06:57

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

Re: [Solved] Alsa, no simultaneous sound; Asus Xonar D2X

Can remove that "bindings" entry, it's unnecessary - I've removed it from my copy.

To use a custom PCM within an app, configure the app. This being Wild-West Linux, the configuration file is different for each app. E.g. for the cmus music player:

set dsp.alsa.device=headphones

Offline

#7 2013-04-22 19:52:43

andy_0
Member
Registered: 2013-04-10
Posts: 15

Re: [Solved] Alsa, no simultaneous sound; Asus Xonar D2X

Hey brebs,

I encountered another issue. Maybe you can help. Alsa got updated to v1.0.27 with Arch Linux today (repository date 2013-04-12). No sound is played anymore. When I try to use ALSA commands such as "alsamixer" or "aplay -l" I get the following error message:

ALSA lib conf.c:1686:(snd_config_load1) _toplevel_:163:0:Unexpected char
ALSA lib conf.c:3406:(config_file_open) /etc/asound.conf may be old or corrupted: consider to remove or fix it
ALSA lib conf.c:3328:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid argument
ALSA lib conf.c:3777:(snd_config_update_r) hooks failed, removing configuration

For "aplay -l" I get the error message for every sound card:

**** List of PLAYBACK Hardware Devices ****
ALSA lib conf.c:1686:(snd_config_load1) _toplevel_:66:0:Unexpected char
ALSA lib conf.c:3406:(config_file_open) /etc/asound.conf may be old or corrupted: consider to remove or fix it
ALSA lib conf.c:3328:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid argument
ALSA lib conf.c:3777:(snd_config_update_r) hooks failed, removing configuration
aplay: device_list:277: control open (0): Invalid argument
ALSA lib conf.c:1686:(snd_config_load1) _toplevel_:66:0:Unexpected char
ALSA lib conf.c:3406:(config_file_open) /etc/asound.conf may be old or corrupted: consider to remove or fix it
ALSA lib conf.c:3328:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid argument
ALSA lib conf.c:3777:(snd_config_update_r) hooks failed, removing configuration
aplay: device_list:277: control open (1): Invalid argument
ALSA lib conf.c:1686:(snd_config_load1) _toplevel_:66:0:Unexpected char
ALSA lib conf.c:3406:(config_file_open) /etc/asound.conf may be old or corrupted: consider to remove or fix it
ALSA lib conf.c:3328:(snd_config_hooks_call) function snd_config_hook_load returned error: Invalid argument
ALSA lib conf.c:3777:(snd_config_update_r) hooks failed, removing configuration
aplay: device_list:277: control open (2): Invalid argument

lspci | grep Audio

00:14.2 Audio device: Advanced Micro Devices [AMD] nee ATI SBx00 Azalia (Intel HDA) (rev 40)
01:00.1 Audio device: Advanced Micro Devices [AMD] nee ATI Barts HDMI Audio [Radeon HD 6800 Series]
03:04.0 Multimedia audio controller: C-Media Electronics Inc CMI8788 [Oxygen HD Audio]

lsmod | grep snd

snd_hda_codec_hdmi     27857  1 
snd_hda_codec_realtek    62279  1 
snd_virtuoso           33414  0 
snd_oxygen_lib         29853  1 snd_virtuoso
snd_mpu401_uart         5851  1 snd_oxygen_lib
snd_rawmidi            18742  1 snd_mpu401_uart
snd_hda_intel          33946  0 
snd_seq_device          5180  1 snd_rawmidi
snd_hda_codec         101474  3 snd_hda_codec_realtek,snd_hda_codec_hdmi,snd_hda_intel
snd_hwdep               6364  1 snd_hda_codec
snd_pcm                76956  4 snd_hda_codec_hdmi,snd_oxygen_lib,snd_hda_codec,snd_hda_intel
snd_page_alloc          7298  2 snd_pcm,snd_hda_intel
snd_timer              18687  1 snd_pcm
snd                    58893  12 snd_hda_codec_realtek,snd_hwdep,snd_timer,snd_hda_codec_hdmi,snd_pcm,snd_rawmidi,snd_virtuoso,snd_oxygen_lib,snd_hda_codec,snd_hda_intel,snd_mpu401_uart,snd_seq_device
soundcore               5418  1 snd

/etc/asound.conf.

pcm.dmixed {
	type asym
	playback.pcm {
		# See plugin:dmix at http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
		type dmix

		# Don't block other users
		# http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
		ipc_key_add_uid true

		ipc_key 5678293
		ipc_perm 0660
		ipc_gid audio

		slave {
			# 2 for stereo, 6 for surround51
			channels 2
			pcm {
				# mplayer chooses S32_LE, but others usually S16_LE
				format S32_LE

				# 44100 or 48000
				# 44100 for music, 48000 is compatible with most h/w
				#rate 44100
				rate 48000

				# http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html
				# Maybe helps
				nonblock true

				type hw
				card D2X
				device 0
				subdevice 0
			}

			# mplayer2 chooses 1024
			# period_size 512 with buffer_size 16384 stops crackling in xmame
			# 320 breaks flash - https://bbs.archlinux.org/viewtopic.php?id=129458
			#period_size 512
			period_size 1024
			# 2730 is chosen by "speaker-test"
			#period_size 512
			#period_time 20000
			#periods 8

			# mplayer2 chooses 8192
			# 5460 (2730*2) is too small for mplayer2
			# If too large, use CONFIG_SND_HDA_PREALLOC_SIZE=2048
			buffer_size 8192
			#buffer_size 4096
			#buffer_time 682667  # 32768 samples at 48 kHz, in µs
		}

		bindings {
			0 0
			1 1
			2 2
			3 3
			4 4
			5 5
		}

	capture.pcm "hw:D2X"
}

As far as I can tell the system outputs are correct. So I guess the issue "should" be located within the /etc/asound.conf.

Offline

#8 2013-04-22 20:58:06

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

Re: [Solved] Alsa, no simultaneous sound; Asus Xonar D2X

Looks like you're missing a closing bracket for the playback.pcm line. To be added before the capture.pcm line.

Offline

#9 2013-04-22 21:20:22

mich41
Member
Registered: 2012-06-22
Posts: 796

Re: [Solved] Alsa, no simultaneous sound; Asus Xonar D2X

Unless you really need these buffer/period tricks, your asoundrc is pretty much equivalent to the following:

defaults.pcm.dmix.format "S32_LE"

pcm.default "sysdefault:D2X"

Offline

#10 2013-04-22 21:40:14

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

Re: [Solved] Alsa, no simultaneous sound; Asus Xonar D2X

mich41 wrote:

Unless you really need these buffer/period tricks

They are specified, basically to ensure that they are sensible.

Offline

#11 2013-04-23 09:46:30

andy_0
Member
Registered: 2013-04-10
Posts: 15

Re: [Solved] Alsa, no simultaneous sound; Asus Xonar D2X

@ mich41
Yes, the config is extensive but it shouldn't hurt.

@ brebs
It really was the bracket. That's odd as I didn't change anything. Alsa either somewhat removed their resilience for a malformed configuration file or something removed the bracket.

Offline

Board footer

Powered by FluxBB