mikebrady / shairport-sync

AirPlay and AirPlay 2 audio player
Other
7.16k stars 569 forks source link

Ver 311 Stretch endpoints out of sync with one another #582

Closed moodeaudio closed 7 years ago

moodeaudio commented 7 years ago

Hi Mike,

I began testing with Stretch and the new ver 3.1.1 of shairpoint sync and I ran into a few issues.

1) Using latest iTunes 12.6.2.20 on Sierra when I send a stream to two Pi's running Raspbian Stretch and ver 3.1.1 the audio is significantly out of sync.

2) After the shairport-sync session ends, its not possible to get any audio output from ALSA for example using MPD. Running the cmd below fixes this condition.

sudo amixer sset <mixer_name> unmute

Btw, lot of nice new features in 311 :-)

-Tim

moodeaudio commented 7 years ago

Hi Mike,

Below is some debug output from one of the Pi's.

pi@rp3:~ $ /usr/local/bin/shairport-sync -vvv -a "RP3 Airplay" -S soxr -w -B /var/www/command/spspre.sh -E /var/www/command/spspost.sh --metadata-pipename=/tmp/shairport-sync-metadata --get-coverart -- -d hw:0 -c "M
Looking for configuration file at full path "/usr/local/etc/shairport-sync.conf"
Value read for output rate is 44100.
alsa output device name is "hw:0".
Open Mixer
Mixer device name is "hw:0".
Mixer Control name is "Master".
Lowest dB value is a mute -- try minimum volume +1
Hardware mixer has dB volume from -103.000000 to 0.000000.
The processor is running little-endian.
Version: "3.1.1-OpenSSL-Avahi-ALSA-stdout-soxr-metadata-sysconfdir:/usr/local/etc"
statistics_requester status is 0.
daemon status is 0.
deamon pid file is "/var/run/shairport-sync/shairport-sync.pid".
rtsp listening port is 5000.
udp base port is 6001.
udp port range is 100.
player name is "RP3 Airplay".
backend is "(null)".
on-start action is "/var/www/command/spspre.sh".
on-stop action is "/var/www/command/spspost.sh".
wait-cmd status is 1.
on-start returns output is 0.
mdns backend "(null)".
userSuppliedLatency is 0.
AirPlayLatency is -1.
iTunesLatency is -1.
forkedDaapdLatency is -1.
stuffing option is "1" (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 0.150000 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 1.
no special mdns service interface was requested.
configuration file name "/usr/local/etc/shairport-sync.conf" resolves to "/usr/local/etc/shairport-sync.conf".
metadata enabled is 1.
metadata pipename is "/tmp/shairport-sync-metadata".
metadata socket address is "(null)" port 0.
metadata socket packet size is "500".
get-coverart is 1.
loudness is 0.
loudness reference level is -20.000000
Successful Startup
avahi: avahi_register.
avahi: register_service.
avahi: service 'A1ACD7F92117@RP3 Airplay' group is not yet committed.
avahi: request to add "_raop._tcp" service with metadata
avahi: service 'A1ACD7F92117@RP3 Airplay' group is registering.
avahi: service 'A1ACD7F92117@RP3 Airplay' successfully added.
New RTSP connection from 192.168.1.155:58605 to self at 192.168.1.169:5000.
    CSeq: 1.
    Content-Type: application/sdp.
    Content-Length: 572.
    User-Agent: iTunes/12.6.2 (Macintosh; OS X 10.12.6).
    Client-Instance: 1DED0D3DC6140141.
    DACP-ID: 1DED0D3DC6140141.
    Active-Remote: 3958771034.
RTSP Packet received of type "ANNOUNCE":
  Type: "CSeq", content: "1"
  Type: "Content-Type", content: "application/sdp"
  Type: "Content-Length", content: "572"
  Type: "User-Agent", content: "iTunes/12.6.2 (Macintosh; OS X 10.12.6)"
  Type: "Client-Instance", content: "1DED0D3DC6140141"
  Type: "DACP-ID", content: "1DED0D3DC6140141"
  Type: "Active-Remote", content: "3958771034"
Play connection from user agent "iTunes/12.6.2 (Macintosh; OS X 10.12.6)".
RTSP Response:
  Type: "CSeq", content: "1"
  Type: "Server", content: "AirTunes/105.1"
    CSeq: 2.
    Transport: RTP/AVP/UDP;unicast;interleaved=0-1;mode=record;control_port=6001;timing_port=6002.
    User-Agent: iTunes/12.6.2 (Macintosh; OS X 10.12.6).
    Client-Instance: 1DED0D3DC6140141.
    DACP-ID: 1DED0D3DC6140141.
    Active-Remote: 3958771034.
RTSP Packet received of type "SETUP":
  Type: "CSeq", content: "2"
  Type: "Transport", content: "RTP/AVP/UDP;unicast;interleaved=0-1;mode=record;control_port=6001;timing_port=6002"
  Type: "User-Agent", content: "iTunes/12.6.2 (Macintosh; OS X 10.12.6)"
  Type: "Client-Instance", content: "1DED0D3DC6140141"
  Type: "DACP-ID", content: "1DED0D3DC6140141"
  Type: "Active-Remote", content: "3958771034"
Active-Remote string seen: "3958771034".
DACP-ID string seen: "1DED0D3DC6140141".
User-Agent is iTunes 10 or better, (actual version is 12); selecting the iTunes latency of 12 frames.
rtp_setup: cport=6001 tport=6002.
Set up play connection from 192.168.1.155 to self at 192.168.1.169.
listening for audio, control and timing on ports 6001, 6002, 6003.
RTSP Response:
  Type: "CSeq", content: "2"
  Type: "Server", content: "AirTunes/105.1"
  Type: "Transport", content: "RTP/AVP/UDP;unicast;interleaved=0-1;mode=record;control_port=6002;timing_port=6003;server_port=6001"
  Type: "Session", content: "1"
Output frame bytes is 4.
Audio receiver -- Server RTP thread starting.
Timing receiver -- Server RTP thread starting.
Output bit depth is 16.
Control receiver -- Server RTP thread starting.
Timing sender thread starting.
    CSeq: 3.
    Session: 1.
    Range: npt=0-.
    RTP-Info: seq=29777;rtptime=3133730796.
    User-Agent: iTunes/12.6.2 (Macintosh; OS X 10.12.6).
    Client-Instance: 1DED0D3DC6140141.
    DACP-ID: 1DED0D3DC6140141.
    Active-Remote: 3958771034.
RTSP Packet received of type "RECORD":
  Type: "CSeq", content: "3"
  Type: "Session", content: "1"
  Type: "Range", content: "npt=0-"
  Type: "RTP-Info", content: "seq=29777;rtptime=3133730796"
  Type: "User-Agent", content: "iTunes/12.6.2 (Macintosh; OS X 10.12.6)"
  Type: "Client-Instance", content: "1DED0D3DC6140141"
  Type: "DACP-ID", content: "1DED0D3DC6140141"
  Type: "Active-Remote", content: "3958771034"
Flush requested up to 3133730795. It seems as if 0 is special.
RTSP Response:
  Type: "CSeq", content: "3"
  Type: "Server", content: "AirTunes/105.1"
  Type: "Audio-Latency", content: "11025"
Open Mixer
Mixer device name is "hw:0".
Mixer Control name is "Master".
    CSeq: 4.
    Session: 1.
    Content-Type: text/parameters.
    Content-Length: 20.
    User-Agent: iTunes/12.6.2 (Macintosh; OS X 10.12.6).
    Client-Instance: 1DED0D3DC6140141.
    DACP-ID: 1DED0D3DC6140141.
    Active-Remote: 3958771034.
RTSP Packet received of type "SET_PARAMETER":
  Type: "CSeq", content: "4"
  Type: "Session", content: "1"
  Type: "Content-Type", content: "text/parameters"
  Type: "Content-Length", content: "20"
  Type: "User-Agent", content: "iTunes/12.6.2 (Macintosh; OS X 10.12.6)"
  Type: "Client-Instance", content: "1DED0D3DC6140141"
  Type: "DACP-ID", content: "1DED0D3DC6140141"
  Type: "Active-Remote", content: "3958771034"
Open Mixer
Mixer device name is "hw:0".
Mixer Control name is "Master".
Setting volume db to -5144.235168.
Open Mixer
Mixer device name is "hw:0".
Mixer Control name is "Master".
RTSP Response:
  Type: "CSeq", content: "4"
  Type: "Server", content: "AirTunes/105.1"
    CSeq: 5.
    Session: 1.
    Content-Type: text/parameters.
    Content-Length: 20.
    User-Agent: iTunes/12.6.2 (Macintosh; OS X 10.12.6).
    Client-Instance: 1DED0D3DC6140141.
    DACP-ID: 1DED0D3DC6140141.
    Active-Remote: 3958771034.
RTSP Packet received of type "SET_PARAMETER":
  Type: "CSeq", content: "5"
  Type: "Session", content: "1"
  Type: "Content-Type", content: "text/parameters"
  Type: "Content-Length", content: "20"
  Type: "User-Agent", content: "iTunes/12.6.2 (Macintosh; OS X 10.12.6)"
  Type: "Client-Instance", content: "1DED0D3DC6140141"
  Type: "DACP-ID", content: "1DED0D3DC6140141"
  Type: "Active-Remote", content: "3958771034"
Open Mixer
Mixer device name is "hw:0".
Mixer Control name is "Master".
Setting volume db to -5144.235168.
Open Mixer
Mixer device name is "hw:0".
Mixer Control name is "Master".
RTSP Response:
  Type: "CSeq", content: "5"
  Type: "Server", content: "AirTunes/105.1"
syncing to seqno 29777.
Hammerton Decoder used on encrypted audio.
Output written using MMAP
    CSeq: 6.
    Session: 1.
    Content-Type: application/x-dmap-tagged.
    Content-Length: 1191.
    RTP-Info: rtptime=3133730796.
    User-Agent: iTunes/12.6.2 (Macintosh; OS X 10.12.6).
    Client-Instance: 1DED0D3DC6140141.
    DACP-ID: 1DED0D3DC6140141.
    Active-Remote: 3958771034.
PCM handle name = 'hw:0'
alsa device parameters:
  access type = MMAP_INTERLEAVED
  format = 'S16_LE' (Signed 16 bit Little Endian)
  subformat = 'STD' (Standard)
  number of channels = 2
  number of significant bits = 16
  rate = 44100 frames per second (precisely).
  precise (rational) rate = 0.000 frames per second (i.e. 0/1088784512).
  period_time = 5804 us (>).
  period_size = 256 frames (precisely).
  buffer_time = 2972154 us (>).
  buffer_size = 131072 frames (>).
  periods_per_buffer = 512 (precisely).
Setting volume db to -5144.235168.
Open Mixer
Mixer device name is "hw:0".
Mixer Control name is "Master".
RTSP Packet received of type "SET_PARAMETER":
  Type: "CSeq", content: "6"
  Type: "Session", content: "1"
  Type: "Content-Type", content: "application/x-dmap-tagged"
  Type: "Content-Length", content: "1191"
  Type: "RTP-Info", content: "rtptime=3133730796"
  Type: "User-Agent", content: "iTunes/12.6.2 (Macintosh; OS X 10.12.6)"
  Type: "Client-Instance", content: "1DED0D3DC6140141"
  Type: "DACP-ID", content: "1DED0D3DC6140141"
  Type: "Active-Remote", content: "3958771034"
received metadata tags in SET_PARAMETER request.
RTSP Response:
  Type: "CSeq", content: "6"
  Type: "Server", content: "AirTunes/105.1"
    CSeq: 7.
    Session: 1.
    Content-Type: image/jpeg.
    Content-Length: 45964.
    RTP-Info: rtptime=3133730796.
    User-Agent: iTunes/12.6.2 (Macintosh; OS X 10.12.6).
    Client-Instance: 1DED0D3DC6140141.
    DACP-ID: 1DED0D3DC6140141.
    Active-Remote: 3958771034.
RTSP Packet received of type "SET_PARAMETER":
  Type: "CSeq", content: "7"
  Type: "Session", content: "1"
  Type: "Content-Type", content: "image/jpeg"
  Type: "Content-Length", content: "45964"
  Type: "RTP-Info", content: "rtptime=3133730796"
  Type: "User-Agent", content: "iTunes/12.6.2 (Macintosh; OS X 10.12.6)"
  Type: "Client-Instance", content: "1DED0D3DC6140141"
  Type: "DACP-ID", content: "1DED0D3DC6140141"
  Type: "Active-Remote", content: "3958771034"
RTSP Response:
  Type: "CSeq", content: "7"
  Type: "Server", content: "AirTunes/105.1"
    CSeq: 8.
    Session: 1.
    Content-Type: text/parameters.
    Content-Length: 44.
    User-Agent: iTunes/12.6.2 (Macintosh; OS X 10.12.6).
    Client-Instance: 1DED0D3DC6140141.
    DACP-ID: 1DED0D3DC6140141.
    Active-Remote: 3958771034.
RTSP Packet received of type "SET_PARAMETER":
  Type: "CSeq", content: "8"
  Type: "Session", content: "1"
  Type: "Content-Type", content: "text/parameters"
  Type: "Content-Length", content: "44"
  Type: "User-Agent", content: "iTunes/12.6.2 (Macintosh; OS X 10.12.6)"
  Type: "Client-Instance", content: "1DED0D3DC6140141"
  Type: "DACP-ID", content: "1DED0D3DC6140141"
  Type: "Active-Remote", content: "3958771034"
RTSP Response:
  Type: "CSeq", content: "8"
  Type: "Server", content: "AirTunes/105.1"
Packet reception interval stats: mean, standard deviation and max for the last 2,500 packets in microseconds:     7979.6,    11765.2,   171175.0.
    CSeq: 9.
    Session: 1.
    RTP-Info: seq=32295;rtptime=3134617132.
    User-Agent: iTunes/12.6.2 (Macintosh; OS X 10.12.6).
    Client-Instance: 1DED0D3DC6140141.
    DACP-ID: 1DED0D3DC6140141.
    Active-Remote: 3958771034.
RTSP Packet received of type "FLUSH":
  Type: "CSeq", content: "9"
  Type: "Session", content: "1"
  Type: "RTP-Info", content: "seq=32295;rtptime=3134617132"
  Type: "User-Agent", content: "iTunes/12.6.2 (Macintosh; OS X 10.12.6)"
  Type: "Client-Instance", content: "1DED0D3DC6140141"
  Type: "DACP-ID", content: "1DED0D3DC6140141"
  Type: "Active-Remote", content: "3958771034"
Flush requested up to 3134617132. It seems as if 0 is special.
RTSP Response:
  Type: "CSeq", content: "9"
  Type: "Server", content: "AirTunes/105.1"
Open Mixer
Mixer device name is "hw:0".
Mixer Control name is "Master".
    CSeq: 10.
    Session: 1.
    User-Agent: iTunes/12.6.2 (Macintosh; OS X 10.12.6).
    Client-Instance: 1DED0D3DC6140141.
    DACP-ID: 1DED0D3DC6140141.
    Active-Remote: 3958771034.
RTSP Packet received of type "TEARDOWN":
  Type: "CSeq", content: "10"
  Type: "Session", content: "1"
  Type: "User-Agent", content: "iTunes/12.6.2 (Macintosh; OS X 10.12.6)"
  Type: "Client-Instance", content: "1DED0D3DC6140141"
  Type: "DACP-ID", content: "1DED0D3DC6140141"
  Type: "Active-Remote", content: "3958771034"
TEARDOWN asking connection to stop
RTSP Response:
  Type: "CSeq", content: "10"
  Type: "Server", content: "AirTunes/105.1"
  Type: "Connection", content: "close"
RTSP shutdown requested.
Closing down RTSP conversation thread...
Open Mixer
Mixer device name is "hw:0".
Mixer Control name is "Master".
Shut down audio, control and timing threads
Control RTP thread interrupted. terminating.
Audio receiver -- Server RTP thread interrupted. terminating.
Timing thread interrupted. terminating.
Wait for timer requester to exit.
rtp_timing_sender thread interrupted. terminating.
Closed and terminated timer requester thread.
Timing RTP thread terminated.
timing thread joined
audio thread joined
control thread joined
Player thread exit
shutting down RTP thread
RTSP conversation thread terminated.
^Cshutdown requested...
avahi: avahi_unregister.
Request to shut down all rtsp conversation threads
asking playing threads to stop
Open Mixer
Mixer device name is "hw:0".
Mixer Control name is "Master".

-Tim

moodeaudio commented 7 years ago

... and below is the config file.

pi@rp3:~ $ cat /usr/local/etc/shairport-sync.conf
// Sample Configuration File for Shairport Sync
// Commented out settings are generally the defaults, except where noted.

// General Settings
general =
{
//      name = "%H"; // This means "Hostname" -- see below. This is the name the service will advertise to iTunes.
//              The default is "Hostname" -- i.e. the machine's hostname with the first letter capitalised (ASCII only.)
//              You can use the following substitutions:
//                              %h for the hostname,
//                              %H for the Hostname (i.e. with first letter capitalised (ASCII only)),
//                              %v for the version number, e.g. 3.0 and
//                              %V for the full version string, e.g. 3.0-OpenSSL-Avahi-ALSA-soxr-metadata-sysconfdir:/etc
//              Overall length can not exceed 50 characters. Example: "Shairport Sync %v on %H".
//      password = "secret"; // leave this commented out if you don't want to require a password
//      interpolation = "basic"; // aka "stuffing". Default is "basic", alternative is "soxr". Use "soxr" only if you have a reasonably fast processor.
//      output_backend = "alsa"; // Run "shairport-sync -h" to get a list of all output_backends, e.g. "alsa", "pipe", "stdout". The default is the first one.
//      mdns_backend = "avahi"; // Run "shairport-sync -h" to get a list of all mdns_backends. The default is the first one.
//      port = 5000; // Listen for service requests on this port
//      udp_port_base = 6001; // start allocating UDP ports from this port number when needed
//      udp_port_range = 100; // look for free ports in this number of places, starting at the UDP port base. Allow at least 10, though only three are needed in a steady state.
//      statistics = "no"; // set to "yes" to print statistics in the log
//      drift_tolerance_in_seconds = 0.002; // allow a timing error of this number of seconds of drift away from exact synchronisation before attempting to correct it
//      resync_threshold_in_seconds = 0.050; // a synchronisation error greater than this number of seconds will cause resynchronisation; 0 disables it
//      log_verbosity = 0; // "0" means no debug verbosity, "3" is most verbose.

//      ignore_volume_control = "no"; // set this to "yes" if you want the volume to be at 100% no matter what the source's volume control is set to.
//      volume_range_db = 60 ; // use this advanced setting to set the range, in dB, you want between the maximum volume and the minimum volume. Range is 30 to 150 dB. Leave it commented out to use mixer's native range.
//      volume_max_db = 0.0 ; // use this advanced setting, which must have a decimal point in it, to set the maximum volume, in dB, you wish to use.
//              The setting is for the hardware mixer, if chosen, or the software mixer otherwise. The value must be in the mixer's range (0.0 to -96.2 for the software mixer).
//              Leave it commented out to use mixer's maximum volume.
//  run_this_when_volume_is_set = "/full/path/to/application/and/args"; //  Run the specified application whenever the volume control is set or changed.
//    The desired AirPlay volume is appended to the end of the command line – leave a space if you want it treated as an extra argument.
//    AirPlay volume goes from 0 to -30 and -144 means "mute".

//      regtype = "_raop._tcp"; // Use this advanced setting to set the service type and transport to be advertised by Zeroconf/Bonjour. Default is "_raop._tcp".
//      playback_mode = "stereo"; // This can be "stereo", "mono", "reverse stereo", "both left" or "both right". Default is "stereo".
//      alac_decoder = "hammerton"; // This can be "hammerton" or "apple". This advanced setting allows you to choose
//              the original Shairport decoder by David Hammerton or the Apple Lossless Audio Codec (ALAC) decoder written by Apple.
//      interface = "name"; // Use this advanced setting to specify the interface on which Shairport Sync should provide its service. Leave it commented out to get the default, which is to select the interface(s) automatically.

//  audio_backend_latency_offset_in_seconds = 0.0; // Set this offset to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -0.1.
// If set too small, buffer underflow occurs on low-powered machines. Too long and the response time to volume changes becomes annoying. Default is 0.15 seconds in the alsa backend, 0.35 seconds in the pa backend and 1.0 seconds otherwise.
audio_backend_buffer_desired_length_in_seconds = 0.15;
//  audio_backend_silent_lead_in_time = 2.0; // This optional advanced setting, from 0.0 and 4.0 seconds, sets the length of the period of silence that precedes the start of the audio. The default is the latency, usually 2.0 seconds. Values greater than the latency are ignored. Values that are too low will affect initial synchronisation.
};

dsp =
{

//////////////////////////////////////////
//  This convolution filter can be used to apply almost any correction to the audio signal, like frequency and phase correction.
//  For example you could measure (with a good microphone and a sweep-sine) the frequency response of your speakers + room,
//  and apply a correction to get a flat response curve.
//////////////////////////////////////////
//
//  convolution = "yes";                  // Activate the convolution filter.
//  convolution_ir_file = "impulse.wav";  // Impulse Response file to be convolved to the audio stream
//  convolution_gain = -4.0;              // Static gain applied to prevent clipping during the convolution process
//  convolution_max_length = 44100;       // Truncate the input file to this length in order to save CPU.

//////////////////////////////////////////
//  This loudness filter is used to compensate for human ear non linearity.
//  When the volume decreases, our ears loose more sentisitivity in the low range frequencies than in the mid range ones.
//  This filter aims at compensating for this loss, applying a variable gain to low frequencies depending on the volume.
//  More info can be found here: https://en.wikipedia.org/wiki/Equal-loudness_contour
//  For this filter to work properly, you should disable (or set to a fix value) all other volume control and only let shairport-sync control your volume.
//  The setting "loudness_reference_volume_db" should be set at the volume reported by shairport-sync when listening to music at a normal listening volume.
//////////////////////////////////////////
//
//  loudness = "yes";                     // Activate the filter
//  loudness_reference_volume_db = -20.0; // Above this level the filter will have no effect anymore. Below this level it will gradually boost the low frequencies.

};

// How to deal with metadata, including artwork
metadata =
{
//      enabled = "no"; // set this to yes to get Shairport Sync to solicit metadata from the source and to pass it on via a pipe
//      include_cover_art = "no"; // set to "yes" to get Shairport Sync to solicit cover art from the source and pass it via the pipe. You must also set "enabled" to "yes".
//      pipe_name = "/tmp/shairport-sync-metadata";
//      pipe_timeout = 5000; // wait for this number of milliseconds for a blocked pipe to unblock before giving up
//      socket_address = "226.0.0.1"; // if set to a host name or IP address, UDP packets containing metadata will be sent to this address. May be a multicast address. "socket-port" must be non-zero and "enabled" must be set to yes"
//      socket_port = 5555; // if socket_address is set, the port to send UDP packets to
//      socket_msglength = 65000; // the maximum packet size for any UDP metadata. This will be clipped to be between 500 or 65000. The default is 500.
};

// Advanced parameters for controlling how a Shairport Sync runs
sessioncontrol = 
{
//      run_this_before_play_begins = "/full/path/to/application and args"; // make sure the application has executable permission. It it's a script, include the #!... stuff on the first line
//      run_this_after_play_ends = "/full/path/to/application and args"; // make sure the application has executable permission. It it's a script, include the #!... stuff on the first line
//      wait_for_completion = "no"; // set to "yes" to get Shairport Sync to wait until the "run_this..." applications have terminated before continuing
// set to "yes" to allow another device to interrupt Shairport Sync while it's playing from an existing audio source
allow_session_interruption = "no";
// wait for this number of seconds after a source disappears before terminating the session and becoming available again.
session_timeout = 120;
};

// Back End Settings

// These are parameters for the "alsa" audio back end.
alsa =
{
//  output_device = "default"; // the name of the alsa output device. Use "alsamixer" or "aplay" to find out the names of devices, mixers, etc.
//  mixer_control_name = "PCM"; // the name of the mixer to use to adjust output volume. If not specified, volume in adjusted in software.
//  mixer_device = "default"; // the mixer_device default is whatever the output_device is. Normally you wouldn't have to use this.
// can be 44100, 88200, 176400 or 352800, but the device must have the capability.
output_rate = 44100;
// can be "U8", "S8", "S16", "S24", "S24_3LE", "S24_3BE" or "S32", but the device must have the capability. Except where stated using (*LE or *BE), endianness matches that of the processor.
output_format = "S16";
// Set to "yes" to disable synchronization. Default is "no".
disable_synchronization = "no";
//  period_size = <number>; // Use this optional advanced setting to set the alsa period size near to this value
//  buffer_size = <number>; // Use this optional advanced setting to set the alsa buffer size near to this value
//  use_mmap_if_available = "yes"; // Use this optional advanced setting to control whether MMAP-based output is used to communicate  with the DAC. Default is "yes"
//  mute_using_playback_switch = "yes"; // Use this optional advanced setting to control whether the snd_mixer_selem_set_playback_switch_all call can be used for muting. Default is yes.
};

// Parameters for the "sndio" audio back end. All are optional.
sndio =
{
//  device = "snd/0"; // optional setting to set the name of the output device. Default is the sndio system default.
//  rate = 44100; // optional setting  which can be 44100, 88200, 176400 or 352800, but the device must have the capability. Default is 44100.
//  format = "S16"; // optional setting  which can be "U8", "S8", "S16", "S24", "S24_3LE", "S24_3BE" or "S32", but the device must have the capability. Except where stated using (*LE or *BE), endianness matches that of the processor.
//  round = <number>; // advanced optional setting to set the period size near to this value
//  bufsz = <number>; // advanced optional setting to set the buffer size near to this value
};

// Parameters for the "pa" PulseAudio  backend.
pa =
{
//  application_name = "Shairport Sync"; //Set this to the name that should appear in the Sounds "Applications" tab when Shairport Sync is active.
};

// Parameters for the "pipe" audio back end, a back end that directs raw CD-style audio output to a pipe. No interpolation is done.
pipe =
{
//  name = "/path/to/pipe"; // there is no default pipe name for the output
};

// These are no configuration file parameters for the "stdout" audio back end. No interpolation is done.

// These are no configuration file  parameters for the "ao" audio back end. No interpolation is done.

// Static latency settings are deprecated and the settings have been removed. 

-Tim

mikebrady commented 7 years ago

Hi Tim, and thanks for the comprehensive report. The synchronisation thing is a bit troubling – it's not something that has occurred with me. However, I have changed the way resynchronisation is being done, so maybe it's buggy. Can I ask if you mean that sync is wrong between the two Pis or between both Pis and the Mac?

You can download a particular version of Shairport Sync by clicking on the Releases tab of the main page. You'll see a list of the releases and you can select an appropriate tar file for downloading.

The mute thing is a side effect of the way Shairport Sync now deals with hardware muting – if hardware muting is enabled, it will leave the device muted when a play session ends. Is that a problem? I guess it could be unmuted at the end of a play session.

Separately, I think I have finally resolved the issue of Shairport Sync dropping off / becoming unavailable after, say, playing a YouTube video on Safari and routine the audio to Shairport Sync, so 3.1.2 should be interesting. I'll await your input first!

moodeaudio commented 7 years ago

Hi Mike,

It turns out that one Pi in my test was running a Kali FIFO re-clocker. This device can add tiny delay as it loads its buffer. I removed it from the test and sync was perfect between the two Pi's :-)

I didn't notice out-of-sync with 302 and the Kali in-place but its possible that it was there and just not noticeable --or-- maybe the new re-sync method needs a bit of tuning.

As far as mute goes, I think the default should be to leave the device unmuted after Airplay session ends. moOde has a "resume MPD playback after Airplay ends" feature, and it supports several other renderers including Squeezelite and UPnP. An unmuted ALSA output is what they expect. There is even some code in moOde startup to unmute ALSA outputs.

Question: does conf param "mute_using_playback_switch control" control the mute/unmute feature?

3.1.2 should really rock!

-Tim

moodeaudio commented 7 years ago

Hi Mike,

Setting the the following conf param on the Pi w/Kali FIFO nicely compensates for the FIFO buffer delay. I used a value of -0.7 to get perfect sync. Playing Apple Music for couple of hours and sounding great.

// Set this offset to compensate for a fixed delay in the audio back end. E.g. if the output device delays by 100 ms, set this to -0.1. audio_backend_latency_offset_in_seconds = 0.0;

-Tim

mikebrady commented 7 years ago

Thanks for the update, Tim. For now, it is reasonable to assume that sync is okay? That way, I can concentrate the unmute feature.

It’s good to hear that that offset parameter works well enough to compensate. It does, of course, mean that the buffer of packets is 0.7 seconds shorter, so it’ll be a bit less robust on a poor network.

Finally, yes, the use of hardware mute in the alsa back end is controlled by the mute_using... parameter.

moodeaudio commented 7 years ago

Yes, sync is ok. I've added the latency setting to moOde's Airplay config screen so I can advise users with Kali that they can try adjusting the setting to compensate for the FIFO delay. Of course, no guarantee it will be effective depending on network quality, etc.

mute_using_playback_switch control = No

Testing the above setting and I'm seeing that ALSA output is indeed left unmuted after Airplay session ends :-)

I'd propose simply defaulting it to No instead of Yes since you don't really know what audio apps the user might want to use after an Airplay session ends.

-Tim

mikebrady commented 7 years ago

Okay, thanks. Let me think, for a short time!, about the implications of defaulting to “No”.

PeterPablo commented 7 years ago

Perfect, thank you for the issue and discussion. I updated to 3.2d3 and had the same issue with muting as I use a kodi instance for radio playback. That of course now stopped working once a shairport-sync playback session happened. Setting mute_using_playback_switch = "no"; solves this issue.

mikebrady commented 7 years ago

Thanks Peter. I'm just checking back to the original point at which the change was made.

mikebrady commented 7 years ago

I just pushed an update – 3.2d4 – with the default for mute_using_playback_switch set to "no" by default. Thanks for your help clarifying the issue.

moodeaudio commented 7 years ago

Thats great, Mike!

I'll close the issue now.