Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
    Don't use strndup as old versions of OpenWrt don't seem to have it
    Update FREEBSD.md
    Fix comparison between old and new metadata strings by checking they have equal lengths as well.
    Remove a redundant definition to prevent use on an uninitialised copy, clean up some of the less-used backends
    Remove some unwanted and unused variable declarations from audio_dummy.c and audio_soundio.c
    Add the -fno-common flag to compilation.
    Treat the "mper" attribute as the 64-bit item that it is rather than a 32-bit item as hithereto. Output it as a hexadecimal number to correspond with the format of the track id obtained from AppleScript
    Make changes to that it compiles under gcc-10 with -fno-common
    Add a SIGCHLD handler to reap zombie processes generated after script invocations where wait_for_completion is set to "no".
    Update and rename CONTRIBUTING.md to REPORTING ISSUES.md
    Add a few more commands and clarify some text.
    Change from talking about a server to talking about a client. Technically, e.g. iTunes is a client of Shairport Sync.
    Store the UserAgent so as to recognise forked-daapd so as to always send a revision_number of 1 when asking for playerstatus of forked-daapd.
    Add or update some of the copyright notices
    Add the ability to set the volume directly to the D-Bus RemoteControl interface and to the MPRIS interface. Both use the recently-discovered ability to set the device_volume.
    Merge in Pieter De Gendt's work on resampling on the jack backend.
    Merge pull request mikebrady#939 from pdgendt/feature/jack-soxr-resampling
    Add SetAirplayVolume to the D-Bus RemoteControl interface.
    Add SetVolume to the MPRIS interface.
    Hook up the Volume property in the MPRIS interface.
    Modify RemoteCommand in the D-Bus interface to return the HTTP status and response.
    Change the type of airplay_volume from int to double in the metadata hub.
    Add a few sample commands in the D-Bus document.
