You are not logged in.

#1 2009-06-28 18:37:45

w1ntermute
Member
Registered: 2009-06-28
Posts: 146

Setting ALSA sound card system wide (rather than just in KDE)

Hi,

I've got an HTPC with an ATI Radeon HD 4350 graphics card running Arch x86. It has its own integrated sound card for outputting audio via HDMI, which is detected by ALSA as a separate device. I've managed to set it as the default audio device in KDE 4 (via System Settings). This allows applications such as Amarok and SMPlayer to properly output audio to the HD 4350's integrated sound card, but software such as Flash and MPlayer (from the command line) are still outputting audio to the motherboard's built-in sound card. How can I change this setting on a system-wide level? I've tried running alsaconf as root and adding

pcm.!default {
    type hw
    card 2
    device 3
}

to ~/.asoundrc; I got the card and device numbers from aplay:

[htpc@exia ~]$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: HDA Generic [HDA Generic]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: HDMI [HDA ATI HDMI], device 3: ATI HDMI [ATI HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Here is the output from MPlayer when I try to play a video, complete with errors regarding audio:

MPlayer UNKNOWN-4.4.0 (C) 2000-2009 MPlayer Team
137 audio & 296 video codecs
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing /tmp/FlashmvWXPy.
libavformat file format detected.
[flv @ 0xac7d250]skipping flv packet: type 18, size 294, flags 0
[lavf] Video stream found, -vid 0
[lavf] Audio stream found, -aid 1
VIDEO:  [H264]  854x480  0bpp  29.970 fps    0.0 kbps ( 0.0 kbyte/s)
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
==========================================================================
==========================================================================
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: confmisc.c:768:(parse_card) cannot find card '2'
[AO_ALSA] alsa-lib: conf.c:3513:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
[AO_ALSA] alsa-lib: confmisc.c:392:(snd_func_concat) error evaluating strings
[AO_ALSA] alsa-lib: conf.c:3513:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
[AO_ALSA] alsa-lib: confmisc.c:1251:(snd_func_refer) error evaluating name
[AO_ALSA] alsa-lib: conf.c:3513:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
[AO_ALSA] alsa-lib: conf.c:3985:(snd_config_expand) Evaluate error: No such file or directory
[AO_ALSA] alsa-lib: pcm.c:2211:(snd_pcm_open_noupdate) Unknown PCM default
[AO_ALSA] Playback open error: No such file or directory
[JACK] cannot open server
[AO SDL] Samplerate: 44100Hz Channels: Stereo Format s16le
[AO_ALSA] alsa-lib: confmisc.c:768:(parse_card) cannot find card '2'
[AO_ALSA] alsa-lib: conf.c:3513:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
[AO_ALSA] alsa-lib: confmisc.c:392:(snd_func_concat) error evaluating strings
[AO_ALSA] alsa-lib: conf.c:3513:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
[AO_ALSA] alsa-lib: confmisc.c:1251:(snd_func_refer) error evaluating name
[AO_ALSA] alsa-lib: conf.c:3513:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
[AO_ALSA] alsa-lib: conf.c:3985:(snd_config_expand) Evaluate error: No such file or directory
[AO_ALSA] alsa-lib: pcm.c:2211:(snd_pcm_open_noupdate) Unknown PCM default
[AO SDL] Unable to open audio: No available audio device
DVB card number must be between 1 and 4
AO: [null] 44100Hz 2ch s16le (2 bytes per sample)
Starting playback...
VDec: vo config request - 854 x 480 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
VO: [xv] 854x480 => 854x480 Planar YV12

Thanks!

Last edited by w1ntermute (2009-06-28 18:40:03)

Offline

#2 2009-06-29 22:56:38

whoops
Member
Registered: 2009-03-19
Posts: 891

Re: Setting ALSA sound card system wide (rather than just in KDE)

Do you use the motherboard sound-card? If not - did you try just turning it off in bios (or blacklisting the driver)?

Offline

#3 2009-07-02 18:11:14

w1ntermute
Member
Registered: 2009-06-28
Posts: 146

Re: Setting ALSA sound card system wide (rather than just in KDE)

whoops wrote:

Do you use the motherboard sound-card?

No.

whoops wrote:

If not - did you try just turning it off in bios (or blacklisting the driver)?

No, I haven't tried that. I'll give it a shot. Thanks for the tip!

Last edited by w1ntermute (2009-07-02 18:11:53)

Offline

#4 2009-07-02 18:20:23

Odysseus
Member
Registered: 2009-02-15
Posts: 141

Re: Setting ALSA sound card system wide (rather than just in KDE)

The .asoundrc you first posted will work if you just change the card number to 1.

However, the best way to specify the default sound device in .asoundrc would look like this:

defaults.ctl.card 1
defaults.pcm.card 1
defaults.pcm.device 3

Otherwise only one application can use the card at a time (due to "type hw").


I'm the type to fling myself headlong through the magical wardrobe, and then incinerate the ornate mahogany portal behind me with a Molotov cocktail.

Offline

#5 2009-07-05 19:08:18

w1ntermute
Member
Registered: 2009-06-28
Posts: 146

Re: Setting ALSA sound card system wide (rather than just in KDE)

OK, now YouTube audio is working, but Hulu audio and MPlayer audio aren't. I don't see any error messages in MPlayer.

Offline

Board footer

Powered by FluxBB