You are not logged in.

#1 2008-12-08 09:39:59

orjanp
Member
From: Tromsoe, Norway
Registered: 2004-07-03
Posts: 347

"Restart" sound device.

Hello!

Is there an easy way to "restart" my sound device without needing to reboot my machine?

For some reason I often get the following error:

[~]$ mpd
ALSA lib pcm_dmix.c:1008:(snd_pcm_dmix_open) unable to open slave
No audio_output specified and unable to detect a default audio output device

I guess something is blocking my sound device.


Ørjan Pettersen

Offline

#2 2008-12-08 09:49:22

r6
Member
From: Melbourne
Registered: 2008-07-02
Posts: 156

Re: "Restart" sound device.

sudo /etc/rc.d/alsa restart

Offline

#3 2008-12-08 10:06:13

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: "Restart" sound device.

Do you have MPD configured to use the device?

See the part below in your mpd.conf, where you can specifically set a device (hw:x:x) in case MPD can't find an output by itself:

#audio_output {
#        type                    "alsa"
#        name                    "My ALSA Device"
#        device                  "hw:0,0"     # optional
#        format                  "44100:16:2" # optional
#}

It could also be that you have to create an .asoundrc file. Though ALSA usually doesn't require one anymore there might be a legacy program on your system that needs it, to prevent it from claiming the device exclusively. More information about that here: http://alsa.opensrc.org/.asoundrc

Last you can try installing OSS4 instead of ALSA, which generally handles multiple audio streams better: http://wiki.archlinux.org/index.php/OSS


ᶘ ᵒᴥᵒᶅ

Offline

#4 2008-12-08 12:19:55

orjanp
Member
From: Tromsoe, Norway
Registered: 2004-07-03
Posts: 347

Re: "Restart" sound device.

MPD usually works fine. But sometimes it don't. A reboot does fix it.

Same goes for aplay <somefile>.

Doing a /etc/rc.d/alsa restart doesn't work.

I believe the problem is caused by another program  locking the sound exclusively. OSS would have been worth a try if it wasn't for my AC'97 sound.
So I guess i have a look at the .asoundrc thing.

I have tried to remove sound modules, but some modules can't be removed because they are in use. Even if it isn't indicated that it is in use when doing a lsmod

[~]# lsmod | grep snd
snd_pcm_oss            40192  1 
snd_mixer_oss          16512  1 snd_pcm_oss
snd_intel8x0           30748  1 
snd_ac97_codec        100516  1 snd_intel8x0
ac97_bus                3584  1 snd_ac97_codec
snd_pcm                69636  3 snd_pcm_oss,snd_intel8x0,snd_ac97_codec
snd_timer              21384  1 snd_pcm
snd                    50724  6 snd_pcm_oss,snd_mixer_oss,snd_intel8x0,snd_ac97_codec,snd_pcm,snd_timer
soundcore               8160  2 snd
snd_page_alloc          9224  2 snd_intel8x0,snd_pcm
[~]# rmmod snd_intel8x0
ERROR: Module snd_intel8x0 is in use

Thanks.

Last edited by orjanp (2008-12-08 12:44:05)


Ørjan Pettersen

Offline

#5 2008-12-08 13:49:17

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: "Restart" sound device.

OSS4 should be able to work fine with i8x0 AC97 afaik?

And please say hi to Geir Jenssen for me when you see him! smile


ᶘ ᵒᴥᵒᶅ

Offline

#6 2008-12-08 13:53:49

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: "Restart" sound device.

All you should have to do is unload any sound modules in use and then reload them. Gentoo has a script for this, perhaps I'll try to port it.

Offline

#7 2008-12-08 14:08:49

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: "Restart" sound device.

Ok, here is the gentoo alsa initscript... Look at the terminate() function, it should do what you want.

Offline

#8 2008-12-09 14:44:14

hk2717
Member
From: China
Registered: 2007-09-13
Posts: 217

Re: "Restart" sound device.

I have the same problem. Sometimes the sound just lock up. Sadly the above script does not seems to work either.

Edit: typo.

