You are not logged in.

#1 2014-10-09 17:45:43

Sputnik83
Member
Registered: 2014-10-09
Posts: 5

USB-Speakers wont work with ALSA

Hi all,
first of all, this is a cross-post from the german forum.

Well, its hard for me to ask this in english, my skills are verry poor. So please be a bit patient. In case you could help me i would be realy glad if you could write down your answers in "easy to understand" english. Thank you wink
Also my Linux skills aren't very good hmm

Lets go:

My USB-Speakers (Edifiier R600 USB) wont work with ALSA.
Pulseaudio made me a lot of trouble too with this speakers and sadly i (and the german forum) couldnt find a solution that for.

I dont even know, why they wont work...

So all i can do now is give you as much data as possible.
If you need any further informations please just ask me.

Thank you for your support!

Dearest Sputti

nano /etc/modprobe.d/alsa-base.conf
options snd_usb_audio index=0 model=auto vid=1002 pid=4383
options snd_hda_intel index=1 model=auto vid=8086 pid=284b
 cat /proc/asound/modules
 0 snd_usb_audio
 1 snd_hda_intel
lsmod | grep snd
snd_hda_codec_idt      56908  1 
snd_hda_codec_hdmi     45117  1 
snd_hda_codec_generic    63126  2 snd_hda_codec_idt
snd_usb_audio         135316  0 
snd_usbmidi_lib        27484  1 snd_usb_audio
snd_rawmidi            26806  1 snd_usbmidi_lib
snd_seq_device         13132  1 snd_rawmidi
snd_hda_intel          26327  0 
snd_hda_controller     26727  1 snd_hda_intel
snd_hda_codec         108552  5 snd_hda_codec_hdmi,snd_hda_codec_idt,snd_hda_codec_generic,snd_hda_intel,snd_hda_controller
snd_hwdep              17244  2 snd_usb_audio,snd_hda_codec
snd_pcm                88487  5 snd_usb_audio,snd_hda_codec_hdmi,snd_hda_codec,snd_hda_intel,snd_hda_controller
snd_timer              26614  1 snd_pcm
snd                    69340  12 snd_usb_audio,snd_hwdep,snd_timer,snd_hda_codec_hdmi,snd_hda_codec_idt,snd_pcm,snd_rawmidi,snd_hda_codec_generic,snd_usbmidi_lib,snd_hda_codec,snd_hda_intel,snd_seq_device
soundcore              13031  2 snd,snd_hda_codec
usbcore               199328  8 btusb,uhci_hcd,snd_usb_audio,uvcvideo,snd_usbmidi_lib,ehci_hcd,ehci_pci,usbhid
ls -l /dev/snd
insgesamt 0
drwxr-xr-x  2 root root       60 Oct  9 18:50 by-id
drwxr-xr-x  2 root root       80 Oct  9 18:50 by-path
crw-rw----+ 1 root audio 116,  2 Oct  9 18:50 controlC0
crw-rw----+ 1 root audio 116,  4 Oct  9 18:50 controlC1
crw-rw----+ 1 root audio 116, 10 Oct  9 18:50 hwC1D0
crw-rw----+ 1 root audio 116, 11 Oct  9 18:50 hwC1D1
crw-rw----+ 1 root audio 116, 12 Oct  9 18:50 hwC1D2
crw-rw----+ 1 root audio 116,  3 Oct  9 18:50 pcmC0D0p
crw-rw----+ 1 root audio 116,  7 Oct  9 18:50 pcmC1D0c
crw-rw----+ 1 root audio 116,  6 Oct  9 19:11 pcmC1D0p
crw-rw----+ 1 root audio 116,  8 Oct  9 18:50 pcmC1D1p
crw-rw----+ 1 root audio 116,  9 Oct  9 18:50 pcmC1D2c
crw-rw----+ 1 root audio 116,  5 Oct  9 18:50 pcmC1D3p
crw-rw----+ 1 root audio 116,  1 Oct  9 18:50 seq
crw-rw----+ 1 root audio 116, 33 Oct  9 18:50 timer
lspci -nn | grep -i audio
00:1b.0 Audio device [0403]: Intel Corporation 82801H (ICH8 Family) HD Audio Controller [8086:284b] (rev 02)
 lsusb
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 005: ID 0a5c:4503 Broadcom Corp. Mouse (Boot Interface Subclass)
Bus 007 Device 004: ID 0a5c:4502 Broadcom Corp. Keyboard (Boot Interface Subclass)
Bus 007 Device 003: ID 413c:8126 Dell Computer Corp. Wireless 355 Bluetooth
Bus 007 Device 002: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 002: ID 18c3:6255  
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 05a9:2640 OmniVision Technologies, Inc. OV2640 Webcam
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
 aplay -l