mikebrady committed Feb 20, 2020
1 parent cfb491e commit 0222466
Showing 35 changed files with 977 additions and 464 deletions.
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@ if BUILD_FOR_OPENBSD
AM_CXXFLAGS = -I/usr/local/include -Wno-multichar -Wall -Wextra -Wno-clobbered -Wno-psabi -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
AM_CFLAGS = -Wno-multichar -Wall -Wextra -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
else
AM_CXXFLAGS = -Wno-multichar -Wall -Wextra -Wno-clobbered -Wno-psabi -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
AM_CFLAGS = -Wno-multichar -Wall -Wextra -Wno-clobbered -Wno-psabi -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
AM_CXXFLAGS = -fno-common -Wno-multichar -Wall -Wextra -Wno-clobbered -Wno-psabi -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
AM_CFLAGS = -fno-common -Wno-multichar -Wall -Wextra -Wno-clobbered -Wno-psabi -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
endif
endif

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -597,11 +597,11 @@ This will be followed by the statistics themselves at regular intervals, for exa
1.99, -22.7, 22.7, 54162, 0, 0, 0, 0, 8567, 216, 225, 44100.00, 44103.12, 44099.87, 24.57, 92, -27.45
```

"Sync error in milliseconds" is the average deviation from exact synchronisation. The first line of the example above indicates that the output is on average 0.7 milliseconds behind exact synchronisation. Sync is allowed to drift by the `general` `drift_tolerance_in_seconds` setting — (± 0.002 seconds) by default — before a correction will be made.
"Sync error in milliseconds" is the average deviation from exact synchronisation. The first line of the example above indicates that the output is on average 0.15 milliseconds behind exact synchronisation. Sync is allowed to drift by the `general` `drift_tolerance_in_seconds` setting — (± 0.002 seconds) by default — before a correction will be made.

"Net correction in ppm" is actually the net sum of corrections — the number of frame insertions less the number of frame deletions — given as a moving average in parts per million. After an initial settling period, it represents the drift — the divergence between the rate at which frames are generated at the source and the rate at which the output device consumes them. In this case, the drift is negligible, but it can routinely be up to 150 ppm, especially with older machines.

"Corrections in ppm" is the number of frame insertions plus the number of frame deletions (i.e. the total number of corrections), given as a moving average in parts per million. The closer this is to the net corrections, the fewer "unnecessary" corrections that are being made. Third party programs tend to have much larger levels of corrections.
"Corrections in ppm" is the number of frame insertions plus the number of frame deletions (i.e. the total number of corrections), given as a moving average in parts per million. The closer this is to the net corrections, the fewer "unnecessary" corrections are being made. Third party programs tend to have much larger levels of corrections.

"Min DAC queue size" is the minimum size the queue of samples in the output device's hardware buffer was measured at. It is meant to stand at 0.2 seconds = 8,820 frames at 44,100 frames per second, and will go low if the processor is very busy. If it goes below about 2,000 then it's an indication that the processor can't really keep up.

30 changes: 30 additions & 0 deletions alac.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
/*
* ALAC (Apple Lossless Audio Codec) decoder
* Copyright (c) 2005 David Hammerton
* All rights reserved.
*
* http://crazney.net/programs/itunes/alac.html
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/


#ifndef __ALAC__DECOMP_H
#define __ALAC__DECOMP_H

26 changes: 26 additions & 0 deletions apple_alac.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/*
* This file is part of Shairport Sync.
* Copyright (c) Mike Brady 2019
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

#include <string.h>

// these are headers for the ALAC decoder, utilities and endian utilities
25 changes: 25 additions & 0 deletions apple_alac.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
* This file is part of Shairport Sync.
* Copyright (c) Mike Brady 2019
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __APPLE_ALAC_H
#define __APPLE_ALAC_H

2 changes: 1 addition & 1 deletion audio.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Audio driver handler. This file is part of Shairport.
* Copyright (c) James Laird 2013
* Modifications (c) Mike Brady 2014 -- 2018
* Modifications (c) Mike Brady 2014 -- 2019
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
20 changes: 10 additions & 10 deletions audio_alsa.c
Original file line number Diff line number Diff line change
@@ -123,7 +123,7 @@ int frame_size; // in bytes for interleaved stereo
int alsa_device_initialised; // boolean to ensure the initialisation is only
// done once

enum yndk_type precision_delay_available_status =
yndk_type precision_delay_available_status =
YNDK_DONT_KNOW; // initially, we don't know if the device can do precision delay

snd_pcm_t *alsa_handle = NULL;
@@ -159,14 +159,14 @@ int volume_based_mute_is_active =
snd_pcm_sframes_t (*alsa_pcm_write)(snd_pcm_t *, const void *, snd_pcm_uframes_t) = snd_pcm_writei;

int precision_delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay,
enum yndk_type *using_update_timestamps);
yndk_type *using_update_timestamps);
int standard_delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay,
enum yndk_type *using_update_timestamps);
yndk_type *using_update_timestamps);

// use this to allow the use of standard or precision delay calculations, with standard the, uh,
// standard.
int (*delay_and_status)(snd_pcm_state_t *state, snd_pcm_sframes_t *delay,
enum yndk_type *using_update_timestamps) = standard_delay_and_status;
yndk_type *using_update_timestamps) = standard_delay_and_status;

// this will return true if the DAC can return precision delay information and false if not
// if it is not yet known, it will test the output device to find out
@@ -216,7 +216,7 @@ int precision_delay_available() {
do_play(silence, frames_of_silence);
pthread_cleanup_pop(1);
// now we can get the delay, and we'll note if it uses update timestamps
enum yndk_type uses_update_timestamps;
yndk_type uses_update_timestamps;
snd_pcm_state_t state;
snd_pcm_sframes_t delay;
int ret = precision_delay_and_status(&state, &delay, &uses_update_timestamps);
@@ -392,7 +392,7 @@ format_record fr[] = {
// be added at the lowest possible level.
// Hence, selecting the greatest bit depth is always either beneficial or neutral.

enum sps_format_t auto_format_check_sequence[] = {
sps_format_t auto_format_check_sequence[] = {
SPS_FORMAT_S32, SPS_FORMAT_S32_LE, SPS_FORMAT_S32_BE, SPS_FORMAT_S24, SPS_FORMAT_S24_LE,
SPS_FORMAT_S24_BE, SPS_FORMAT_S24_3LE, SPS_FORMAT_S24_3BE, SPS_FORMAT_S16, SPS_FORMAT_S16_LE,
SPS_FORMAT_S16_BE, SPS_FORMAT_S8, SPS_FORMAT_U8,
@@ -508,12 +508,12 @@ int actual_open_alsa_device(int do_auto_setup) {
}
} else { // auto format
int number_of_formats_to_try;
enum sps_format_t *formats;
sps_format_t *formats;
formats = auto_format_check_sequence;
number_of_formats_to_try = sizeof(auto_format_check_sequence) / sizeof(sps_format_t);
int i = 0;
int format_found = 0;
enum sps_format_t trial_format = SPS_FORMAT_UNKNOWN;
sps_format_t trial_format = SPS_FORMAT_UNKNOWN;
while ((i < number_of_formats_to_try) && (format_found == 0)) {
trial_format = formats[i];
sf = fr[trial_format].alsa_code;
@@ -1422,7 +1422,7 @@ static void start(__attribute__((unused)) int i_sample_rate,
}

int standard_delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay,
enum yndk_type *using_update_timestamps) {
yndk_type *using_update_timestamps) {
int ret = 0;
if (using_update_timestamps)
*using_update_timestamps = YNDK_NO;
@@ -1444,7 +1444,7 @@ int standard_delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay,
}

int precision_delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay,
enum yndk_type *using_update_timestamps) {
yndk_type *using_update_timestamps) {
snd_pcm_status_t *alsa_snd_pcm_status;
snd_pcm_status_alloca(&alsa_snd_pcm_status);

6 changes: 0 additions & 6 deletions audio_dummy.c
Original file line number Diff line number Diff line change
@@ -34,17 +34,11 @@
#include <sys/time.h>
#include <unistd.h>

int Fs;
long long starttime, samples_played;

static int init(__attribute__((unused)) int argc, __attribute__((unused)) char **argv) { return 0; }

static void deinit(void) {}

static void start(int sample_rate, __attribute__((unused)) int sample_format) {
Fs = sample_rate;
starttime = 0;
samples_played = 0;
debug(1, "dummy audio output started at Fs=%d Hz\n", sample_rate);
}

Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

0 comments on commit 0222466

Please sign in to comment.