Headphone works, speakers don't

On my NixOS system, I can get audio through my headphones, but not through my speakers.

Basic checks:

  • Speakers work on another machine
  • Speakers are plugged in and turned on
  • Headphones are unplugged when using speakers
# nix-channel --list | grep nixos
nixos https://nixos.org/channels/nixos-20.03

Sound is enabled.

  # Enable sound.
  sound.enable = true;
  hardware.pulseaudio.enable = true;

My user account is in the audio group.

  users.users.amy = {
    isNormalUser = true;
    home = "/home/amy";
    description = "Amy de Buitleir";
    extraGroups = [ "wheel" "networkmanager" "vboxsf" "docker" "audio" ];
    uid = 1000;
  };
$ cat /proc/asound/version 
Advanced Linux Sound Architecture Driver Version k5.4.67.
$ cat /proc/asound/cards
 0 [Generic        ]: HDA-Intel - HD-Audio Generic
                      HD-Audio Generic at 0xfa200000 irq 113
 1 [Headphone      ]: USB-Audio - Aorus Master Front Headphone
                      Gigabyte-Aorus-Master-Front-Headphone
 2 [Generic_1      ]: HDA-Intel - HD-Audio Generic
                      HD-Audio Generic at 0xe1ca0000 irq 115
 3 [Audio          ]: USB-Audio - Aorus Master Main Audio
                      Gigabyte-Aorus-Master-Main-Audio
$ lsmod | grep snd
snd_hda_codec_hdmi     69632  1
snd_usb_audio         262144  5
snd_hda_intel          49152  2
snd_intel_nhlt         20480  1 snd_hda_intel
snd_usbmidi_lib        32768  1 snd_usb_audio
snd_rawmidi            40960  1 snd_usbmidi_lib
snd_seq_device         16384  1 snd_rawmidi
snd_hda_codec         135168  2 snd_hda_codec_hdmi,snd_hda_intel
mc                     49152  1 snd_usb_audio
snd_hda_core           86016  3 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec
snd_hwdep              16384  2 snd_usb_audio,snd_hda_codec
snd_pcm_oss            65536  0
snd_mixer_oss          28672  1 snd_pcm_oss
snd_pcm               106496  7 snd_hda_codec_hdmi,snd_hda_intel,snd_usb_audio,snd_hda_codec,snd_pcm_oss,snd_hda_core
snd_timer              36864  1 snd_pcm
snd                    86016  25 snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_usb_audio,snd_usbmidi_lib,snd_hda_codec,snd_timer,snd_pcm_oss,snd_pcm,snd_rawmidi,snd_mixer_oss
soundcore              16384  1 snd
usbcore               270336  6 xhci_hcd,snd_usb_audio,usbhid,snd_usbmidi_lib,btusb,xhci_pci

aplay reports no errors, but I don’t hear anything unless I have the headphones plugged in.

$ aplay -vv test.wav
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 11025 Hz, Mono
ALSA <-> PulseAudio PCM I/O Plugin
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 1
  rate         : 11025
  exact rate   : 11025 (11025/1)
  msbits       : 16
  buffer_size  : 5513
  period_size  : 1378
  period_time  : 125000
  tstamp_mode  : NONE
  tstamp_type  : GETTIMEOFDAY
  period_step  : 1
  avail_min    : 1378
  period_event : 0
  start_threshold  : 5513
  stop_threshold   : 5513
  silence_threshold: 0
  silence_size : 0
  boundary     : 6207086186423386112
###                                  +             | 72%^C
Aborted by signal Interrupt...

Likewise, speaker-test reports no errors, but I don’t hear anything unless I have the headphones plugged in.

$ speaker-test -twav

speaker-test 1.2.1

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
WAV file(s)
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 192 to 2097152
Period size range from 64 to 699051
Using max buffer size 2097152
Periods = 4
was set period_size = 524288
was set buffer_size = 2097152
 0 - Front Left
Time per period = 1.481250
 0 - Front Left
Time per period = 1.483892
 0 - Front Left
Time per period = 1.484287
 0 - Front Left
^CTime per period = 1.482327

Could this be volume set up? I don’t understand this, but I certainly experience that mute/volume levels are separate for speakers and headphones (which is quite handy BTW).

Good thought, but I checked in alsamixer, and the volume is in the green range. Nothing is muted. The volume knob on the speakers is up too.

Could you try pasystray? Is it shown as an available sink there (and volume is not sneaked to 0%)?

My speakers are set on full volume with alsamixer as well, I have to use amixer to actually unmute them.

I don’t remember the exact command though, I usually just do it from history…

I tried pasystray, but got an error message.

$ pasystray

