Jump to content
Sign in to follow this  
Guest aus9-deactive

[SOLVED} How does a user restart Alsa without rebooting

Recommended Posts

Guest aus9

Hi

 

I am new to Bodhi. I have searched and posted to one kind user who knows a fair bit but no joy so started a new thread.

 

Now apparently in Ubuntu we have these 2 ways of restarting alsa?

 

http://nwlinux.com/restarting-alsa-sound-drivers-without-reboot-ubuntu/

 

Research my hard drive install 1.3.0 suggests:

 

(1) sudo /etc/init.d/alsa-utils restart

 

Must be an old link. Allegedly Bodhi uses upstart as no longer depends on init.d but looking into /etc/init and /etc/init.d I can find no such script

 

(2) sudo /sbin/alsa force-reload

 

sudo find / -name alsa
/usr/src/linux-headers-3.0.0-12-generic/include/config/thinkpad/acpi/alsa
/usr/share/sounds/alsa
/usr/share/alsa
/var/lib/alsa


file /usr/share/sounds/alsa/
/usr/share/sounds/alsa/: directory

file /usr/share/alsa/
/usr/share/alsa/: directory

file /var/lib/alsa/
/var/lib/alsa/: directory

 

3) Now I have been looking at upstart and apparently if the init exists you could try running

 

restart name etc

 

 

4) I do know how to reboot....but please I need to know how to restart alsa with out reboot

 

If no-one knows....well maybe I should report a bug as its not feature?

 

thanks for reading

 

Feel free to tell me or correct my research methods etc

Share this post


Link to post
Share on other sites
Guest aus9

research part 2

 

ok now we know that

 

cat /proc/asound/cards

(for me with one card its)
cat /proc/asound/cards
0 [intel          ]: HDA-Intel - HDA Intel

 

so looking at

 

alsactl --help
Usage: alsactl <options> command

Available global options:
 -h,--help        this help
 -d,--debug       debug mode
 -v,--version     print version of this program

Available state options:
 -f,--file #      configuration file (default /var/lib/alsa/asound.state)
 -F,--force       try to restore the matching controls as much as possible
                  (default mode)
 -g,--ignore      ignore 'No soundcards found' error
 -P,--pedantic    do not restore mismatching controls (old default)
 -I,--no-init-fallback
                  don't initialize even if restore fails
 -r,--runstate #  save restore and init state to this file (only errors)
                  default settings is 'no file set'
 -R,--remove      remove runstate file at first, otherwise append errors

Available init options:
 -E,--env #=#	   set environment variable for init phase (NAME=VALUE)
 -i,--initfile #  main configuation file for init phase (default /usr/share/alsa/init/00main)


Available commands:
 store   <card #> save current driver setup for one or each soundcards
                  to configuration file
 restore <card #> load current driver setup for one or each soundcards
                  from configuration file
 init	  <card #> initialize driver to a default state
 names   <card #> dump information about all the known present (sub-)devices
                  into configuration file (DEPRECATED)

 

so I am looking at that restore option lets try it...before going to bed

 


alsactl restore 0
root@945GCT-M2:/sbin# 

 

---> meaning no error reported but I had vlc playing and no sound skipped hmmmm

 


tail -n 4 /var/log/messages
Jan 10 21:26:04 945GCT-M2 kernel: [   15.181049] ppdev: user-space parallel port driver
Jan 10 21:26:04 945GCT-M2 kernel: [   15.187062] 8139too 0000:02:05.0: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
Jan 10 21:26:05 945GCT-M2 kernel: [   15.355646] zram: module is from the staging directory, the quality is unknown, you have been warned.
Jan 10 21:26:05 945GCT-M2 kernel: [   15.358120] zram: Creating 2 devices ...

 

 

nope it ain't happening for me too tired bed beckons

 

as does 20 aussie beach babes

Share this post


Link to post
Share on other sites
Guest aus9

hippytaff

 

Nice try but playing a sound and running pidof alsa returns no hits, for me.....YMMV

 

In the first link first post it suggested lsof | grep pcm and

 

lsof | grep pcm
vlc       1299     gordon  mem       REG        8,1    13612     221876 /usr/lib/vlc/plugins/codec/liblpcm_plugin.so
vlc       1299     gordon  mem       CHR      116,3                6124 /dev/snd/pcmC0D0p
vlc       1299     gordon   11r      CHR      116,3      0t0       6124 /dev/snd/pcmC0D0p

 

then I would run.....killall vlc......but I can't kill alsa and I still don't know how to restart alsa.

 

2) I am going to pinch a debian unpack of alsa-utils and play around with their /etc/init.d script....I will report but in the mean time.....please please tell me how to restart alsa.

Share this post


Link to post
Share on other sites