**** Liste der Hardware-Geräte (PLAYBACK) ****
Karte 0: Device [USB Audio Device], Gerät 0: USB Audio [USB Audio]
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0
Karte 1: Intel [HDA Intel], Gerät 0: STAC9228 Analog [STAC9228 Analog]
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0
Karte 1: Intel [HDA Intel], Gerät 1: STAC9228 Digital [STAC9228 Digital]
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0
Karte 1: Intel [HDA Intel], Gerät 3: HDMI 0 [HDMI 0]
  Sub-Geräte: 1/1
  Sub-Gerät #0: subdevice #0
dmesg
[ 3151.843387] usb 5-2: USB disconnect, device number 2
[ 3156.603138] usb 5-2: new full-speed USB device number 3 using uhci_hcd
[ 3156.816796] input: Elite Silicon USB Audio Device as /devices/pci0000:00/0000:00:1d.0/usb5/5-2/5-2:1.2/0003:18C3:6255.0004/input/input38
[ 3156.817218] hid-generic 0003:18C3:6255.0004: input,hidraw0: USB HID v1.00 Device [Elite Silicon USB Audio Device] on usb-0000:00:1d.0-2/input2

after unplug and replug USB-Speakers

nano /etc/udev/rules.d/00-local.rules
KERNEL=="pcmC[D0-9cp]*", ACTION=="add", PROGRAM="/usr/bin/sh -c 'K=%k; K=$${K#pcmC}; K=$${K%%D*}; echo defaults.ctl.card $$K > /etc/asound.conf; echo defaults$
KERNEL=="pcmC[D0-9cp]*", ACTION=="remove", PROGRAM="/usr/bin/sh -c 'echo defaults.ctl.card 0 > /etc/asound.conf; echo defaults.pcm.card 0 >>/etc/asound.conf'"

see here

Offline

#2 2014-10-09 19:42:45

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: USB-Speakers wont work with ALSA

What exactly have you tried? I suggest you to read the section of https://wiki.archlinux.org/index.php/Ad … chitecture concerning HDMI, I think it should be pretty similar for your USB speakers (both should be seen as alternative digital  sound cards). If it still doesn't work, repost with the output of the detail of what you have tried.  (don' forget to export LANG=C; export LC_ALL=C to turn the messages in English so we can understand them).

Offline

#3 2014-10-09 21:06:28

Sputnik83
Member
Registered: 2014-10-09
Posts: 5

Re: USB-Speakers wont work with ALSA

Well... I think i figgured something important out.

aplay -D plughw:0,0 /usr/share/sounds/alsa/Front_Center.wav
Wiedergabe: WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate: 48000 Hz, mono

work perfectly with the USB-Speakers!

That the embedded soundfile works well, made me think about the sound source.

I dont have any mp3 or other soundfiles on my Laptop.
All sound i get is from streaming (youtube or similar).
So i downloaded a song and tried playing it with VLC.

first i had my normal internal intel sound.
But i realized VLC has the option to spezify the audiodevice.
And woops i can pick USB-audio-device and it works well.

So i guess my Problem is realated to browser-embeded sounds. Like flashplayer. I use Chromium with Pepperflash, but had the same situation with firefox earlyer.

Is there a possibilty to fix this?

Guess we are on a good way hum?

Dearest Sputti

Offline

#4 2014-10-09 22:17:42

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: USB-Speakers wont work with ALSA

You must set the default audio device in the alsa configuration files via ~/.asoundrc (really read the HDMI section of the link I have provided). But what I find strange is that the default device is plughw:0,0 unless you have changed it in /etc/asound.conf or ~/.asoundrc. So if aplay -D plughw:0,0 /usr/share/sounds/alsa/Front_Center.wav
works, the USB should already be the default. I assume that pulseaudio is not running and there are no /etc/asoundconf or ~/.asoundrc. What happens if you aplay /usr/share/sounds/alsa/Front_Center.wav ?

Last edited by olive (2014-10-09 22:18:19)

Offline

#5 2014-10-09 23:28:06

Sputnik83
Member
Registered: 2014-10-09
Posts: 5

Re: USB-Speakers wont work with ALSA

olive wrote:

You must set the default audio device in the alsa configuration files via ~/.asoundrc (really read the HDMI section of the link I have provided)

Well, i try, but couldnt make it work jet...

olive wrote:

But what I find strange is that the default device is plughw:0,0 unless you have changed it in /etc/asound.conf or ~/.asoundrc.