(pasystray:16041): pasystray-WARNING **: 20:01:20.607: Error initializing Avahi: Daemon not running

I guess I could install avahi, but it doesn’t seem relevant to the problem?

Here’s some info I got from amixer.

$ amixer
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 65536 [100%] [on]
  Front Right: Playback 65536 [100%] [on]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 65536
  Front Left: Capture 65536 [100%] [on]
  Front Right: Capture 65536 [100%] [on]

I found this command that’s supposed to unmute, but I get an error message.

$ amixer -c 0 set Master playback 100% unmute
amixer: Unable to find simple control 'Master',0

I don’t know much about ALSA or pulseaudio, etc., so I’m lost here.

I think I got a step further. I ran the following command:

$ amixer scontrols
Simple mixer control 'Master',0
Simple mixer control 'Capture',0

Based on that output, I think I figured out the correct command to unmute.

$ amixer set 'Master',0 unmute
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 65536 [100%] [on]
  Front Right: Playback 65536 [100%] [on]

However, still no sound from the speakers.

I’ve had the same problem for months. It hasn’t bothered me often since I generally prefer headphones, but someone else having the problem motivated me to try again, and at least for me this worked:

Run alsamixer, then hit F6 to select your soundcard, scroll over to <Speaker>, and make sure it isn’t muted. Apologies if you’ve already tried this, as it seems very obvious, but at least for me I’d somehow managed to spend many hours searching through pacmd and related commands without noticing this …

i would also look into pavucontrol, allows a lot of configuration input and output devices

1 Like

I have also been having strange issues lately where pulseaudio fails to detect devices after a suspend/resume cycle - I’m not sure if this is related.

So a couple of things to pay attention to:

  1. aplay -l vs pactl list. Do you see physical devices showing in the former but not the latter?

  2. try running speaker-test with pasuspender to talk directly to the hardware: pasuspender -- speaker-test

  3. speaker-test allows you to specify a device to play through with the -D flag. What happens when you pass it the device to which the speakers are connected?

  4. if you look in the journal for pulseaudio with journalctl --user -u pulseaudio do you see messages like this:
    E: [pulseaudio] module.c: Failed to load module “module-alsa-card…”

Aha!