its

sudo alsa reload

its started during system boot so i doubt users can access it in anyway. else it would be a security leak.

Share this post


Link to post
Share on other sites
Guest aus9

research part 3

 

Not on bodhi atm but peeking at my old debian setup

 

hmm running /etc/init.d/alsa (action) causes no output to /var/log/messages......sorry to wasted space

 

2) The actual script /etc/init.d/alsa-utils in a code box for display purposes

 

#!/bin/sh
#
# alsa-utils initscript
#
### BEGIN INIT INFO
# Provides:          alsa-utils
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     S
# Default-Stop:      0 1 6
# Short-Description: Restore and store ALSA driver settings
# Description:       This script stores and restores mixer levels on
#                    shutdown and bootup.On sysv-rc systems: to
#                    disable storing of mixer levels on shutdown,
#                    remove /etc/rc[06].d/K50alsa-utils.  To disable
#                    restoring of mixer levels on bootup, rename the
#                    "S50alsa-utils" symbolic link in /etc/rcS.d/ to
#                    "K50alsa-utils".
### END INIT INFO

# Don't use set -e; check exit status instead

# Exit silently if package is no longer installed
[ -x /usr/sbin/alsactl ] || exit 0

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MYNAME=/etc/init.d/alsa-utils

. /lib/lsb/init-functions
. /usr/share/alsa/utils.sh

# $1 EXITSTATUS
# [$2 MESSAGE]
log_action_end_msg_and_exit()
{
log_action_end_msg "$1" ${2:+"$2"}
exit $1
}

# $1 PROGRAM
executable()
{
# If which is not available then we must be running before
# /usr is mounted on a system that has which in /usr/bin/.
# Conclude that $1 is not executable.
[ -x /bin/which ] || [ -x /usr/bin/which ] || return 1
which "$1" >/dev/null 2>&1
}

executable amixer || { echo "${MYNAME}: Error: No amixer program available." >&2 ; exit 1 ; }

# $1 <card ID> | "all"
restore_levels()
{
[ -f /var/lib/alsa/asound.state ] || return 1
CARD="$1"
[ "$1" = all ] && CARD=""
# Assume that if alsactl prints a message on stderr
# then it failed somehow.  This works around the fact
# that alsactl doesn't return nonzero status when it
# can't restore settings for the card
if MSG="$(alsactl restore $CARD 2>&1 >/dev/null)" && [ ! "$MSG" ] ; then
	return 0
else
	# Retry with the "force" option.  This restores more levels
	# but it results in much longer error messages.
	alsactl -F restore $CARD >/dev/null 2>&1
	log_action_cont_msg "warning: 'alsactl restore${CARD:+ $CARD}' failed with error message '$MSG'"
	return 1
fi
}

# $1 <card ID> | "all"
store_levels()
{
CARD="$1"
[ "$1" = all ] && CARD=""
if MSG="$(alsactl store $CARD 2>&1)" ; then
	sleep 1
	return 0
else
	log_action_cont_msg "warning: 'alsactl store${CARD:+ $CARD}' failed with error message '$MSG'"
	return 1
fi
}


# $1 <card ID>
mute_and_zero_levels_on_card()
{
CARDOPT="-c $1"
for CTL in \
	Master \
	PCM \
	Synth \
	CD \
	Line \
	Mic \
	"PCM,1" \
	Wave \
	Music \
	AC97 \
	"Master Digital" \
	DAC \
	"DAC,0" \
	"DAC,1" \
	Headphone \
	Speaker \
	Playback
do
	mute_and_zero_level "$CTL"
done
#	for CTL in \
#		"Audigy Analog/Digital Output Jack" \
#		"SB Live Analog/Digital Output Jack"
#	do
#		switch_control "$CTL" off
#	done
return 0
}

# $1 <card ID> | "all"
mute_and_zero_levels()
{
TTZML_RETURNSTATUS=0
case "$1" in
  all)
	for CARD in $(echo_card_indices) ; do
		mute_and_zero_levels_on_card "$CARD" || TTZML_RETURNSTATUS=1
	done
	;;
  *)
	mute_and_zero_levels_on_card "$1" || TTZML_RETURNSTATUS=1
	;;
esac
return $TTZML_RETURNSTATUS
}


# $1 <card ID> | "all"
card_OK()
{
[ "$1" ] || bugout
if [ "$1" = all ] ; then
	[ -d /proc/asound ]
	return $?
else
	[ -d "/proc/asound/card$1" ] || [ -d "/proc/asound/$1" ]
	return $?
fi
}

# If a card identifier is provided in $2 then regard it as an error
# if that card is not present; otherwise don't regard it as an error.

case "$1" in
 start)
