thommy
Posts: 12
Joined: Sun Mar 17, 2013 11:29 pm

ALSA problems [SOLVED]

Sun Mar 17, 2013 11:36 pm

I'm setting up MPD to stream music from my NAS to a USB sound card.

That bit was fairtly straightforward:

Install Raspbian
Install ALSA
Install MPD
mount network share at boot using fstab
configure MPD

...and for a few hours today I had the perfect audio streamer. Until I rebooted.

MPD can no longer open the audio device and so is stuck in 'Paused' mode.
Typing 'alsamixer' at the prompt gives "cannot open mixer: No such file or directory"

Typing 'aplay -l' gives:

"**** List of PLAYBACK Hardware Devices ****
card 1: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0"

both root and my own account are members of the 'audio' group

It's been 5 hours sf stress trying to work out what changed after the reboot and I'm now at a loss!
Last edited by thommy on Mon Mar 18, 2013 9:30 pm, edited 1 time in total.

ski522
Posts: 394
Joined: Sun Sep 30, 2012 2:22 pm

Re: ALSA problems

Mon Mar 18, 2013 11:16 am

[quote="thommy"]
"**** List of PLAYBACK Hardware Devices ****
card 1: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0"[/quote]

This indicates that your card is set to device 1, therefore in your "/etc/mpd.conf" file do you have the following (or something similar)?
[code]# An example of an ALSA output:
#
audio_output {
type "alsa"
name "My ALSA Device"
device "hw:1,0" # optional
format "44100:16:2" # optional
mixer_device "default" # optional
mixer_control "PCM" # optional
mixer_index "0" # optional
}
[/code]
Specifically this line [quote]device "hw:1,0" # optional[/quote]

If you want to default your USB sound card to device 0 then "sudo nano /etc/modprobe.d/alsa-base.conf" and change the "options snd-usb-audio index=0", reboot.

thommy
Posts: 12
Joined: Sun Mar 17, 2013 11:29 pm

Re: ALSA problems

Mon Mar 18, 2013 11:30 am

Hi.

Thanks for taking the time to look at this. I have scoured the web and as yet found nothing relating directly to this issue.
"**** List of PLAYBACK Hardware Devices ****
card 1: Set [C-Media USB Headphone Set], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0"
This shows that there is only 1 device, but that it's on hw:0,0

The problem isn't within MPD because the alsa mixer wont load and sound-test produces nothing.

When trying to play in MPD I get this:

Code: Select all

mpc play
AFL - Smoke Sessions Vol. 16
[paused]  #1/24   0:00/55:08 (0%)
volume: n/a   repeat: off   random: off   single: off   consume: off
ERROR: problems opening audio device
When trying to load the alsamixer I get this:

Code: Select all

alsamixer
cannot open mixer: No such file or directory
I get these messages when logged into as both root and my user account.

I have checked alsa.conf settings but this now seems to be deprecated as devices are detected automatically.

Cloudcentric
Posts: 982
Joined: Fri Sep 14, 2012 9:13 am

Re: ALSA problems

Mon Mar 18, 2013 6:14 pm

Sound output by default will by either HDMI or Audio Out Jack, and by default it will auto-detect,:

HDMI output:
sudo modprobe snd_bcm2835
sudo amixer cset numid=3 2

Audio Jack output:
sudo modprobe snd_bcm2835
sudo amixer cset numid=3 1

Autodetect output:
sudo modprobe snd_bcm2835
sudo amixer cset numid=3 0

http://blog.scphillips.com/2013/01/soun ... -with-alsa
Last edited by Cloudcentric on Mon Mar 18, 2013 6:56 pm, edited 1 time in total.
I know everything about nothing"

thommy
Posts: 12
Joined: Sun Mar 17, 2013 11:29 pm

Re: ALSA problems

Mon Mar 18, 2013 6:26 pm

Thanks.

You seem to be suggesting that I buy another soundcard however this one works fine as proved on the afternoon after installation (and before reboot) when i was playing a variety of hi res audio files.

It's being detected as hw:0,0 i.e. default (because i haven't added the sound drivers for the pi onboard audio). Therefore the link you provide is not helpful because it states in the first few paragraphs to look elsewhere if using a USB audio device.

