How restart the audio/sound system?

Sorry to have to ask. What I thought would be a simple question and answer. Seems not to be…

What I think the question should be is: How do I restart the sound system from the command line?
I think I need something along the line of #systemctl restart <pulse/alsa/sound?>.service

Just in case there are “many ways to skin this cat”! My problem is:
I have two sound cards and after booting-up both work fine. All is tikity-boo…! I’m happy :slight_smile:
However, after some time (unknown, maybe hours) one sound card stops working.
The only way I know how to get it working again, is to reboot.
I’m looking for a quicker route. In time I may get round to figuring out why it happens but for now there are other more important things to fix!

Best regards, Martin

PS - Forgive me if I take some time coming back - I may not hear the “new message arrive” fanfare !

Hi
You can see the loaded services/targets etc via;


systemctl list-units --no-pager |egrep "alsa|sound"

I would surmise the sound.target…


systemctl status sound.target

systemctl restart sound.target

systemctl status sound.target

So…

**Gzunder:~ # systemctl list-units --no-pager |egrep "alsa|sound"**
sys-devices-pci0000:00-0000:00:03.0-0000:01:00.1-sound-card1.device   loaded active plugged          Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]                     
sys-devices-pci0000:00-0000:00:1b.0-sound-card0.device                loaded active plugged          5 Series/3400 Series Chipset High Definition Audio                              
alsa-restore.service                                                  loaded active exited           Save/Restore Sound Card State                                                   
Gzunder:~ # 

I’m guessing, two sound cards and one service?

Now, I try…

**Gzunder:~ # systemctl status sound.target**
● sound.target - Sound Card
   Loaded: loaded (/usr/lib/systemd/system/sound.target; static; vendor preset: disabled)
   Active: active since Thu 2019-01-24 14:57:18 GMT; 3s ago
     Docs: man:systemd.special(7)

Jan 24 14:57:18 Gzunder.localnet systemd[1]: Reached target Sound Card.
Gzunder:~ # 

Says “active” and I can hear both playing.

Now…

**Gzunder:~ # systemctl stop sound.target
Gzunder:~ # systemctl status sound.target**
● sound.target - Sound Card
   Loaded: loaded (/usr/lib/systemd/system/sound.target; static; vendor preset: disabled)
   Active: inactive (dead) since Thu 2019-01-24 15:00:07 GMT; 23s ago
     Docs: man:systemd.special(7)

Jan 24 14:57:18 Gzunder.localnet systemd[1]: Reached target Sound Card.
Jan 24 15:00:07 Gzunder.localnet systemd[1]: Stopped target Sound Card.
Gzunder:~ # 

Seems to imply that “something” has stopped/inactive/(dead)? But I can clearly hear both outputs playing??

Confused.