EXITSTATUS=0
TARGET_CARD="$2"
case "$TARGET_CARD" in
  ""|all) TARGET_CARD=all ; log_action_begin_msg "Setting up ALSA" ;;
  *) log_action_begin_msg "Setting up ALSA card ${TARGET_CARD}" ;;
esac
card_OK "$TARGET_CARD" || log_action_end_msg_and_exit "$( [ ! "$2" ] ; echo $? ; )" "none loaded"
preinit_levels "$TARGET_CARD" || EXITSTATUS=1
if ! restore_levels "$TARGET_CARD" ; then
	sanify_levels "$TARGET_CARD" || EXITSTATUS=1
	restore_levels "$TARGET_CARD" >/dev/null 2>&1 || :
fi
log_action_end_msg_and_exit "$EXITSTATUS"
;;
 stop)
EXITSTATUS=0
TARGET_CARD="$2"
case "$TARGET_CARD" in
  ""|all) TARGET_CARD=all ; log_action_begin_msg "Shutting down ALSA" ;;
  *) log_action_begin_msg "Shutting down ALSA card ${TARGET_CARD}" ;;
esac
card_OK "$TARGET_CARD" || log_action_end_msg_and_exit "$( [ ! "$2" ] ; echo $? ; )" "none loaded"
store_levels "$TARGET_CARD" || EXITSTATUS=1
#mute_and_zero_levels "$TARGET_CARD" || EXITSTATUS=1
log_action_end_msg_and_exit "$EXITSTATUS"
;;
 restart|force-reload)
EXITSTATUS=0
$0 stop || EXITSTATUS=1
$0 start || EXITSTATUS=1
exit $EXITSTATUS
;;
 reset)
TARGET_CARD="$2"
case "$TARGET_CARD" in
  ""|all) TARGET_CARD=all ; log_action_begin_msg "Resetting ALSA" ;;
  *) log_action_begin_msg "Resetting ALSA card ${TARGET_CARD}" ;;
esac
card_OK "$TARGET_CARD" || log_action_end_msg_and_exit "$( [ ! "$2" ] ; echo $? ; )" "none loaded"
preinit_levels "$TARGET_CARD"
sanify_levels "$TARGET_CARD"
log_action_end_msg_and_exit "$?"
;;
 *)
echo "Usage: $MYNAME {start [CARD]|stop [CARD]|restart [CARD]|reset [CARD]}" >&2
exit 3
;;
esac

 

 

Now google also shows that some people need to restart alsa after suspend....likely for portable computer users?

http://ubuntuforums.org/archive/index.php/t-810718.html

 

Now one of the commands from Ubuntu includes from that link

 

sudo alsa force-reload

 

But I have already research Bodhi and its missing but I believe my other distro has it and its

 

/etc/apm/scripts.d/alsa (that seems to match suspend issues)

 

contents in a code box

 

#!/bin/sh
#
# apmd proxy script for ALSA

[ -x /usr/sbin/alsactl ] || exit 0

case "$1,$2" in
suspend,*) /usr/sbin/alsactl store && /usr/sbin/alsa suspend ;;
resume,suspend) /usr/sbin/alsa resume && /usr/sbin/alsactl restore ;;
esac

 

Ok the debian alsactl lets peek into that

 

strings alsactl | grep force
 -F,--force       try to restore the matching controls as much as possible
force

or alsactl --help (also shows force)

 

good that looks like the force mentioned in the Ubuntu forum

 

Part 4

 

My initial attempts to unpack and steal the debian init script were a fail

 

My initial attempts to unpack and configure the source file for alsa-utils results in a complaint that I don't have a up-to-date libasound lib but I when I installed libasound2-dev ...still no joy

 

 

grrrr

 

blood pressure.....breathe!

 

 

EDIT

 

GPL source for debian alsa-utils aussie mirror

http://mirror.internode.on.net/pub/debian/pool/main/a/alsa-utils/

 

so

 

Can anyone tell me how to restart alsa on Bodhi please?

Share this post


Link to post
Share on other sites
Guest aus9

I can reboot that is not the issue

 

My post is titled for a user.

 

I don't want to offer some large list of reasons here please.

 

The suspend issue should suffice.

 

I suspect I am may be construed as being rude but ... Elw3....can I assume you do not know how to restart alsa on Bodhi either?

Share this post


Link to post
Share on other sites
Guest Meji_D

sudo apt-get install alsa-base

Will install the necessary parts to allow you to use alsa {unload|reload|force-unload|force-reload|suspend|resume} commands.

 

sudo alsa reload

Should achieve what you want.

 

sudo alsa force-reload

I believe will log you out and restart X as well.

 

Good luck ;)

Share this post


Link to post
Share on other sites
Guest aus9