well i dont think i did..

/etc/asound.conf
defaults.ctl.card 1
defaults.pcm.card 1
defaults.pcm.card 1
defaults.pcm.card 1

~/.asoundrc is empty

olive wrote:

So if aplay -D plughw:0,0 /usr/share/sounds/alsa/Front_Center.wav
works, the USB should already be the default.

USB is default i guess. Set it up here:

/etc/modprobe.d/alsa-base.conf
options snd_usb_audio index=0 model=auto
options snd_hda_intel index=-2 model=auto vid=8086 pid=284b
olive wrote:

I assume that pulseaudio is not running and there are no /etc/asoundconf or ~/.asoundrc.

/etc/asoundconf is empty as far you don't mean /etc/asound.conf so see at top.

i deinstalled Pulsaudio cause i had a lot of trouble with...

olive wrote:

What happens if you aplay /usr/share/sounds/alsa/Front_Center.wav ?

aplay /usr/share/sounds/alsa/Front_Center.wav
Playing WAVE '/usr/share/sounds/alsa/Front_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
aplay: set_params:1239: Channels count non available

no sound...

Offline

#6 2014-10-10 06:18:50

olive
Member
From: Belgium
Registered: 2008-06-22
Posts: 1,490

Re: USB-Speakers wont work with ALSA

Of course, I meant /etc/asound.conf. In your case, this file point to the the card nr: 1 changing the default which was card nr 0 (your USB speaker). So this file is telling the system not to use the USB speakers as default, exactly the opposite of what you want. Normally this file should not be present (maybe a remnant of pulseaudo ?). Remove that file and everything should work.

To have a clean system, be sure to uninstall pulseaudio-alsa if you have it and do a

pacman -Qo /etc/asound.conf

to be sure no package claim this file.

You can also read the HDMI section of the alsa configuration in the Gentoo wiki that bring additional informations: http://wiki.gentoo.org/wiki/ALSA

Last edited by olive (2014-10-10 07:23:57)

Offline

#7 2014-10-10 08:42:24

Sputnik83
Member
Registered: 2014-10-09
Posts: 5

Re: USB-Speakers wont work with ALSA

Well... i get it to work last night with:

~/.asoundrc                                                                               

pcm.!default {
    type hw
    card 0
}

ctl.!default {
    type hw
    card 0
}

and:

/etc/asound.conf
defaults.ctl.card 1
defaults.pcm.card 1
defaults.pcm.card 1
defaults.pcm.card 1

as far i understand, my system defines card0 as default, while /etc/asound.conf set it back to card1 and finaly ~/.asoundrc set it back to 0 again.
So i should be able to delete both files and have card0 as default right?
Or should i keep my ~/.asoundrc for any reasons?

/Edit: well delete both semms to work!
/Edit2: wupps nope! I need ~/.asoundrc for working USB-Device.

I uninstalled pulseaudio-alsa together with pulseaudio.


So this was 80% of the Problem. I have sound i am happy!
Btw: Thank you a lot that for!

Well: this is a laptop!
Sometimes i want take it with me and i dont think i want to carry the USB-speakes to university wink

So what i need is a possibility to set the USB-speakers just as default, if they are pluged to the laptop.

Is there any possibility that for?

Now, if i remove USB-speakers from USB-port i dont have any sound.
if i replug them flash stops and i have to reload the page.

For sure, i would prefere a automatic way, but i would be glad enough if there is a manually way to switch sound output to the internal card before unpluging the USB-speakers.

Right now, it seems i have to reboot evry time i want to switch sound output. This seems not very handy!

/Edit3:
So i figured something out:

First of all, I need ~/.asoundrc liek this:

pcm.!default {
    type hw
    card 1
}

ctl.!default {
    type hw
    card 1
}

for working USB-speakers in Chromium

The udev-rule for USB-plug'n'play-behavioure (see first post/ last code-box) creats the /etc/asound.conf file.
and does what it should do. Change values in /etc/asound.conf file to USB when pluged and to internal when not pluged.
BUT this don't effect chromium-flash-sound.
So i need ~/.asoundrc what override the settings made by the udev-rule...

For testing i deleted the /etc/modprobe.d/alsa-base.conf. I thought it should be a bit overkill having a 3rd file where i define my standard output.
As far i can realize, this don't have any effect right now...

So what i need is a way to tell Chromium to accept the /etc/asound.conf or a udev script, that effect the ~/.asoundrc instead...

Last edited by Sputnik83 (2014-10-10 11:12:25)

Offline

Board footer

Powered by FluxBB