Is there not an audio.service or sound.service or something like that (obviously not either of those name, cos I’ve been hunting all over 'tnternet…)

Martin

On Thu 24 Jan 2019 03:16:07 PM CST, martinprowe wrote:

malcolmlewis;2892322 Wrote:
> Hi
> You can see the loaded services/targets etc via;
>
> >
Code:

> >
> systemctl list-units --no-pager |egrep “alsa|sound”
>

> >

So…

Code:

Gzunder:~ # systemctl list-units --no-pager |egrep “alsa|sound”
sys-devices-pci0000:00-0000:00:03.0-0000:01:00.1-sound-card1.device
loaded active plugged Cape Verde/Pitcairn HDMI Audio [Radeon
HD 7700/7800 Series]
sys-devices-pci0000:00-0000:00:1b.0-sound-card0.device
loaded active plugged 5 Series/3400 Series Chipset High
Definition Audio
alsa-restore.service
loaded active exited Save/Restore Sound Card State Gzunder:~

--------------------

I’m guessing, two sound cards and one service?

Now, I try…

Code:

Gzunder:~ # systemctl status sound.target
● sound.target - Sound Card
Loaded: loaded (/usr/lib/systemd/system/sound.target; static; vendor
preset: disabled) Active: active since Thu 2019-01-24 14:57:18 GMT; 3s
ago Docs: man:systemd.special(7)

Jan 24 14:57:18 Gzunder.localnet systemd[1]: Reached target Sound
Card. Gzunder:~ #

Says “active” and I can hear both playing.

Now…

Code:

Gzunder:~ # systemctl stop sound.target
Gzunder:~ # systemctl status sound.target

● sound.target - Sound Card
Loaded: loaded (/usr/lib/systemd/system/sound.target; static; vendor
preset: disabled) Active: inactive (dead) since Thu 2019-01-24 15:00:07
GMT; 23s ago Docs: man:systemd.special(7)

Jan 24 14:57:18 Gzunder.localnet systemd[1]: Reached target Sound
Card. Jan 24 15:00:07 Gzunder.localnet systemd[1]: Stopped target Sound
Card. Gzunder:~ #

Seems to imply that “something” has stopped/inactive/(dead)? But I can
clearly hear both outputs playing??

Confused.

Is there not an audio.service or sound.service or something like
that (obviously not either of those name, cos I’ve been hunting all over
'tnternet…)

Martin

Hi
You did not start the service, yes the target should apply to all
cards…


Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
SLES 15 | GNOME Shell 3.26.2 | 4.12.14-25.25-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

What service?

Martin

On Thu 24 Jan 2019 06:06:03 PM CST, martinprowe wrote:

malcolmlewis;2892340 Wrote:
> You did not start the service

What service?

Martin

Hi
Correction, the target :wink:


systemctl restart sound.target


Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
SLES 15 | GNOME Shell 3.26.2 | 4.12.14-25.25-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

Sorry, but this is not getting any clearer for me?

If I start with a re-boot (to set everything to normal) and then play two audio tracks on each sound sinks:

mprowe@Gzunder:~> **paplay -d alsa_output.pci-0000_01_00.1.hdmi-stereo test.flac**
mprowe@Gzunder:~> **paplay -d alsa_output.pci-0000_00_1b.0.hdmi-stereo test.flac**

I can now hear both tracks playing on their respective sound cards. Now I will try and stop/start/restart using your advice:

Gzunder:/home/mprowe # **systemctl stop sound.target**
Gzunder:/home/mprowe # **systemctl status sound.target**
● sound.target - Sound Card
   Loaded: loaded (/usr/lib/systemd/system/sound.target; static; vendor preset: disabled)
   Active: inactive (dead) since Fri 2019-01-25 11:14:02 GMT; 10min ago
     Docs: man:systemd.special(7)

Jan 25 09:26:35 Gzunder.localnet systemd[1]: Reached target Sound Card.
Jan 25 11:14:02 Gzunder.localnet systemd[1]: Stopped target Sound Card.
Gzunder:/home/mprowe # 

Systemctl says it has “stopped something” … but I can still hear the music?
More disappointingly, I have had the default sink fail this morning (the cause of this investigation) and restarting the sound.target did not get it going. I still needed to reboot :frowning:

Regards, Martin

Hi
In the systemctl output, there should be two cards and a sound target, eg;


systemctl list-units --no-pager |egrep "alsa|sound"

sys-devices-pci0000:00-0000:00:01.0-0000:01:00.1-sound-card1.device                      loaded active plugged   GK208 HDMI/DP Audio Controller                                    
sys-devices-pci0000:00-0000:00:1b.0-sound-card0.device                                   loaded active plugged   7 Series/C216 Chipset Family High Definition Audio Controller
sound.target                                                                                loaded active active    Sound Card

systemctl list-units --no-pager |egrep "alsa|sound"

sys-devices-pci0000:00-0000:00:01.1-sound-card0.device                                      loaded active plugged   Kabini HDMI/DP Audio                                                         
sys-devices-pci0000:00-0000:00:09.2-sound-card1.device                                      loaded active plugged   Family 15h (Models 60h-6fh) Audio Controller                                 
sound.target                                                                                loaded active active    Sound Card

Not sure if you can use systemd to unplug and re-plug a device?

I see the alsa status as ‘condition failed’


systemctl status alsa-<use tab completion>

Can you add the -v option to paplay to get more info?

FWIW, PulseAudio can be enabled/disabled using ‘setup-pulseaudio’…

sudo setup-pulseaudio --status
sudo setup-pulseaudio --enable
sudo setup-pulseaudio --disable

but I doubt the problem is occurring at this layer. Your opening post suggests a possible power management issue to me. Can you share the hardware details please?

/usr/sbin/hwinfo --sound

Yes, of course…

**Gzunder:~ # hwinfo --sound**
25: PCI 100.1: 0403 Audio device                                                                                                          
  [Created at pci.378]                                                                                                                    
  Unique ID: NXNs.TB_hCuhjxV5                                                                                                             
  Parent ID: 3hqH.dmRx1m7CVE5                                                                                                             
  SysFS ID: /devices/pci0000:00/0000:00:03.0/0000:01:00.1                                                                                 
  SysFS BusID: 0000:01:00.1                                                                                                               
  Hardware Class: sound                                                                                                                   
  Model: "ATI Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]"                                                                
  Vendor: pci 0x1002 "ATI Technologies Inc"                                                                                               
  Device: pci 0xaab0 "Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]"                                                        
  SubVendor: pci 0x103c "Hewlett-Packard Company"                                                                                         
  SubDevice: pci 0xaab0                                                                                                                   
  Driver: "snd_hda_intel"
  Driver Modules: "snd_hda_intel"
  Memory Range: 0xf79fc000-0xf79fffff (rw,non-prefetchable)
  IRQ: 40 (289 events)
  Module Alias: "pci:v00001002d0000AAB0sv0000103Csd0000AAB0bc04sc03i00"
  Driver Info #0:
    Driver Status: snd_hda_intel is active
    Driver Activation Cmd: "modprobe snd_hda_intel"
  Config Status: cfg=yes, avail=yes, need=no, active=unknown
  Attached to: #17 (PCI bridge)

52: PCI 1b.0: 0403 Audio device
  [Created at pci.378]
  Unique ID: u1Nb.ZbI9NHBokA7
  SysFS ID: /devices/pci0000:00/0000:00:1b.0
  SysFS BusID: 0000:00:1b.0
  Hardware Class: sound
  Model: "Intel 5 Series/3400 Series Chipset High Definition Audio"
  Vendor: pci 0x8086 "Intel Corporation"
  Device: pci 0x3b56 "5 Series/3400 Series Chipset High Definition Audio"
  SubVendor: pci 0x1043 "ASUSTeK Computer Inc."
  SubDevice: pci 0x8375 
  Revision: 0x06
  Driver: "snd_hda_intel"
  Driver Modules: "snd_hda_intel"
  Memory Range: 0xf78f8000-0xf78fbfff (rw,non-prefetchable)
  IRQ: 39 (1451 events)
  Module Alias: "pci:v00008086d00003B56sv00001043sd00008375bc04sc03i00"
  Driver Info #0:
    Driver Status: snd_hda_intel is active
    Driver Activation Cmd: "modprobe snd_hda_intel"
  Config Status: cfg=yes, avail=yes, need=no, active=unknown
Gzunder:~ # 

Regards, Martin

Ok, thanks for sharing that info. It would be good to eliminate PA from the equation. When you think a sound card has ‘disappeared’, try testing at the ALSA layer. Disable pulseaudio with

sudo setup-pulseaudio --disable

and use aplay to list your cards and outputs available

aplay -L

Use that information to try playing a test sound via the appropriate device and output.

For reference I get (only one sound device to test with unfortunately)…

# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default
    Default ALSA Output (currently PulseAudio Sound Server)
sysdefault:CARD=I82801AAICH
    Intel 82801AA-ICH, Intel 82801AA-ICH
    Default Audio Device
front:CARD=I82801AAICH,DEV=0
    Intel 82801AA-ICH, Intel 82801AA-ICH
    Front speakers
surround21:CARD=I82801AAICH,DEV=0
    Intel 82801AA-ICH, Intel 82801AA-ICH
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=I82801AAICH,DEV=0
    Intel 82801AA-ICH, Intel 82801AA-ICH
    4.0 Surround output to Front and Rear speakers
surround41:CARD=I82801AAICH,DEV=0
    Intel 82801AA-ICH, Intel 82801AA-ICH
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=I82801AAICH,DEV=0
    Intel 82801AA-ICH, Intel 82801AA-ICH
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=I82801AAICH,DEV=0
    Intel 82801AA-ICH, Intel 82801AA-ICH
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
iec958:CARD=I82801AAICH,DEV=0
    Intel 82801AA-ICH, Intel 82801AA-ICH
    IEC958 (S/PDIF) Digital Audio Output

So, I can run something like the following…

aplay  --device sysdefault:CARD=I82801AAICH /usr/share/sounds/alsa/test.wav
aplay  --device front:CARD=I82801AAICH,DEV=0 /usr/share/sounds/alsa/test.wav

See if you can get sound from both of your cards.

BTW, you can use systool to check the current loaded module options

systool -m snd_hda_intel -v

If we determine that power management is at play here, it is possible to load the snd_hda_intel module so that power saving is disabled.

I forgot to mention that you can re-enable PA again with

sudo setup-pulseaudio --enable

Thanks for the suggestion, Deano.

Lost the output from this sound card twice today (not uncommon - it is probably more often than that but I just don’t notice).

Gzunder:~ # **systemctl list-units --no-pager |grep "sound-card1"**
sys-devices-pci0000:00-0000:00:03.0-0000:01:00.1-sound-card1.device   loaded active plugged   Cape Verde/Pitcairn HDMI Audio [Radeon HD 7700/7800 Series]                         
Gzunder:~ # 

Unfortunately, no amount of:

Gzunder:~ # **setup-pulseaudio --disable**
Disabling PulseAudio for ALSA...
Disabling PulseAudio for libao...
Disabling PulseAudio for SDL...
Disabling PulseAudio for Timidity...
Disabling PulseAudio for Phonon...
Disabling PulseAudio for Kmix...
Disabling PulseAudio for speech dispatcher...
Disabling PulseAudio for SoX...
Setting alsasink/src for gstreamer
Clearing QEMU/KVM audio setup
Disabling PulseAudio autospawn...
Gzunder:~ # 

… followed by:

Gzunder:~ # **setup-pulseaudio --enable**
Enabling PulseAudio for ALSA...
Enabling PulseAudio for libao...
Enabling PulseAudio for mplayer...
Enabling PulseAudio for OSS...
Enabling PulseAudio for SDL...
Enabling PulseAudio for Timidity...
Enabling PulseAudio for Phonon...
Enabling PulseAudio for Kmix...
Enabling PulseAudio for speech dispatcher...
Enabling PulseAudio for SoX...
Setting auto sink/src for gstreamer
Enabling PulseAudio for QEMU/KVM
Enabling PulseAudio autospawn...
Gzunder:~ #

… did not bring it back.
I do notice that following the --disable, the Task Bar Sound Widgets, change to report “No Output or Input Devices found”.
Then following (10-20sec) the “devices” reappear. No no sound?

Regards, Martin

I didn’t expect simply disabling and re-enabling pulseaudio would bring working sound back. What I wanted you to try was the alsa sound tests (with PA disabled).

Opps… Sorry! Didn’t understand. Let me try again…

A preliminary point? I have downloaded a test file and called it test.wav.
Starting simple, I check it plays on both sound cards with:

# **aplay -v test.wav**
No protocol specified
Playing WAVE 'test.wav' : Float 32 bit Little Endian, Rate 44100 Hz, Stereo
ALSA <-> PulseAudio PCM I/O Plugin
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : FLOAT_LE
  subformat    : STD
  channels     : 2
  rate         : 44100
  exact rate   : 44100 (44100/1)
  msbits       : 32
  buffer_size  : 22050
  period_size  : 5512
  period_time  : 125000
  tstamp_mode  : NONE
  tstamp_type  : GETTIMEOFDAY
  period_step  : 1
  avail_min    : 5512
  period_event : 0
  start_threshold  : 22050
  stop_threshold   : 22050
  silence_threshold: 0
  silence_size : 0
  boundary     : 6206523236469964800
# 

From this (because I think I will need it later?) I conclude that the format switch (-f) should be S32_LE (stereo, 32 bit, little endian).
As the above aplay command does not specify a device, I am switching the default sound card with the System Settings | Multimedia | Audio Volume GUI (Systemsettings5).
This seems to work.

Next, I get my list of devices:

**# aplay -L**
null
    Discard all samples (playback) or generate zero samples (capture)
**default**
    Default ALSA Output (currently PulseAudio Sound Server)
**sysdefault:CARD=MID**
    HDA Intel MID, VT1828S Analog
    Default Audio Device
**front:CARD=MID**,DEV=0
    HDA Intel MID, VT1828S Analog
    Front speakers
**surround21:CARD=MID**,DEV=0
    HDA Intel MID, VT1828S Analog
    2.1 Surround output to Front and Subwoofer speakers
**surround40:CARD=MID**,DEV=0
    HDA Intel MID, VT1828S Analog
    4.0 Surround output to Front and Rear speakers
**surround41:CARD=MID**,DEV=0
    HDA Intel MID, VT1828S Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
**surround50:CARD=MID**,DEV=0
    HDA Intel MID, VT1828S Analog
    5.0 Surround output to Front, Center and Rear speakers
**surround51:CARD=MID**,DEV=0
    HDA Intel MID, VT1828S Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
**surround71:CARD=MID**,DEV=0
    HDA Intel MID, VT1828S Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
**hdmi:CARD=MID**,DEV=0
    HDA Intel MID, VT1828S Digital
    HDMI Audio Output
**hdmi:CARD=HDMI**,DEV=0
    HDA ATI HDMI, HDMI 0
    HDMI Audio Output
**hdmi:CARD=HDMI**,DEV=1
    HDA ATI HDMI, HDMI 1
    HDMI Audio Output
# 

I have emboldened the strings that I think I need to use in the –device= switch.
I suspect that the only devices that I will hear are the 2 defaults and the 3 hdmi?
This is because I have an HDMI amp plugged into the motherboard sound card and two DisplayPort monitors (with speakers) plugged into the graphics card.

Firstly, if I try the two “defaults”:

 #** aplay --device=default test.wav**
No protocol specified
Playing WAVE 'test.wav' : Float 32 bit Little Endian, Rate 44100 Hz, Stereo

#** aplay --device=sysdefault test.wav**
Playing WAVE 'test.wav' : Float 32 bit Little Endian, Rate 44100 Hz, Stereo
#

And yes, I hear audio from both commands.
However –device=default, produced audio from the sound card on the motherboard and
–device=sysdefault produced audio from the sound card on the display adaptor?

So I now move on to try the other devices.

# **aplay --device=front:CARD=MID test.wav**
Playing WAVE 'test.wav' : Float 32 bit Little Endian, Rate 44100 Hz, Stereo
aplay: set_params:1339: Sample format non available
Available formats:
- S16_LE
- S32_LE
#

… so do I need a format switch? Let me try:

# **aplay --device=front:CARD=MID -f S32_LE test.wav**
Playing WAVE 'test.wav' : Float 32 bit Little Endian, Rate 44100 Hz, Stereo
aplay: set_params:1339: Sample format non available
Available formats:
- S16_LE
- S32_LE
#

Nope. No different. And all the other devices result in the same output.
Have I misunderstood the --device= switch? Why has it (sorta) worked for the –device=default and –device=sysdefault but none of the others devices?

Regards, Martin
PS - Sorry that this is getting so involved. It’s like spaghetti in there!

Your first and second sound cards (with respect to the HDMI outputs) are listed like this…

hdmi:CARD=HDMI,DEV=0
    HDA ATI HDMI, HDMI 0
    HDMI Audio Output
hdmi:CARD=HDMI,DEV=1
    HDA ATI HDMI, HDMI 1
    HDMI Audio Output
# 

So to test the second card you would use…

aplay --device=hdmi:CARD=HDMI,DEV=1 test.wav

Yep, that is what I had guessed! However, as I said earlier, all but the two “defaults” give this output:

# **aplay --device=hdmi:CARD=HDMI,DEV=1 test.wav**
Playing WAVE 'test.wav' : Float 32 bit Little Endian, Rate 44100 Hz, Stereo
aplay: set_params:1339: Sample format non available
Available formats:
- S16_LE
- S32_LE
# 

Adding the** --format=S32_LE **option did not make any difference.
… so is this an error message? Or a mistake in the command? A complete Red Herring? Or something else?

Thank you for sticking with this.
Regards, Martin

Can you try this using the ALSA-supplied ‘/usr/share/sounds/alsa/test.wav’ file please?

Dho… I’m sorry. I didn’t know that those files were on my system. You are dealing with an idiot at this end :shame:

Now that you have put me right, here are the results:


# **aplay --device=hdmi:CARD=MID,DEV=0 /usr/share/sounds/alsa/test.wav**                        
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo                
# //I hear the test sound on my HDMI Amp connected to the motherboard sound card

# **aplay --device=hdmi:CARD=HDMI,DEV=0 /usr/share/sounds/alsa/test.wav**
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo                
# //I hear the test sound on my **Left**-Hand DisplayPort monitor connected to my graphics card

#  **aplay --device=hdmi:CARD=HDMI,DEV=1 /usr/share/sounds/alsa/test.wav**                        
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo                
# //I hear the test sound on my **Right**-Hand DisplayPort monitor connected to my graphics card

WhooooHooooo… I guess this is good…?

I’ll post again later in the day after re-testing, with the above, once I loose the output from my (assumed) default, the --device=hdmi:CARD=HDMI,DEV=0.

Regards, Martin

Okay… The Sound card on the graphics controller has gone quiet (for whatever reason)?
So, I re-run the three aplay <device> test.wav and these are the results…


# **aplay --device=hdmi:CARD=MID,DEV=0 /usr/share/sounds/alsa/test.wav**                        
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo                
# //I **CAN** hear the test sound on my HDMI Amp connected to the motherboard sound card

# **aplay --device=hdmi:CARD=HDMI,DEV=0 /usr/share/sounds/alsa/test.wav**
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo                
# //I **CAN NOT** hear the test sound on my Left-Hand DisplayPort monitor connected to my graphics card

#  **aplay --device=hdmi:CARD=HDMI,DEV=1 /usr/share/sounds/alsa/test.wav   **                     
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo                
# //I **CAN NOT** hear the test sound on my Right-Hand DisplayPort monitor connected to my graphics card

It seems that I must have a problem with Graphics/Sound Card.
I’ll not guess, will you advise on what info I can provide…

Regards, Martin