Last edited by hk2717 (2008-12-09 14:45:16)

Offline

#9 2008-12-09 17:56:03

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: "Restart" sound device.

You're not supposed to run it as a script. I just provided it as an example.

Offline

#10 2008-12-09 18:07:17

skottish
Forum Fellow
From: Here
Registered: 2006-06-16
Posts: 7,942

Re: "Restart" sound device.

Out of curiosity, for the people that sometimes things are working and sometimes they're not, do you have alsa, oss, mpd, network, and such, backgrounded in the daemons array in rc.conf? From my experience, sometimes things start faster than others. In the case of mpd for example, if it tries to start before everything it needs does, it will happily fail and you won't know about it until you try to use it.

Offline

#11 2008-12-09 18:21:49

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: "Restart" sound device.

r6 wrote:

sudo /etc/rc.d/alsa restart

For future reference, that will never have any effect on any sound devices.  Read the script.


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#12 2008-12-10 02:38:19

hk2717
Member
From: China
Registered: 2007-09-13
Posts: 217

Re: "Restart" sound device.

skottish wrote:

Out of curiosity, for the people that sometimes things are working and sometimes they're not, do you have alsa, oss, mpd, network, and such, backgrounded in the daemons array in rc.conf? From my experience, sometimes things start faster than others. In the case of mpd for example, if it tries to start before everything it needs does, it will happily fail and you won't know about it until you try to use it.

Exactly. I once have all the daemons starting in the background but now I find that it is definitely not the best practice. However, my current problem is the sound suddenly dies during daily use.

Someone please provide a usable script! For I am a programming noob.:( Rebooting every couple of hours is so annoying! Even Windows is more stable than this.:|

Offline

#13 2008-12-10 02:46:30

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: "Restart" sound device.

Take a look at the gentoo alsa rc script.  It is more functional than the our alsa daemon and will give you the commands you need.


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#14 2008-12-10 10:07:04

orjanp
Member
From: Tromsoe, Norway
Registered: 2004-07-03
Posts: 347

Re: "Restart" sound device.

litemotiv wrote:

OSS4 should be able to work fine with i8x0 AC97 afaik?

And please say hi to Geir Jenssen for me when you see him! smile

That is true, despite the fact that the WIKI says that AC'97 sound isn't supported. So I installed OSS4. Time will show if this is a working solution.

It was often Firefox and flash videos that blocked my sound. A restart of Firefox often fixed that. Flash was the bad apple here.

Will do. smile

Daenyth wrote:

Ok, here is the gentoo alsa initscript... Look at the terminate() function, it should do what you want.

Had a look at it, but since OSS4 works fine for now, I went for that solution.

skottish wrote:

Out of curiosity, for the people that sometimes things are working and sometimes they're not, do you have alsa, oss, mpd, network, and such, backgrounded in the daemons array in rc.conf? From my experience, sometimes things start faster than others. In the case of mpd for example, if it tries to start before everything it needs does, it will happily fail and you won't know about it until you try to use it.

Good point. But I start mpd manually after login.

rson451 wrote:
r6 wrote:

sudo /etc/rc.d/alsa restart

For future reference, that will never have any effect on any sound devices.  Read the script.

Just what I thought to, but I wasn't entirely sure.

Thanks for all the help and pointers. As of now, my sound is working fine with OSS4.


Ørjan Pettersen

Offline

#15 2008-12-11 03:43:01

mintcoffee
Member
From: Waterloo, ON
Registered: 2007-10-05
Posts: 120
Website

Re: "Restart" sound device.

Well occasionally you'll need to kill a program that's hogging the audio device. Execute 'lsof /dev/snd/* /dev/dsp' to see which programs are using the audio device and kill any that you think might be causign the problem.


Arch on a Thinkpad T400s

Offline

#16 2008-12-11 17:14:48

anrxc
Member
From: Croatia
Registered: 2008-03-22
Posts: 834
Website

Re: "Restart" sound device.

fuser can also be used, which is more likely to be installed since it's in core (psmisc).


You need to install an RTFM interface.

Offline

Board footer

Powered by FluxBB