I recently upgraded (foolishly, it seems) Ubuntu to Groovy Gorilla and the Gorilla killed my working shairport-sync install which took me a while to set up. I'm using the HDMI output of my graphics card as a sound card and the sound still works fine for all apps apart from shairport-sync. I figured it might need rebuilding in the new version, so I did that (first without removing the old version, then with...). Lots of restarting, especially before I realised you can restart the service with sudo systemctl restart shairport-sync. It would be good if the troubleshooting page here had a list of commands and things to aid diagnosis, etc.
I am able to stream to the box but it seems that SS is having trouble playing the sound. This is the error I get in the log when streaming:
shairport-sync[3373]: Failed to create secure directory (/home/shairport-sync/.config/pulse): No such file or directory
shairport-sync: warning: audio_alsa: Unable to set hw parameters for device "hdmi:NVidia": Cannot allocate memory.
I tried creating that directory and it didn't get rid of that error. UPDATE: fixed the directory error, it needed a chown for the shairport-sync user.
I've tried a lot of different devices and combinations in the config file. Looking at the ALSA docs, hdmi:NVidia should work the same as hw:0,7 - they produce the same shairport error at least.
Here's my config file as it was when it was working:
general =
{
name = "%H";
output_backend = "alsa";
// audio_backend_buffer_desired_length_in_seconds = 19845;
};
sessioncontrol =
{
};
alsa =
{
output_device = "hw:0,7";
mixer_control_name = "S/PDIF";
};
pa =
{
application_name = "Shairport Sync"; //Set this to the name that should appear in the Sounds "Applications" tab when Shairport Sync is active.
};
metadata =
{
};
mqtt =
{
};
diagnostics =
{
}
Here's my ALSA info:
http://alsa-project.org/db/?f=bfb2088b8126962a7b8e0c60c8decb5233697527
Thanks for the post. It would be useful to know the version of Shairport Sync (see REPORTING ISSUES.md) -- could you post what comes back from:
$ shairport-sync -V
please?
That warning:
shairport-sync: warning: audio_alsa: Unable to set hw parameters for device "hdmi:NVidia": Cannot allocate memory.
is an interesting one, and might relate to Groovy Gorilla. I haven't tried it out yet.
Sure, I get:
3.3.8rc1-OpenSSL-Avahi-ALSA-pa-soxr-metadata-sysconfdir:/etc
I now wish I'd done this before rebuilding to get a version string of the previous working version too.
Great, thanks. Could you do:
$ shairport-sync -h
and post the last few lines, where it lists the hardware output devices it can see? It's not always definitive, but it might be useful. It'll be something like:
...
...
Settings and options for the audio backend "alsa":
-d output-device set the output device, default is "default".
-c mixer-control set the mixer control name, default is to use no mixer.
-m mixer-device set the mixer device, default is the output device.
-i mixer-index set the mixer index, default is 0.
hardware output devices:
"hw:Headphones"
"hw:IQaudIODAC"
I just did this actually based on trying something out from another issue.
Available mDNS backends:
avahi
Available audio backends:
alsa (default)
pa
Settings and options for the audio backend "alsa":
-d output-device set the output device, default is "default".
-c mixer-control set the mixer control name, default is to use no mixer.
-m mixer-device set the mixer device, default is the output device.
-i mixer-index set the mixer index, default is 0.
hardware output devices:
"hw:NVidia"
I tried setting the output_device to "hw:NVidia" as above but it can't find the device: warning: the alsa output_device "hw:NVidia" can not be found.
Currently looking at this for inspiration, though I realise it's a different distro:
https://bbs.archlinux.org/viewtopic.php?id=256191
speaker-test -D hw:NVidia -c 8 results in
speaker-test 1.2.3
Playback device is hw:NVidia
Stream parameters are 48000Hz, S16_LE, 8 channels
Using 16 octaves of pink noise
Playback open error: -2,No such file or directory
Sound still working when I play music files or visit a streaming site directly on the machine.
speaker-test -D default -c 8 works.
speaker-test -D hw:0,7 -c 8 gives
speaker-test 1.2.3
Playback device is hw:0,7
Stream parameters are 48000Hz, S16_LE, 8 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 16 to 8544000
Period size range from 8 to 4272000
Using max buffer size 8544000
Periods = 4
Unable to set hw params for playback: Cannot allocate memory
Setting of hwparams failed: Cannot allocate memory
Could be something in the way alsa config is handled in the new ubuntu? Clutching at straws here...
Great stuff, thanks. From the initial error messages, I guess that the default output is in fact a a port into the pulseaudio system; perhaps you'd be good enough to post the output from $ aplay -L and we could check.
[Edit] play → aplay!
Anyway, Shairport Sync requires S16_LE, 2 channel and 44100 fps. Could you post its response to the following, please?
$ speaker-test -c 2 -r 44100 -F S16_LE -D hw: NVidia
aplay -L produces:
Discard all samples (playback) or generate zero samples (capture)
samplerate
Rate Converter Plugin Using Samplerate Library
speexrate
Rate Converter Plugin Using Speex Resampler
jack
JACK Audio Connection Kit
oss
Open Sound System
pulse
PulseAudio Sound Server
upmix
Plugin for channel upmix (4,6,8)
vdownmix
Plugin for channel downmix (stereo) with a simple spacialization
default
Playback/recording through the PulseAudio sound server
hw:CARD=NVidia,DEV=3
HDA NVidia, HDMI 0
Direct hardware device without any conversions
hw:CARD=NVidia,DEV=7
HDA NVidia, HDMI 1
Direct hardware device without any conversions
plughw:CARD=NVidia,DEV=3
HDA NVidia, HDMI 0
Hardware device with all software conversions
plughw:CARD=NVidia,DEV=7
HDA NVidia, HDMI 1
Hardware device with all software conversions
hdmi:CARD=NVidia,DEV=0
HDA NVidia, HDMI 0
HDMI Audio Output
hdmi:CARD=NVidia,DEV=1
HDA NVidia, HDMI 1
HDMI Audio Output
dmix:CARD=NVidia,DEV=3
HDA NVidia, HDMI 0
Direct sample mixing device
dmix:CARD=NVidia,DEV=7
HDA NVidia, HDMI 1
Direct sample mixing device
usbstream:CARD=NVidia
HDA NVidia
USB Stream Output
Yeah, so the default actually routes your audio into the PulseAudio system.
and speaker-test -c 2 -r 44100 -F S16_LE -D hw:NVidia produces:
speaker-test 1.2.3
Playback device is hw:NVidia
Stream parameters are 44100Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Playback open error: -2,No such file or directory
ah ok so it's not using alsa?
Well, if Shairport Sync is using its ALSA backend and is outputting to the default output device, which turns out to be a port into the PulseAudio system, then the audio is being routed eventually into the PulseAudio system.
Do any of the real devices work with 44100 stereo?
$ speaker-test -c 2 -r 44100 -F S16_LE -D hw:CARD=NVidia,DEV=3
or
$ speaker-test -c 2 -r 44100 -F S16_LE -D hw:CARD=NVidia,DEV=7
or
$ speaker-test -c 2 -r 44100 -F S16_LE -D hdmi:CARD=NVidia,DEV=0
or
$ speaker-test -c 2 -r 44100 -F S16_LE -D hdmi:CARD=NVidia,DEV=1
First one doesn't error but I can't hear anything.
Second doesn't error and I get the test noise.
Third doesn't error but I can't hear anything.
Fourth doesn't error and I get the test noise.
Good stuff. Maybe try setting the Shairport Sync output device to one of those that generates noise?
For example, in the alsa stanza:
output_device = "hw:CARD=NVidia,DEV=7";
Ok, just tried that but get shairport-sync: warning: audio_alsa: Unable to set hw parameters for device "hw:CARD=NVidia,DEV=7": Cannot allocate memory.
and also shairport-sync: warning: audio_alsa: Unable to set hw parameters for device "hdmi:CARD=NVidia,DEV=1": Cannot allocate memory.
Thanks. Going back to the speaker test, would you mind posting the first bit of the output from that device please?
Just tried no.2 (whilst attempting to stream):
> speaker-test -c 2 -r 44100 -F S16_LE -D hw:CARD=NVidia,DEV=7
speaker-test 1.2.3
Playback device is hw:CARD=NVidia,DEV=7
Stream parameters are 44100Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Playback open error: -16,Device or resource busy
no. 2 after stopping:
> speaker-test -c 2 -r 44100 -F S16_LE -D hw:CARD=NVidia,DEV=7
speaker-test 1.2.3
Playback device is hw:CARD=NVidia,DEV=7
Stream parameters are 44100Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 44100Hz (requested 44100Hz)
Buffer size range from 64 to 7849792
Period size range from 32 to 3924896
Using max buffer size 7849792
Periods = 4
was set period_size = 3924896
was set buffer_size = 7849792
0 - Front Left
1 - Front Right
Thanks. I’ll have to think about this. It puzzles me why that error message is being given.
Thanks for your help so far.
One thing I notice is that the period size and buffer sizes are both very large, and I just wonder if that's the problem. There are a couple of advanced settings in the alsa stanza. Could you try, say:
period_size = 512;
and
buffer_size = 32768;
(Remember to uncomment the lines to activate them!) It's a wild guess, based on the parameters for another card, but might be worth a try.
ok wow I now have some music through. Some different stuff in the log.
alsa stanza in conf:
alsa =
{
output_device = "hw:CARD=NVidia,DEV=7";
period_size = 512;
buffer_size = 32768;
mixer_control_name = "S/PDIF";
};
log:
shairport-sync[2833]: ALSA lib conf.c:5082:(parse_args) Unknown parameter DEV
shairport-sync[2833]: ALSA lib conf.c:5215:(snd_config_expand) Parse arguments error: No such file or directory
shairport-sync[2833]: ALSA lib control.c:1379:(snd_ctl_open_noupdate) Invalid CTL hw:CARD=NVidia,DEV=7
Great stuff! It seems to be complaining about some part of the name of the output device. It might need a bit of experimentation, e.g. hw:NVidia,7 — circling back to your original parameters, maybe 😬.
Yeah it doesn't seem to like the CARD=..,DEV=.. format. Using my original hw:0,7 also now works but produces:
shairport-sync[2964]: ALSA lib conf.c:5082:(parse_args) Unknown parameter 1
shairport-sync[2964]: ALSA lib conf.c:5215:(snd_config_expand) Parse arguments error: No such file or directory
shairport-sync[2964]: ALSA lib control.c:1379:(snd_ctl_open_noupdate) Invalid CTL hw:0,7
However, hdmi:CARD=NVidia,DEV=1 works but produces:
shairport-sync[2945]: ALSA lib control.c:1379:(snd_ctl_open_noupdate) Invalid CTL hdmi:CARD=NVidia,DEV=1
Might go with hdmi:CARD=NVidia,DEV=1 as it produces one error line instead of three, might poke to get rid of that but so pleased it works again. Thanks so much for your help!
Great. It you manage to get rid of those errors, please let us know.
Errors gone! I just remembered I added a .asoundrc trying out some random config I found (I don't really know what I'm doing)
defaults.pcm.!card "NVidia"
defaults.ctl.!card "NVIdia"
This is my /etc/asound.conf
pcm.!default {
type plug slave.pcm {
type hw card 0 device 7
}
}
I removed the .asoundrc I added. Now, using hw:NVidia,7 works with no log entries. Presumably hw:0,7 will also work in the same way now, but I think I'm done fiddling. Thanks so much for your help.
Scratch that, still getting those log errors after another restart?! Maybe I'll just quit while I'm ahead though - streaming audio does work!
Super. Okay to close the issue?
Yes fine with that. Still working and down to one error using plughw:0,7:
shairport-sync[3067]: ALSA lib control.c:1379:(snd_ctl_open_noupdate) Invalid CTL plughw:0,7.
I think this error might be something to do with old/invalid alsa config somewhere, based on this:
https://bbs.archlinux.org/viewtopic.php?id=255908
However, I'm not going to anger the gods by deleting any alsa stuff. Thanks again for your help and for this great streaming tool.