The modprobe commands do not help either because I am not trying to use either of the onboard audio devices and my post shows that when trying to run alsamixer i get the error 'No such file or directory' - which suggests it is a permissions issue (but I don't know that).

ski522
Posts: 394
Joined: Sun Sep 30, 2012 2:22 pm

Re: ALSA problems

Mon Mar 18, 2013 6:31 pm

No..."card 1" would indicate that it's card 1 not card 0 so it would "hw:1.0...for example here is what mine shows for aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: DAC [USB Audio DAC], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
Also, I find it odd that aplay -l isn't show the bcm2835 on-board sound card. Did you make the change in alsa-base.conf file I suggested? Not sure what you mean when you say you didn't load the onboard sound card drivers, did you remove them?

What happens when you run alsamixer -c 1 #for hw:1.0

Cloudcentric
Posts: 982
Joined: Fri Sep 14, 2012 9:13 am

Re: ALSA problems

Mon Mar 18, 2013 6:56 pm

USB Sound Card

sudo modprobe snd_bcm2835
sudo amixer cset numid=3 0

use Nano text editor to open alsa-base.conf, place a # in front of options snd-usb-audio index=-2

nano /etc/modprobe.d/alsa-base.conf
sudo reboot

http://www.jackenhack.com/raspberry-pi- ... y-problems
I know everything about nothing"

ski522
Posts: 394
Joined: Sun Sep 30, 2012 2:22 pm

Re: ALSA problems

Mon Mar 18, 2013 8:40 pm

Cloudcentric wrote:USB Sound Card

sudo modprobe snd_bcm2835
sudo amixer cset numid=3 0

use Nano text editor to open alsa-base.conf, place a # in front of options snd-usb-audio index=-2

nano /etc/modprobe.d/alsa-base.conf
sudo reboot

http://www.jackenhack.com/raspberry-pi- ... y-problems
No, the OP wants the USB sound card to be default or index 0, you instructions would make always default to index 1.

Cloudcentric
Posts: 982
Joined: Fri Sep 14, 2012 9:13 am

Re: ALSA problems

Mon Mar 18, 2013 8:45 pm

Yep I missed a line out...............

http://www.jackenhack.com/raspberry-pi- ... y-problems

The trick to make the card work is to edit the file /etc/modprobe.d/alsa-base.conf and comment out the line:

options snd-usb-audio index=-2
with
#options snd-usb-audio index=-2

and add this line at the end.

options snd-usb-audio nrpacks=1

This forces the USB device to become the default audio output device. The added line removes a lot of debugging info getting written to the syslog file, filling it up with lines like these.................................................................
I know everything about nothing"

thommy
Posts: 12
Joined: Sun Mar 17, 2013 11:29 pm

Re: ALSA problems

Mon Mar 18, 2013 9:29 pm

Thanks guys, it's working now.

shrikantetc
Posts: 10
Joined: Mon Jul 17, 2017 5:54 am

Re: ALSA /var/lib/alsa/asound.state after REBOOT restore to default

Mon Sep 25, 2017 6:43 am

Hi,

I am using Raspberry Pi model b board. Raspbian Jessie

Whenever I am making some changes in /var/lib/alsa/asound.state file.
After reboot, It is resetting to default again.

Why does this happen?

I am using alsamixer to changed parameter.
But that changes are also not getting reflected on reboot.


Thanks,
Shrikant

soodvarun78
Posts: 5
Joined: Fri Aug 04, 2017 9:21 am
Contact: Skype

Re: ALSA problems [SOLVED]

Mon Sep 25, 2017 10:21 am

Persisting in file asound.state is handled using systemd unit files on startup and shutdown
Unit file alsa-restore.service is called on startup
Unit file alsa-store.service is called on shutdown
The unit files uses alsactl utility for this ...
Please verify that unit files are getting called at startup and shutdown.

Also you can verify by running explicitly through command line
1. alsamixer
2. change some setting
3. store the setting in asound.state using
sudo alsactl store
4. The change should be stored in asound.state. Verify change in asound.state by opening it
5. Restart system if the change is not getting reflected, some problem with Unit files.

Return to “Raspbian”

Who is online

Users browsing this forum: No registered users and 10 guests