forked from mikebrady/shairport-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shairport-sync.html
871 lines (566 loc) · 42.4 KB
/
shairport-sync.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
<body text="#000000" link="#0000ff" bgcolor="#ffffff"><center><table width="80%">
<tr><td><h1>shairport-sync</h1>
<h2>Synchronised Audio Player for iTunes / AirPlay</h2>
<h2>Synopsis</h2>
<b>
shairport-sync <b>[-dvw]</b>
<b>[-a </b><em>name</em><b>]</b>
<b>[-A </b><em>latency</em><b>]</b>
<b>[-B </b><em>command</em><b>]</b>
<b>[-c </b><em>configurationfile</em><b>]</b>
<b>[-E </b><em>command</em><b>]</b>
<b>[--forkedDaapdLatency=</b><em>latency</em><b>]</b>
<b>[--get-cover-art]</b>
<b>[-i </b><em>latency</em><b>]</b>
<b>[-L </b><em>latency</em><b>]</b>
<b>[-m </b><em>backend</em><b>]</b>
<b>[--meta-dir=</b><em>directory</em><b>]</b>
<b>[-o </b><em>backend</em><b>]</b>
<b>[--password=</b><em>secret</em><b>]</b>
<b>[-r </b><em>threshold</em><b>]</b>
<b>[--statistics]</b>
<b>[-S </b><em>mode</em><b>]</b>
<b>[-t </b><em>timeout</em><b>]</b>
<b>[--tolerance=</b><em>frames</em><b>]</b>
<b>[-- </b><em>audio_backend_options</em><b>]</b>
<br>
shairport-sync <b>-D</b><br>
shairport-sync <b>-k</b><br>
shairport-sync <b>-h</b><br>
shairport-sync <b>-R</b><br>
shairport-sync <b>-V</b><br>
</b>
<h2>Description</h2>
<p>shairport-sync plays audio streamed from iTunes or from an AirPlay
device to an Advanced Linux Sound Architecture (ALSA) compatible audio output device.</p>
<p>A feature of shairport-sync is that the audio is played synchronously.
This means that if many devices are playing the same stream at the same
time, all the outputs will stay in step with one another.
This allows multiple devices to play the same source without getting out of phase with one another,
enabling, for example, simultaneous multi-room operation.
</p>
<p>shairport-sync can be compiled to stream audio, without synchronisation, to a pipe, to stdout or to a libao output device (an "AO" device). It can also be compiled to stream metadata to a pipe or socket.</p>
<p>Settings can be made using the configuration file (recommended for all new installations) or by using command-line options.</p>
<h2>Configuration File Settings</h2>
<p>You should use the configuration file for setting up shairport-sync.
This file is normally <em>/etc/shairport-sync.conf</em>.
You may need to have root privileges to modify it.</p>
<p>Settings are organised into groups, for example, there is a "general" group of
standard settings, and there is an "alsa" group with settings that pertain to the ALSA
back end. Here is an example of a typical configuration file:</p>
<p><b>general = {</b></p>
<p><p><b>name = "Mike's Boombox";</b></p></p>
<p><p><b>interpolation = "soxr";</b></p></p>
<p><p><b>password = "secret";</b></p></p>
<p><b>};</b></p>
<p><b></b></p>
<p><b>alsa = {</b></p>
<p><p><b>output_device = "hw:0";</b></p></p>
<p><p><b>mixer_control_name = "PCM";</b></p></p>
<p><b>};</b></p>
<p>Most settings have sensible default values, so -- as in the example above -- users generally only need to set (1) the service name, (2) a password (if desired) and
(3) the output device. If the output device has a mixer that can be used for volume control, then (4) the volume control's name should be specified. It is highly desirable to use the output device's mixer for volume control, if available -- response time is reduced to zero and the processor load is reduced. In the example above, "soxr" interpolation was also enabled.</p>
<p>A sample configuration file with all possible settings, but with all of them commented out, is installed at <em>/etc/shairport-sync.conf.sample</em>.</p>
<p>To retain backwards compatibility with previous versions of shairport-sync
you can use still use command line options, but any new features, etc. will
be available only via configuration file settings.</p>
<p>The configuration file is processed using the <em>libconfig</em> library
-- see <a href = "http:https://www.hyperrealm.com/libconfig/libconfig_manual.html">http:https://www.hyperrealm.com/libconfig/libconfig_manual.html</a>.</p>
<p><b>"GENERAL" SETTINGS</b></p>
<p>These are the settings available within the <b>general</b> group:</p>
<p><b>name=</b><em>"service_name"</em><b>;</b></p>
<p>Use this <em>service_name</em> to identify this player in iTunes, etc.</p>
<p>The following substitutions are allowed:
<b>%h</b> for the computer's hostname,
<b>%H</b> for the computer's hostname with the first letter capitalised (ASCII only),
<b>%v</b> for the shairport-sync version number, e.g. "2.8.4" and
<b>%V</b> for the shairport-sync version string, e.g. "2.8.4-OpenSSL-Avahi-ALSA-soxr-metadata".</p>
<p>The default is "%H", which is replaced by the hostname with the first letter capitalised.</p>
<p><b>password=</b><em>"password"</em><b>;</b></p>
Require the password <em>password</em> to connect to the service. If you leave this setting commented out, no password is needed.
<p><b>interpolation=</b><em>"mode"</em><b>;</b></p>
Interpolate, or "stuff", the audio stream using the <em>mode</em>. Interpolation here refers to the
process of adding or removing frames of audio to or from the
stream sent to the output device to keep it exactly in synchrony
with the player.
The default mode, "basic", is normally almost completely inaudible.
The alternative mode, "soxr", is even less obtrusive but
requires much more processing power. For this mode, support for
libsoxr, the SoX Resampler Library, must be selected when
shairport-sync is compiled.
<p><b>statistics=</b><em>"setting"</em><b>;</b></p>
Use this <em>setting</em> to enable ("yes") or disable ("no") the output of some statistical information on the console or in the log. The default is to disable statistics.
<p><b>mdns_backend=</b><em>"backend"</em><b>;</b></p>
shairport-sync has a number of modules of code ("backends") for interacting with the mDNS service to be used to advertise itself. Normally, the first mDNS backend that works is selected. This setting forces the selection of the specific mDNS <em>backend</em>. The default is "avahi". Perform the command <b>shairport-sync -h</b> to get a list of available mDNS modules.
<p><b>output_backend=</b><em>"backend"</em><b>;</b></p>
shairport-sync has a number of modules of code ("backends") through which audio is output. Normally, the first audio backend that works is selected. This setting forces the selection of the specific audio <em>backend</em>. The default is "alsa". Perform the command <b>shairport-sync -h</b> to get a list of available audio backends. Only the alsa backend supports synchronisation.
<p><b>port=</b><em>portnumber</em><b>;</b></p>
Use this to specify the <em>portnumber</em> shairport-sync uses to listen for service requests from iTunes, etc. The default is port 5000.
<p><b>udp_port_base=</b><em>portnumber</em><b>;</b></p>
When shairport-sync starts to play audio, it establises three UDP connections to the audio source. Use this setting to specify the starting <em>portnumber</em> for these three ports. It will pick the first three unused ports starting from <em>portnumber</em>. The default is port 6001.
<p><b>udp_port_range=</b><em>range</em><b>;</b></p>
Use this in conjunction with the prevous setting to specify the <em>range</em> of ports that can be checked for availability. Only three ports are needed. The default is 100, thus 100 ports will be checked from port 6001 upwards until three are found.
<p><b>drift=</b><em>frames</em><b>;</b></p>
Allow playback to drift up to <em>frames</em> out of exact synchronization before attempting to correct it.
The default is 88 frames, i.e. 2 ms. The smaller the tolerance, the more likely it is that overcorrection will occur.
Overcorrection is when more corrections (insertions and deletions) are made than are strictly necessary to keep the stream in sync. Use the <b>statistics</b> setting to
monitor correction levels. Corrections should not greatly exceed net corrections.
<p><b>resync_threshold=</b><em>threshold</em><b>;</b></p>
Resynchronise if timings differ by more than <em>threshold</em> frames.
If the output timing differs from the source timing by more than
the threshold, output will be muted and a full resynchronisation
will occur. The default threshold is 2,205 frames, i.e. 50
milliseconds. Specify 0 to disable resynchronisation.
<p><b>log_verbosity=</b><em>0</em><b>;</b></p>
Use this to specify how much debugging information should be output or logged. "0" means no debug information, "3" means most debug information. The default is "0".
<p><b>ignore_volume_control=</b><em>"choice"</em><b>;</b></p>
Set this <em>choice</em> to "yes" if you want the volume to be at 100% no matter what the source's volume control is set to. This might be useful if you want to set the volume on the output device, independently of the setting at the source. The default is "no".
<p><b>volume_range_db=</b><em>dBvalue</em><b>;</b></p>
<p>Use this <em>dBvalue</em> to reduce or increase the attenuation range, in decibels, between the minimum and maximum volume.</p>
<p>For example, if a mixer has a minimum volume of -80 dB and a maximum of +20 dB, you might wish to use only 60 dB of the 100 dB available.
This might be because the sound becomes inaudible at the lowest setting and unbearably loud at the highest setting --
indeed, many domestic HiFi systems have a volume control range of just 60 to 80dB.</p>
<p>Another potential use might be where the range specified by the mixer does not match the capabilities of the device.
For example, the Raspberry Pi's DAC that feeds the built-in audio jack claims a range of 106 dB but has a useful range of only about 30 dB.
The setting allows you to specify the maximum range from highest to lowest.
The range suggested for the Raspberry Pi's built-in audio DAC, which feeds the headphone jack, is 30.
Using it in this case gives the volume control a much more useful range of settings.</p>
<p>As a third example, you can actually extend the range provided by a mixer.
Many cheaper DACs have hardware mixers that offer a restricted attenuation range.
If you specify a volume range greater than the range of the mixer, software attenuation and hardware attenuation
will be combined to give the specified range.</p>
<p>If you omit this setting, the full "native" range of the mixer is used.</p>
<p><b>regtype=</b><em>"regTypeString"</em><b>;</b></p>
Use this advanced setting to set the service type and transport to be advertised by Zeroconf/Bonjour. Default is "_raop._tcp".
<p><b>playback_mode=</b><em>"mode"</em><b>;</b></p>
The <em>mode</em> can be "stereo" or "mono". Default is "stereo".
<p><b>"ALSA" SETTINGS</b></p>
<p>These settings are for the ALSA back end, used to communicate with audio output devices in the ALSA system.
(By the way, you can use tools such as <b>alsamixer</b> or <b>aplay</b> to discover what devices are available.)
Use these settings to select the output device and the mixer control to be used to control the output volume.
You can additionally set the desired size of the output buffer and you can adjust overall latency. Here are the <b>alsa</b> group settings:</p>
<p><b>output_device=</b><em>"output_device"</em><b>;</b></p>
Use the output device called <em>output_device</em>. The default is the device called "default".
<p><b>mixer_control_name=</b><em>"name"</em><b>;</b></p>
Specify the <em>name</em> of the mixer control to be used by shairport-sync to control the volume.
The mixer control must be on the mixer device, which by default is the output device.
If you do not specify a mixer control name, shairport-sync will adjust the volume in software.
<p><b>mixer_type=</b><em>"mixer_type"</em><b>;</b></p>
This setting is deprecated and is ignored. For your information, its functionality has been automatically incorporated in the mixer_control_name setting
-- if you specify a mixer name with the mixer_control_name setting, it is assumed that the mixer is implemented in hardware.
<p><b>mixer_device=</b><em>"mixer_device"</em><b>;</b></p>
By default, the mixer is assumed to be output_device. Use this setting to specify a device other than the output device.
<p><b>audio_backend_latency_offset=</b><em>offset</em><b>;</b></p>
Set this <em>offset</em>, in frames, to compensate for a fixed delay in the audio back end.
For example, if the output device delays by 100 ms, set this to -4410.
<p><b>audio_backend_buffer_desired_length=</b><em>length</em><b>;</b></p>
Use this to set the desired number frames to be in the output device's hardware output buffer.
The default is 6,615 frames, or 0.15 seconds. If set too small, buffer underflow may occur on low-powered machines.
If too large, the response times when using software volume control (i.e. when not using a mixer control to control volume) become annoying,
or it may exceed the hardware buffer size.
It may need to be larger on low-powered machines that are also performing other tasks, such as processing metadata.
<p><b>disable_synchronization=</b><em>"no"</em><b>;</b></p>
This is an advanced setting and is for debugging only. Set to "yes" to disable synchronization. Default is "no".
If you use it to disable synchronisation, then sooner or later you'll experience audio glitches due to
audio buffer overflow or underflow.
<p><b>period_size=</b><em>number</em><b>;</b></p>
Use this optional advanced setting to set the alsa period size near to this value.
<p><b>buffer_size=</b><em>number</em><b>;</b></p>
Use this optional advanced setting to set the alsa buffer size near to this value.
<p><b>"PIPE" SETTINGS</b></p>
<p>These settings are for the PIPE backend, used to route audio to a named unix pipe. The audio is in raw CD audio format: PCM 16 bit little endian, 44,100 samples per second,
interleaved stereo.</p>
<p>Use the <em>name</em> setting to set the name and location of the pipe.</p>
<p>There are two further settings affecting timing that might be useful if the pipe reader is, for example,
a program to play an audio stream such as <b>aplay</b>. The <em>audio_backend_latency_offset</em> affects precisely
when the first audio packet is sent
and the <em>audio_backend_buffer_desired_length</em> setting affects the nominal output buffer size.</p>
<p>These are the settings available within the <b>pipe</b> group:</p>
<p><b>name=</b><em>"/path/to/pipe"</em><b>;</b></p>
Use this to specify the name and location of the pipe. The pipe will be created and opened when shairport-sync starts up
and will be closed upon shutdown.
Frames of audio will be sent to the pipe in packets of 352 frames and will be discarded if the pipe has not have a reader attached.
The sender will wait for up to five seconds for a packet to be written before discarding it.
<p><b>audio_backend_latency_offset=</b><em>offset_in_frames</em><b>;</b></p>
Packets of audio frames are written to the pipe synchronously -- that is, they are written at exactly the time they should be played.
You can offset the time of initial audio output relative to its nominal time using this setting.
For example to send an audio stream to the pipe 100 milliseconds before it is due to be played, set this to -4410. Default setting is 0.
<p><b>audio_backend_buffer_desired_length=</b><em>buffer_length_in_frames</em><b>;</b></p>
Use this setting, in frames, to set the size of the output buffer. It works by determining how soon the second and subsequent packets of audio frames are sent to the pipe.
For example, if you send the first packet of audio exactly when it is due and, using a <em>audio_backend_buffer_desired_length</em> setting of 44100,
send subsequent packets of audio a second before they are due to be played, they will be buffered in the pipe reader's buffer, giving it a nominal buffer size of 44,100 frames.
Note that if the pipe reader consumes audio packets faster or slower than they are supplied, the buffer will eventually empty or overflow --
shairport-sync performs no stuffing or interpolation when writing to a pipe. Default setting is 44,100 frames.
<p><b>"STDOUT" SETTINGS</b></p>
<p>These settings are for the STDOUT backend, used to route audio to standard output ("stdout").
The audio is in raw CD audio format: PCM 16 bit little endian, 44,100 samples per second, interleaved stereo.</p>
<p>There are two settings affecting timing that might be useful if the stdout reader is, for example,
a program to play an audio stream such as <b>aplay</b>. The <em>audio_backend_latency_offset</em> affects precisely when the first audio packet is sent
and the <em>audio_backend_buffer_desired_length</em> setting affects the nominal output buffer size.</p>
<p>These are the settings available within the <b>stdout</b> group:</p>
<p><b>audio_backend_latency_offset=</b><em>offset_in_frames</em><b>;</b></p>
Packets of audio frames are written to stdout synchronously -- that is, they are written at exactly the time they should be played.
You can offset the time of initial audio output relative to its nominal time using this setting.
For example to send an audio stream to stdout 100 milliseconds before it is due to be played, set this to -4410. Default setting is 0.
<p><b>audio_backend_buffer_desired_length=</b><em>buffer_length_in_frames</em><b>;</b></p>
Use this setting, in frames, to set the size of the output buffer. It works by determining how soon the second and subsequent packets of audio frames are sent to stdout.
For example, if you send the first packet of audio exactly when it is due and, using a <em>audio_backend_buffer_desired_length</em> setting of 44100,
send subsequent packets of audio a second before they are due to be played, they will be buffered in the stdout reader's buffer, giving it a nominal buffer size of 44,100 frames.
Note that if the stdout reader consumes audio packets faster or slower than they are supplied, the buffer will eventually empty or overflow --
shairport-sync performs no stuffing or interpolation when writing to stdout. Default setting is 44,100 frames.
<p><b>"AO" SETTINGS</b></p>
<p>These settings are for the AO backend, used for the libao audio library.</p>
<p>There are two settings affecting timing. The <em>audio_backend_latency_offset</em> affects precisely when the first audio packet is sent
and the <em>audio_backend_buffer_desired_length</em> setting affects the nominal output buffer size.</p>
<p>These are the settings available within the <b>ao</b> group:</p>
<p><b>audio_backend_latency_offset=</b><em>offset_in_frames</em><b>;</b></p>
Packets of audio frames are written to the libao system synchronously -- that is, they are written at exactly the time they should be played.
You can offset the time of initial audio output relative to its nominal time using this setting.
For example to send an audio stream to stdout 100 milliseconds before it is due to be played, set this to -4410. Default setting is 0.
<p><b>audio_backend_buffer_desired_length=</b><em>buffer_length_in_frames</em><b>;</b></p>
Use this setting, in frames, to set the size of the output buffer. It works by determining how soon the second and subsequent packets of
audio frames are sent to the libao system.
For example, if you send the first packet of audio exactly when it is due and, using a <em>audio_backend_buffer_desired_length</em> setting of 44100,
send subsequent packets of audio a second before they are due to be played, they will be buffered in the stdout reader's buffer, giving it a nominal buffer size of 44,100 frames.
Note that if the libao system consumes audio packets faster or slower than they are supplied, the buffer will eventually empty or overflow --
shairport-sync performs no stuffing or interpolation when writing to libao. Default setting is 44,100 frames.
<p><b>"METADATA" SETTINGS</b></p>
<p>shairport-sync can process metadata provided by the source, such as Track Number, Album Name, cover art, etc. and can provide additional metadata such as volume level,
pause/resume, etc. It sends the metadata to a pipe, by default <em>/tmp/shairport-sync-metadata</em>.
To process metadata, shairport-sync must have been compiled with metadata support included.
You can check that this is so by running the command <b>$ shairport-sync -V</b>; the identification string will contain the word <b>metadata</b>.</p>
<p>Please note that different sources provide different levels of metadata. Some provide a lot; some provide almost none.</p>
<p>The <b>metadata</b> group of settings allow you to enable metadata handling and to control certain aspects of it:</p>
<p><b>enabled=</b><em>"choice"</em><b>;</b></p>
Set the <em>choice</em> to "yes" to enable shairport-sync to look for metadata from the audio source and to forward it,
along with metadata generated by shairport-sync itself, to the metadata pipe. The default is "no".
<p><b>include_cover_art=</b><em>"choice"</em><b>;</b></p>
Set the <em>choice</em> to "yes" to enable shairport-sync to look for cover art from the audio source and to include it in the feed to the metadata pipe.
You must also enable metadata (see above).
One reason for not including cover art is that the images can sometimes be very large and may delay transmission of subsequent metadata through the pipe.
The default is "no".
<p><b>pipe_name=</b><em>"filepathname"</em><b>;</b></p>
Specify the absolute path name of the pipe through which metadata should be sent The default is <em>/tmp/shairport-sync-metadata</em>.
<p><b>socket_address=</b><em>"hostnameOrIP"</em><b>;</b></p>
If <em>hostnameOrIP</em> is set to a host name or and IP address, UDP packets containing metadata will be sent to this address.
May be a multicast address. Additionally, <em>socket-port</em> must be non-zero and <em>enabled</em> must be set to "yes".
<p><b>socket_port=</b><em>port</em><b>;</b></p>
If <b>socket_address</b> is set, use <em>port</em> to specify the port to send UDP packets to. Must not be zero.
<p><b>socket_msglength=</b><em>65000</em><b>;</b></p>
The maximum packet size for any UDP metadata. This must be between 500 or 65000. The default is 500.
<p><b>"SESSIONCONTROL" SETTINGS</b></p>
<p>shairport-sync can run programs just before it starts to play an audio stream and just after it finishes.
You specify them using the sessioncontrol group settings run_this_before_play_begins and run_this_after_play_ends.</p>
<p><b>run_this_before_play_begins=</b><em>"/path/to/application and args"</em><b>;</b></p>
Here you can specify a program and its arguments that will be run just before a play session begins. Be careful to include the full path to the application.
The application must be marked as executable and, if it is a script, its first line must begin with the standard <em>#!/bin/...</em> as appropriate.
<p><b>run_this_after_play_ends=</b><em>"/path/to/application and args"</em><b>;</b></p>
Here you can specify a program and its arguments that will be run just after a play session ends. Be careful to include the full path to the application.
The application must be marked as executable and, if it is a script, its first line must begin with the standard <em>#!/bin/...</em> as appropriate.
<p><b>wait_for_completion=</b><em>"choice"</em><b>;</b></p>
Set <em>choice</em> to "yes" to make shairport-sync wait until the programs specified in the <b>run_this_before_play_begins</b>
and <b>run_this_after_play_ends</b> have completed execution before continuing. The default is "no".
<p><b>allow_session_interruption=</b><em>"choice"</em><b>;</b></p>
If <b>choice</b> is set to "yes", then another source will be able to interrupt an existing play session and start a new one.
When set to "no" (the default), other devices attempting to interrupt a session will fail, receiving a busy signal.
<p><b>session_timeout=</b><em>seconds</em><b>;</b></p>
If a play session has been established and the source disappears without warning (such as a device going out of range of a network)
then wait for <em>seconds</em> seconds before ending the session. Once the session has terminated, other devices can use it.
The default is 120 seconds.
<p><b>"LATENCIES" SETTINGS</b></p>
<p>The latencies settings are now deprecated. Do not use them for new installations. They will be removed from a future version of shairport-sync.</p>
<p>Latency is the exact time from a sound signal's original timestamp until that signal actually "appears" on the output of the audio output device,
usually a Digital to Audio Converter (DAC), irrespective of any internal delays, processing times, etc. in the computer.</p>
<p>shairport-sync now sets latencies automatically using information supplied by the source, typically either 88,200 or 99,577 frames.</p>
<p>The following relates to the old scheme of using fixed latencies, which ignored the latency information supplied by the source.
There are four default latency settings. One latency matches the latency used by recent versions of
iTunes when playing audio and another matches the latency
used by so-called "AirPlay" devices, including iOS devices and iTunes and Quicktime Player when they are playing video.
A third latency is used when the audio source is forked-daapd. The fourth latency is the default if no other latency is chosen and is used for older versions of iTunes.</p>
<p>Note: If you are thinking of changing latencies to compensate for a delay in the audio output device, then
instead of changing these individual latencies, use the <b>audio_backend_latency_offset</b> setting in the <b>alsa</b> group
(or the appropriate other group if you're not outputing through the alsa backend).</p>
<p><b>itunes=</b><em>latency</em><b>;</b></p>
This is the <em>latency</em>, in frames, used for iTunes 10 or later. Default is 99,400.
<p><b>airplay=</b><em>latency</em><b>;</b></p>
This is the <em>latency</em>, in frames, used for AirPlay devices, including iOS devices and iTunes and Quicktime Player when they are playing video. Default is 88,200.
<p><b>forkedDaapd=</b><em>latency</em><b>;</b></p>
This is the <em>latency</em>, in frames, used for forkedDaapd sources. Default is 99,400.
<p><b>default=</b><em>latency</em><b>;</b></p>
This is the <em>latency</em>, in frames, used when the source is unrecognised. Default is 88,200.
<h2>Options</h2>
<p>This section is about the command-line options available in shairport-sync.</p>
<p>Note: if you are setting up shairport-sync for the first time or are updating an existing installation,
you are encouraged to use the configuration file settings described above. Most of the command-line options described below
simply replicate the configuration settings and are retained to provide backward compatibility with older installations of shairport-sync.</p>
<p>Many command-line options take sensible default values, so you can normally
ignore most of them. See the EXAMPLES section for typical usages.</p>
<p>There are two kinds of command-line options for shairport-sync:
regular <b>program options</b> and <b>audio backend options</b>.
Program options are
always listed first, followed by any audio backend options, preceded by
a <b>--</b> symbol.</p>
<h2>Program Options</h2>
<p>These command-line options are used by shairport-sync itself.</p>
<p><b>-a </b><em>service name</em><b> | --name=</b><em>service name</em></p>
<p>
Use this <em>service name</em> to identify this player in iTunes, etc.
<p>The following substitutions are allowed:
<b>%h</b> for the computer's hostname,
<b>%H</b> for the computer's hostname with the first letter capitalised (ASCII only),
<b>%v</b> for the shairport-sync version number, e.g. "2.8.4" and
<b>%V</b> for the shairport-sync version string, e.g. "2.8.4-OpenSSL-Avahi-ALSA-soxr-metadata".</p>
<p>The default is "%H", which is replaced by the hostname with the first letter capitalised.</p>
</p>
<p><b>-A | --AirPlayLatency=</b><em>latency</em></p>
<p>
Use this <em>latency</em>, in frames, for audio streamed from an AirPlay
device. The default is 88,200 frames, where there are 44,100
frames to the second.
</p>
<p>Please note that this feature is deprecated and will be removed in a future version of shairport-sync.</p>
<p><b>-B </b><em>program</em><b> | --on-start=</b><em>program</em></p>
<p>
Execute <em>program</em> when playback is about to begin. Specify the
full path to the program, e.g. <em>/usr/bin/logger</em>.
Executable scripts can be used, but they must have <em>#!/bin/sh</em> (or
whatever is appropriate) in the headline.</p>
<p>If you want shairport-sync to wait until the command has
completed before starting to play, select the <b>-w</b> option as well.
</p>
<p><b>-c </b><em>filename</em><b> | --configfile=</b><em>filename</em></p>
<p>
Read configuration settings from <em>filename</em>. The default is to read them from <em>/etc/shairport-sync.conf</em>. For information about configuration settings, see the "Configuration File Settings" section above.
</p>
<p><b>-D | --disconnectFromOutput</b></p>
<p>
Disconnect the shairport-sync daemon from the output device and
exit. (Requires that the daemon has written its PID to an agreed
file -- see the <b>-d</b> option).
</p>
<p>Please note that this feature is deprecated and will be removed in a future version of shairport-sync.</p>
<p><b>-d | --daemon</b></p>
<p>
Instruct shairport-sync to demonise itself. It will write its
Process ID (PID) to a file, usually at
<em>/var/run/shairport-sync.pid</em>, which is used by the
<b>-k</b>, <b>-D</b> and <b>-R</b> options to locate
the daemon at a later time.
</p>
<p><b>-E </b><em>program</em><b> | --on-stop=</b><em>program</em></p>
<p>
Execute <em>program</em> when playback has ended. Specify the
full path to the program, e.g. <em>/usr/bin/logger</em>.
Executable scripts can be used, but they must have <em>#!/bin/sh</em> (or
whatever is appropriate) in the headline.</p>
<p>If you want shairport-sync to wait until the command has
completed before continuing, select the <b>-w</b> option as well.
</p>
<p><b>--forkedDaapdLatency=</b><em>latency</em></p>
<p>
Use this <em>latency</em>, in frames, for audio streamed from a forked-daapd based
source. The default is 99,400 frames, where there are 44,100
frames to the second.
</p>
<p>Please note that this feature is deprecated and will be removed in a future version of shairport-sync.</p>
<p><b>--get-coverart</b></p>
<p>
This option requires the <b>--meta-dir</b> option to be set, and enables
shairport-sync to request cover art from the source and to transmit it through
the metadata pipe.</p>
<p>Please note that cover art data may be very large, and may place too great a
burden on your network.
</p>
<p><b>-h | --help</b></p>
<p>
Print brief help message and exit.
</p>
<p><b>-i | --iTunesLatency=</b><em>latency</em></p>
<p>
Use this <em>latency</em>, in frames, for audio streamed from an iTunes
source, where iTunes is Version 10 or later. The default is 99,400 frames, where there are 44,100
frames to the second. If the source is iTunes but is earler than Version 10, the <em>default latency</em> is used (see the <b>-L</b> option). Some third party programs masquerade as older versions of iTunes.
</p>
<p>Please note that this feature is deprecated and will be removed in a future version of shairport-sync.</p>
<p><b>-k | --kill</b></p>
<p>
Kill the shairport-sync daemon and exit. (Requires that the daemon has
written its PID to an agreed file -- see the <b>-d</b> option).
</p>
<p><b>-L | --latency=</b><em>latency</em></p>
<p>
Use this to set the <em>default latency</em>, in frames, for audio coming from an unidentified source or from an iTunes Version 9 or earlier source. The standard value for the <em>default latency</em> is 88,200 frames, where there are 44,100
frames to the second.
</p>
<p>Please note that this feature is deprecated and will be removed in a future version of shairport-sync.</p>
<p><b>--meta-dir=</b><em>directory</em></p>
<p>
Listen for metadata coming from the source and send it, along with metadata from
shairport-sync itself, to a pipe called <em>shairport-sync-metadata</em>
in the <em>directory</em> you specify. If you add the <b>--get-cover-art</b> then
cover art will be sent through the pipe too. See <a href = "https://github.com/mikebrady/shairport-sync-metadata-reader">https://github.com/mikebrady/shairport-sync-metadata-reader</a>
for a sample metadata reader.
</p>
<p><b>-m </b><em>mdnsbackend</em><b> | --mdns=</b><em>mdnsbackend</em></p>
<p>
Force the use of the specified mDNS backend to advertise the
player on the network. The default is to try all mDNS backends until one
works.
</p>
<p><b>-o </b><em>outputbackend</em><b> | --output=</b><em>outputbackend</em></p>
<p>
Force the use of the specified output backend to play the audio.
The default is to try the first one. (This is not used at
present.)
</p>
<p><b>-p </b><em>port</em><b> | --port=</b><em>port</em></p>
<p>
Listen for play requests on <em>port</em>. The default is to use port
5000.
</p>
<p><b>--password=</b><em>secret</em></p>
<p>
Require the password <em>secret</em> to be able to connect and stream to the service.
</p>
<p><b>-R | --reconnectToOutput</b></p>
<p>
Reconnect the shairport-sync daemon to the output device and
exit. It may take a few seconds to synchronise. (Requires that
the daemon has written its PID to an agreed file -- see the <b>-d</b>
option).
</p>
<p>Please note that this feature is deprecated and will be removed in a future version of shairport-sync.</p>
<p><b>-r </b><em>threshold</em><b> | --resync=</b><em>threshold</em></p>
<p>
Resynchronise if timings differ by more than <em>threshold</em> frames.
If the output timing differs from the source timing by more than
the threshold, output will be muted and a full resynchronisation
will occur. The default threshold is 2,205 frames, i.e. 50
milliseconds. Specify <b>0</b> to disable resynchronisation.
</p>
<p><b>--statistics</b></p>
<p>
Print some statistics in the standard output, or in the logfile if in daemon mode.
</p>
<p><b>-S </b><em>mode</em><b> | --stuffing=</b><em>mode</em></p>
<p>
Stuff the audio stream using the <em>mode</em>. "Stuffing" refers to the
process of adding or removing frames of audio to or from the
stream sent to the output device to keep it exactly in synchrony
with the player.
The default mode, <b>basic</b>, is normally almost completely inaudible.
The alternative mode, <b>soxr</b>, is even less obtrusive but
requires much more processing power. For this mode, support for
libsoxr, the SoX Resampler Library, must be selected when
shairport-sync is compiled.
</p>
<p><b>-t </b><em>timeout</em><b> | --timeout=</b><em>timeout</em></p>
<p>
Exit play mode if the stream disappears for more than <em>timeout</em>
seconds.</p>
<p>When shairport-sync plays an audio stream, it starts a play
session and will return a busy signal to any other sources that
attempt to use it. If the audio stream disappears for longer
than <em>timeout</em> seconds, the play session will be terminated.
If you specify a timeout time of <b>0</b>,
shairport-sync will never signal that
it is busy and will not prevent other sources from "barging in"
on an existing play session. The default value is 120 seconds.
</p>
<p><b>--tolerance=</b><em>frames</em></p>
<p>
Allow playback to be up to <em>frames</em> out of exact synchronization before attempting to correct it.
The default is 88 frames, i.e. 2 ms. The smaller the tolerance, the more likely it is that overcorrection will occur.
Overcorrection is when more corrections (insertions and deletions) are made than are strictly necessary to keep the stream in sync. Use the <b>--statistics</b> option to
monitor correction levels. Corrections should not greatly exceed net corrections.
</p>
<p><b>-V | --version</b></p>
<p>
Print version information and exit.
</p>
<p><b>-v | --verbose</b></p>
<p>
Print debug information. Repeat up to three times to get more detail.
</p>
<p><b>-w | --wait-cmd</b></p>
<p>
Wait for commands specified using <b>-B</b> or <b>-E</b> to complete before
continuing execution.
</p>
<h2>Audio Backend Options</h2>
<p>These command-line options are passed to the chosen audio backend. The audio backend options are
preceded by a <b>--</b> symbol to introduce them and to separate them from any
program options. In this way, option letters can be used as program
options and also as audio backend options without ambiguity.</p>
<p>In the ALSA backend, audio is sent to an output device
which you can specify using the <b>-d</b> option.
The output level (the "volume") is controlled using a level control associated with a mixer.
By default, the mixer is implemented in shairport-sync itself in software.
To use a hardware level control on a mixer on the sound card, specify the name of the mixer control with the <b>-c</b> option.
If the mixer is not associated with the output device, then you need to specify where the mixer is to be found with the <b>-m</b> option.</p>
<p><b>-c </b><em>controlname</em></p>
<p>
Use the level control called <em>controlname</em> on the hardware mixer for
controlling volume.
This is needed if the mixer type is specified, using the <b>-t</b> option,
to be <b>hardware</b>. There is no default.
</p>
<p><b>-d </b><em>device</em></p>
<p>
Use the specified output <em>device</em>. You may specify a card, e.g. <b>hw:0</b>, in
which case the default output device on the card will be chosen.
Alternatively, you can specify a specific device on a card, e.g. <b>hw:0,0</b>.
The default is the device named <b>default</b>.
</p>
<p><b>-m </b><em>mixer</em></p>
<p>
Use the specified hardware <em>mixer</em> for volume control. Use this to specify where
the mixer is to be found. For example, if the mixer is associated with a card,
as is often the case, specify the card, e.g. <b>hw:0</b>.
If (unusually) the mixer is associated with a specific device on a card,
specify the device, e.g. <b>hw:0,1</b>.
The default is the device named in the <b>-d</b> option,
if given, or the device named <b>default</b>.
</p>
<p><b>-t </b><em>devicetype</em></p>
<p>
This option is deprecated and is ignored. For your information, its functionality has been automatically incorporated in the -c option
-- if you specify a mixer name with the -c option, it is assumed that the mixer is implemented in hardware.
</p>
<h2>Examples</h2>
<p>Here is a slightly contrived example:</p>
shairport-sync <b>-d</b>
<b>-a "Joe's Stereo"</b>
<b>-S soxr</b>
<b>--</b>
<b>-d hw:1,0</b>
<b>-m hw:1</b>
<b>-c PCM</b>
<br>
<p>The program will run in daemon mode ( <b>-d</b> ), will be visible as
"Joe's Stereo" ( <b>-a "Joe's Stereo"</b> ) and will use the SoX Resampler
Library-based stuffing ( <b>-S soxr</b> ).
The audio backend options following the <b>--</b> separator specify
that the audio will be output on output 0 of soundcard 1 (
<b>-d hw:1,0</b> ) and will take advantage of the same sound card's mixer ( <b>-m hw:1</b> )
using the level control named "PCM" ( <b>-c "PCM"</b> ).
</p>
<p>The example above is slightly contrived in order to show the use of the <b>-m</b> option.
Typically, output 0 is the default output of a card,
so the output device could be written <b>-d hw:1</b> and
then the mixer option would be unnecessary, giving the following, simpler, command:</p>
shairport-sync <b>-d</b>
<b>-a "Joe's Stereo"</b>
<b>-S soxr</b>
<b>--</b>
<b>-d hw:1</b>
<b>-c PCM</b>
<br>
<h2>Credits</h2>
<p>Mike Brady developed shairport-sync from the original Shairport by James Laird.</p>
<p>shairport-sync can be found at <a href = "https://github.com/mikebrady/shairport-sync.">https://github.com/mikebrady/shairport-sync.</a></p>
<p>Shairport can be found at <a href = "https://github.com/abrasive/shairport.">https://github.com/abrasive/shairport.</a></p>
<h2>Comments</h2>
<p>This man page was written using <a href="http:https://masqmail.cx/xml2man/">xml2man</a> by Oliver Kurth.</p>
</td></tr></table></center>
</body>