-- Reboot --
Sep 26 00:05:44 nixos systemd[1878]: Starting Sound Service...
Sep 26 00:05:44 nixos pulseaudio[38237]: E: [pulseaudio] module-alsa-card.c: Failed to find a working profile.
Sep 26 00:05:44 nixos pulseaudio[38237]: E: [pulseaudio] module.c: Failed to load module "module-alsa-card" (argument: "devi>
Sep 26 00:05:47 nixos pulseaudio[38237]: E: [pulseaudio] bluez5-util.c: GetManagedObjects() failed: org.freedesktop.DBus.Err>
Sep 26 00:05:47 nixos systemd[1878]: Started Sound Service.
Sep 29 11:33:01 nixos pulseaudio[38237]: E: [alsa-sink-USB Audio] alsa-sink.c: ALSA woke us up to write new data to the devi>
Sep 29 11:33:01 nixos pulseaudio[38237]: E: [alsa-sink-USB Audio] alsa-sink.c: Most likely this is a bug in the ALSA driver >
Sep 29 11:33:01 nixos pulseaudio[38237]: E: [alsa-sink-USB Audio] alsa-sink.c: We were woken up with POLLOUT set -- however >
Sep 30 15:56:27 nixos systemd[1878]: pulseaudio.service: Current command vanished from the unit file, execution of the comma>
Sep 30 15:56:36 nixos pulseaudio[38237]: E: [pulseaudio] module-alsa-card.c: Failed to find a working profile.
Sep 30 15:56:36 nixos pulseaudio[38237]: E: [pulseaudio] module.c: Failed to load module "module-alsa-card" (argument: "devi>
Sep 30 15:56:36 nixos pulseaudio[38237]: E: [pulseaudio] module-alsa-card.c: Failed to find a working profile.
Sep 30 15:56:36 nixos pulseaudio[38237]: E: [pulseaudio] module.c: Failed to load module "module-alsa-card" (argument: "devi>
Sep 30 15:56:36 nixos pulseaudio[38237]: E: [pulseaudio] module-alsa-card.c: Failed to find a working profile.
Sep 30 15:56:36 nixos pulseaudio[38237]: E: [pulseaudio] module.c: Failed to load module "module-alsa-card" (argument: "devi>
Oct 01 20:25:19 nixos pulseaudio[38237]: W: [pulseaudio] module-equalizer-sink.c: module-equalizer-sink is currently unsuppo>
Oct 01 20:25:19 nixos pulseaudio[38237]: W: [pulseaudio] module-equalizer-sink.c: If you're facing audio problems, try unloa>
Oct 01 20:25:19 nixos pulseaudio[38237]: E: [pulseaudio] module-equalizer-sink.c: resume state exists but is wrong size!

Yes! See above post.

pactl list gives a LOT of output, but assuming I’ve interpreted things correctly,

  • On card 1, aplay -l reports devices 3, 7, 8, 9, 10 and 11,
    but pactl list only reports device 10.

  • On card 2, aplay -l reports device 0; pactl list also reports device 0.

  • On card 3, aplay -l reports devices 0, 1 and 2.
    pactl list only reports device 0.

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: Generic_1 [HD-Audio Generic], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 10: HDMI 4 [HDMI 4]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic_1 [HD-Audio Generic], device 11: HDMI 5 [HDMI 5]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Headphone [Aorus Master Front Headphone], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 3: Audio [Aorus Master Main Audio], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: Audio [Aorus Master Main Audio], device 1: USB Audio [USB Audio #1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: Audio [Aorus Master Main Audio], device 3: USB Audio [USB Audio #3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
$ pactl list | grep -E -e 'alsa\.device|alsa\.card|alsa\.driver'
                alsa.device = "0"
                alsa.card = "2"
                alsa.card_name = "Aorus Master Front Headphone"
                alsa.driver_name = "snd_usb_audio"
                alsa.device = "0"
                alsa.card = "3"
                alsa.card_name = "Aorus Master Main Audio"
                alsa.driver_name = "snd_usb_audio"
                alsa.device = "10"
                alsa.card = "1"
                alsa.card_name = "HD-Audio Generic"
                alsa.driver_name = "snd_hda_intel"
                alsa.card = "2"
                alsa.card_name = "Aorus Master Front Headphone"
                alsa.driver_name = "snd_usb_audio"
                alsa.card = "3"
                alsa.card_name = "Aorus Master Main Audio"
                alsa.driver_name = "snd_usb_audio"
                alsa.device = "0"
                alsa.card = "3"
                alsa.card_name = "Aorus Master Main Audio"
                alsa.driver_name = "snd_usb_audio"
                alsa.card = "1"
                alsa.card_name = "HD-Audio Generic"
                alsa.driver_name = "snd_hda_intel"
                alsa.card = "2"
                alsa.card_name = "Aorus Master Front Headphone"
                alsa.driver_name = "snd_usb_audio"
                alsa.card = "3"
                alsa.card_name = "Aorus Master Main Audio"
                alsa.driver_name = "snd_usb_audio"
                alsa.card = "1"
                alsa.card_name = "HD-Audio Generic"
                alsa.driver_name = "snd_hda_intel"

Same output with or without pasuspender. No sound.

I don’t know for sure which device the speakers are connected to, so I tried all the devices reported by aplay -L. Every one gave me the same error message, except that the PCM # is different.

$ speaker-test -D 0

speaker-test 1.2.1

Playback device is 0
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
ALSA lib pcm.c:2635:(snd_pcm_open_noupdate) Unknown PCM 0
Playback open error: -2,No such file or directory

I would really like to get audio working, but I haven’t been able to make any progress on this issue. I think the most salient data at the moment is the module-alsa-card.c: Failed to find a working profile error message (see below).

$ journalctl --user -u pulseaudio | tail
-- Reboot --
Nov 20 17:00:31 nixos systemd[2146]: Starting Sound Service...
Nov 20 17:00:32 nixos pulseaudio[2162]: E: [pulseaudio] module-alsa-card.c: Failed to find a working profile.
Nov 20 17:00:32 nixos pulseaudio[2162]: E: [pulseaudio] module.c: Failed to load module "module-alsa-card" (argument: "device_id="0" name="pci-0000_22_00.4" card_name="alsa_card.pci-0000_22_00.4" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes avoid_resampling=no card_properties="module-udev-detect.discovered=1""): initialization failed.
Nov 20 17:00:34 nixos pulseaudio[2162]: E: [pulseaudio] module-jackdbus-detect.c: Unable to contact D-Bus session bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Nov 20 17:00:34 nixos pulseaudio[2162]: E: [pulseaudio] module.c: Failed to load module "module-jackdbus-detect" (argument: "channels=2"): initialization failed.
Nov 20 17:00:34 nixos pulseaudio[2162]: W: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Nov 20 17:00:34 nixos pulseaudio[2162]: W: [pulseaudio] main.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
Nov 20 17:00:34 nixos pulseaudio[2162]: E: [pulseaudio] bluez5-util.c: GetManagedObjects() failed: org.freedesktop.DBus.Error.ServiceUnknown: The name org.bluez was not provided by any .service files
Nov 20 17:00:34 nixos systemd[2146]: Started Sound Service.