hi

 

firstly it was not installed by default so thanks for fixing that bit up

 

for all users...after Meji_D install instructions as root I ran

 

sudo alsa --help
Usage: /sbin/alsa {unload|reload|force-unload|force-reload|suspend|resume}


sudo alsa force-reload
Unloading ALSA sound driver modules: snd-hda-codec-idt snd-hda-intel snd-hda-codec snd-hwdep snd-pcm snd-timer snd-page-alloc (failed: modules still loaded: snd-hda-codec-idt snd-hda-codec snd-hwdep snd-pcm snd-timer snd-page-alloc).
Loading ALSA sound driver modules: snd-hda-codec-idt snd-hda-intel snd-hda-codec snd-hwdep snd-pcm snd-timer snd-page-alloc

 

One minor thing on my system...it does not log me out but maybe thats because I have a closed source nvidia driver

 

anyhow

 

Thanks heaps

 

grins like a kitten

 

 

Second test.... now that I know.... I am not logged out....vlc stops which is expected behaviour.

 

and I am not fussed my codecs were still loaded

 

I might make a wiki with your name in lights let me know if thats ok or not....no rush

 

thanks again

 

 

for those who like logs....alsa reload appears in log

 

Jan 11 18:18:26 945GCT-M2 kernel: [   17.097135] 8139too 0000:02:05.0: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
Jan 11 18:18:27 945GCT-M2 kernel: [   17.250999] zram: module is from the staging directory, the quality is unknown, you have been warned.
Jan 11 18:18:27 945GCT-M2 kernel: [   17.251248] zram: Creating 2 devices ...
Jan 11 18:18:27 945GCT-M2 kernel: [   17.297603] Adding 1030980k swap on /dev/zram0.  Priority:100 extents:1 across:1030980k SS
Jan 11 18:18:27 945GCT-M2 kernel: [   17.298815] Adding 1030980k swap on /dev/zram1.  Priority:100 extents:1 across:1030980k SS
Jan 11 18:22:38 945GCT-M2 kernel: [  268.716465] HDA Intel 0000:00:1b.0: PCI INT A disabled
Jan 11 18:22:38 945GCT-M2 kernel: [  268.738910] HDA Intel 0000:00:1b.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
Jan 11 18:22:38 945GCT-M2 kernel: [  268.784740] input: HDA Intel Line In at Ext Rear Jack as /devices/pci0000:00/0000:00:1b.0/sound/card0/input9
Jan 11 18:22:38 945GCT-M2 kernel: [  268.785012] input: HDA Intel Mic at Ext Rear Jack as /devices/pci0000:00/0000:00:1b.0/sound/card0/input10
Jan 11 18:22:38 945GCT-M2 kernel: [  268.785142] input: HDA Intel Mic at Ext Front Jack as /devices/pci0000:00/0000:00:1b.0/sound/card0/input11
Jan 11 18:22:38 945GCT-M2 kernel: [  268.785253] input: HDA Intel Speaker at Ext Rear Jack as /devices/pci0000:00/0000:00:1b.0/sound/card0/input12
Jan 11 18:22:38 945GCT-M2 kernel: [  268.790508] input: HDA Intel HP Out at Ext Front Jack as /devices/pci0000:00/0000:00:1b.0/sound/card0/input13
Jan 11 18:27:28 945GCT-M2 kernel: [  559.016481] HDA Intel 0000:00:1b.0: PCI INT A disabled
Jan 11 18:27:29 945GCT-M2 kernel: [  559.240315] HDA Intel 0000:00:1b.0: PCI INT A -> GSI 16 (level, low) -> IRQ 16
Jan 11 18:27:29 945GCT-M2 kernel: [  559.292686] input: HDA Intel Line In at Ext Rear Jack as /devices/pci0000:00/0000:00:1b.0/sound/card0/input14
Jan 11 18:27:29 945GCT-M2 kernel: [  559.292842] input: HDA Intel Mic at Ext Rear Jack as /devices/pci0000:00/0000:00:1b.0/sound/card0/input15
Jan 11 18:27:29 945GCT-M2 kernel: [  559.292908] input: HDA Intel Mic at Ext Front Jack as /devices/pci0000:00/0000:00:1b.0/sound/card0/input16
Jan 11 18:27:29 945GCT-M2 kernel: [  559.292969] input: HDA Intel Speaker at Ext Rear Jack as /devices/pci0000:00/0000:00:1b.0/sound/card0/input17
Jan 11 18:27:29 945GCT-M2 kernel: [  559.293030] input: HDA Intel HP Out at Ext Front Jack as /devices/pci0000:00/0000:00:1b.0/sound/card0/input18

Share this post


Link to post
Share on other sites
Sign in to follow this  

×