mikebrady / shairport-sync

AirPlay and AirPlay 2 audio player
Other
7.19k stars 570 forks source link

macOS Configuration #718

Closed hstriepe closed 2 years ago

hstriepe commented 6 years ago

I am trying to set up sh airport-sync installed via HomeBrew and am having trouble.

What am I doing wrong?

If I want to set up a config list, where would it be placed. No samples in /etc...

Thanks, -- Harald

mikebrady commented 6 years ago

Harald, I don't really know my way around the HomeBrew installation, but if you enter $ shairport-sync -V and post the response, we can locate where the config file is expected.

hstriepe commented 6 years ago

Ah, "/usr/local/etc/shairport-sync/shairport-sync.conf"

It works using the system default.

$ shairport-sync -v
Version: "3.1.7-OpenSSL-ao-stdout-pipe-soxr-metadata-sysconfdir:/usr/local/etc/shairport-sync"
statistics_requester status is 0.
daemon status is 0.
deamon pid file is "/usr/local/var/run/shairport-sync.pid".
rtsp listening port is 5000.
udp base port is 6001.
udp port range is 100.
player name is "Neptune".
backend is "(null)".
on-start action is "(null)".
on-stop action is "(null)".
wait-cmd status is 0.
on-start returns output is 0.
mdns backend "(null)".
stuffing option is "0" (0-basic, 1-soxr).
resync time is 0.050000 seconds.
allow a session to be interrupted: 0.
busy timeout time is 120.
drift tolerance is 0.001995 seconds.
password is "(null)".
ignore_volume_control is 0.
volume_max_db is not set
playback_mode is 0 (0-stereo, 1-mono, 1-reverse_stereo, 2-both_left, 3-both_right).
disable_synchronization is 0.
use_mmap_if_available is 1.
output_rate is 44100.
output_format is 3 (0-unknown, 1-S8, 2-U8, 3-S16, 4-S24, 5-S24_3LE, 6-S24_3BE, 7-S32).
audio backend desired buffer length is 1.000000 seconds.
audio backend latency offset is 0.000000 seconds.
audio backend silence lead-in time is -1.000000 seconds. A value -1.0 means use the default.
volume range in dB (zero means use the range specified by the mixer): 0.
zeroconf regtype is "_raop._tcp".
decoders_supported field is 1.
use_apple_decoder is 0.
alsa_use_playback_switch_for_mute is 0.
no special mdns service interface was requested.
configuration file name "/usr/local/etc/shairport-sync/shairport-sync.conf" resolves to "/usr/local/etc/shairport-sync/shairport-sync.conf".
metadata enabled is 0.
metadata pipename is "(null)".
metadata socket address is "(null)" port 0.
metadata socket packet size is "500".
get-coverart is 0.
loudness is 0.
loudness reference level is -20.000000
Successful Startup
mikebrady commented 6 years ago

Thanks. So, in this configuration, Shairport Sync is using the ao backend to connect to the libao audio subsystem. There are no specific libao options in the Shairport Sync configuration file, and if you do $ shairport-sync -h you'll get the command line options you can use. If you look through some of the issues, including the closed issues, you'll find references to the HomeBrew installation which might be useful.

hstriepe commented 6 years ago

Appreciate the help. I will look around.

hstriepe commented 6 years ago

SwitchAudioSource works with the macOS CoreAudio framework. It clearly maps displayed devices to internal. What I have not figured out is what the device options are for libao. Ended up doing a launchctl script hack that saved the default audio device, switched to my desired shairport-sync target, launched shairport-sync as daemon using that default, and switched back the audio device default. Makes my skin crawl...

Later: Interestingly, my hack works on High Sierra, but not Mojave. I can do it live:

But I cannot do it not programmatically at system start. It picks the set default, even with delays.

Oh well, now I just use a simple script menu there... Getting the right command line syntax to switch to the audio device as listed would be the real answer.

whizkid79 commented 5 years ago

Having the same issues here. I'm looking for a way to tell shairport-sync on macOS which audio device and which channels to use.

luckman212 commented 3 years ago

@whizkid79 @hstriepe did you guys ever figure this out? Today I installed shairport-sync on 11.2 using Homebrew 3.0 and got it to play (no pulseaudio required) with this command:

shairport-sync --name=mac-mini --output=ao --statistics

But not sure if there's a better invocation, or any way to use a different backend, since according to the readme:

Note that the installation uses the libao library and so synchronisation is not available — playback glitches will occur occasionally, when the ao system's buffers overflow or underflow.

update: in case anyone reads this. Here's a simple config that lets you start/stop the airplay receiver with just a short simple command.

edit /usr/local/etc/shairport-sync/shairport-sync.conf:

general = {
    name = "mac-mini";
    output_backend = "ao";
};

start daemon:

shairport-sync -d

stop:

shairport-sync -k
linxucc commented 3 years ago

The original issue could be translated to this: How could I select a specific the output device?

The trick is simple, since the developers for now don't bother the device select thing, it just uses AO's default output device, that in this case, is whatever the current audio output device is, usually this is the "built-in output", which satisfies 99% people so it stays this way.

To switch between difference output devices, the right way (the Macintosh way) is to go to "Audio Midi Setup" (use your spotlight search for "midi"), then select which ever device you want, and set it as the default (right click on it, select use this device for sound output).

As most users don't have an "audio interface" (usually used for audio production or high-end sound reproduction), or multiple interfaces or DACs to switch between, this is the place people seldom knows.

Do note, after the switch, you have to manually restart the services, or it won't recognize the change, result in no sound.

Again since this is some niche scenario developers don't bother... The program only reads default devices once at the start of the program...

With my previous hacking experience with this AO thing, I'm quite sure it's capable of select specific audio output device manually. So it's just something not implemented in Shairport-sync. Maybe in the future when I have sometime I'll do this myself.

@hstriepe @whizkid79 @luckman212 in case you guys still needs the answer...

github-actions[bot] commented 2 years ago

This issue has been inactive for 45 days so will be closed 7 days from now. To prevent this, please remove the "stale" label or post a comment.

Badsheep commented 8 months ago

Hi there,

In case someone is interested, I use this command tine to start shairport on my Mac OS, and I can choose the device I need (in my case it's called : "MIO Airplay") :

do shell script "/usr/local/opt/shairport-sync/bin/shairport-sync -d -o ao -- -n 'MIO Airplay'"

I run this command in a script at the start of the computer.