Skip to content

Commit

Permalink
4.3.5 master version
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebrady committed Dec 2, 2024
2 parents c091f63 + 4895f41 commit a92df98
Show file tree
Hide file tree
Showing 26 changed files with 399 additions and 107 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check_ap2_systemd_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3.5.2
- uses: actions/checkout@v4
- name: Install Dependencies
run: sudo apt-get -y --no-install-recommends install build-essential git xmltoman autoconf automake libtool libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev uuid-dev libgcrypt-dev xxd
run: sudo apt-get -y --no-install-recommends install xmltoman libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libsoxr-dev libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev
- name: Configure
run: |
mkdir build
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/check_ap2_systemd_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3.5.2
- uses: actions/checkout@v4
- name: Install Dependencies
run: sudo apt-get -y --no-install-recommends install build-essential git xmltoman autoconf automake libtool libpopt-dev libconfig-dev libasound2-dev libao-dev libjack-dev libglib2.0-dev libmosquitto-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev uuid-dev libgcrypt-dev xxd
run: sudo apt-get -y --no-install-recommends install xmltoman libpopt-dev libconfig-dev libasound2-dev libao-dev libjack-dev libmosquitto-dev avahi-daemon libavahi-client-dev libsoxr-dev libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev
- name: Configure
run: |
autoreconf -i
autoreconf -fi
./configure --sysconfdir=/etc --with-alsa --with-ao --with-dummy --with-jack --with-pipe --with-stdout --with-soxr --with-avahi --with-ssl=openssl --with-systemd --with-dbus-interface --with-mpris-interface --with-mqtt-client --with-airplay-2
- name: Make
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_ap2_systemd_full_build_folder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
- uses: actions/checkout@v3.5.2
- name: Install Dependencies
run: sudo apt-get -y --no-install-recommends install build-essential git xmltoman autoconf automake libtool libpopt-dev libconfig-dev libasound2-dev libao-dev libjack-dev libglib2.0-dev libmosquitto-dev avahi-daemon libavahi-client-dev libsoxr-dev libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev
run: sudo apt-get -y --no-install-recommends install xmltoman libpopt-dev libconfig-dev libasound2-dev libao-dev libjack-dev libglib2.0-dev libmosquitto-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev
- name: Configure
run: |
mkdir build
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/check_ap2_systemv_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3.5.2
- uses: actions/checkout@v4
- name: Install Dependencies
run: sudo apt-get -y --no-install-recommends install build-essential git xmltoman autoconf automake libtool libpopt-dev libdaemon-dev libconfig-dev libasound2-dev libao-dev libjack-dev libsndio-dev libglib2.0-dev libmosquitto-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev uuid-dev libgcrypt-dev xxd
run: sudo apt-get -y --no-install-recommends install xmltoman libpopt-dev libdaemon-dev libconfig-dev libasound2-dev libao-dev libjack-dev libglib2.0-dev libmosquitto-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev uuid-dev libgcrypt-dev
- name: Configure
run: |
autoreconf -i
./configure --sysconfdir=/etc --with-alsa --with-ao --with-dummy --with-libdaemon --with-jack --with-pipe --with-sndio --with-stdout --with-soxr --with-avahi --with-ssl=openssl --with-systemv --with-dbus-interface --with-mpris-interface --with-mqtt-client --with-airplay-2
./configure --sysconfdir=/etc --with-alsa --with-ao --with-dummy --with-libdaemon --with-jack --with-pipe --with-stdout --with-soxr --with-avahi --with-ssl=openssl --with-systemv --with-dbus-interface --with-mpris-interface --with-mqtt-client --with-airplay-2
- name: Make
run: |
make -j
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check_classic_mac_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Basic libao configuration for macOS with BREW -- classic only, because mac
on:
workflow_dispatch:
push:
branches: [ "development", "danger" ]
branches: [ "development" ]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check_classic_systemd_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3.5.2
- uses: actions/checkout@v4
- name: Install Dependencies
run: sudo apt-get -y --no-install-recommends install build-essential git xmltoman autoconf automake libtool libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev
run: sudo apt-get -y --no-install-recommends install xmltoman libpopt-dev libconfig-dev libasound2-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev
- name: Configure
run: |
mkdir build
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/check_classic_systemd_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Classic (without pa, soundio, apple-alac) for systemd, using a build folde
on:
workflow_dispatch:
push:
branches: [ "development", "danger" ]
branches: [ "development" ]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

Expand All @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3.5.2
- uses: actions/checkout@v4
- name: Install Dependencies
run: sudo apt-get -y --no-install-recommends install build-essential git xmltoman autoconf automake libtool libpopt-dev libconfig-dev libasound2-dev libao-dev libjack-dev libsndio-dev libglib2.0-dev libmosquitto-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev
run: sudo apt-get -y --no-install-recommends install xmltoman libpopt-dev libconfig-dev libasound2-dev libao-dev libjack-dev libglib2.0-dev libmosquitto-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev
- name: Configure
run: |
mkdir build
Expand Down
4 changes: 2 additions & 2 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ Reboot for these changes to take effect.

Next, install the packages that are needed for Shairport Sync and NQPTP:
```
# pkg install git autotools pkgconf popt libconfig openssl alsa-utils \
# pkg install git autotools pkgconf popt libconfig openssl alsa-utils libsoxr \
libplist libsodium ffmpeg e2fsprogs-libuuid vim
```
If you are building classic Shairport Sync, the list of packages is shorter:
```
# pkg install git autotools pkgconf popt libconfig openssl alsa-utils
# pkg install git autotools pkgconf popt libconfig openssl alsa-utils libsoxr
```
## 3. Build
### NQPTP
Expand Down
2 changes: 1 addition & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Minor Release Notes
====
Minor release notes are attached to the release themselves.
Minor release notes are attached to the releases themselves.

Version 4.3 -- Security Updates, Bug Fixes and Enhancements
====
Expand Down
1 change: 1 addition & 0 deletions audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ typedef struct {
int (*init)(int argc, char **argv);
// at end of program
void (*deinit)(void);
void (*prepare_to_play)(void); // sent when audio is received for the first time -- advance warning.

int (*prepare)(void); // looks and sets stuff in the config data structure

Expand Down
31 changes: 16 additions & 15 deletions audio_jack.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* jack output driver. This file is part of Shairport Sync.
* Copyright (c) 2019 -- 2022 Mike Brady <4265913+mikebrady@users.noreply.github.com>,
* Copyright (c) 2019 -- 2024 Mike Brady <4265913+mikebrady@users.noreply.github.com>,
* Jörn Nettingsmeier <nettings@luchtbeweging.nl>
*
* All rights reserved.
Expand Down Expand Up @@ -50,8 +50,11 @@ pthread_mutex_t client_mutex = PTHREAD_MUTEX_INITIALIZER;
jack_port_t *port[NPORTS];
const char *port_name[NPORTS] = {"out_L", "out_R"};


int sps_sample_rate;

jack_client_t *client;
jack_nframes_t sample_rate;
jack_nframes_t jack_sample_rate;
jack_nframes_t jack_latency;

jack_ringbuffer_t *jackbuf;
Expand Down Expand Up @@ -85,12 +88,7 @@ soxr_io_spec_t io_spec;
#endif

static inline sample_t sample_conv(short sample) {
// It sounds correct, but I don't understand it.
// Zero int needs to be zero float. Check.
// Plus 32767 int is 1.0. Check.
// Minus 32767 int is -0.99997. And here my brain shuts down.
// In my head, it should be 1.0, and we should tolerate an overflow
// at minus 32768. But I'm sure there's a textbook explanation somewhere.
// signed 16-bit int to float
return ((sample < 0) ? (-1.0 * sample / SHRT_MIN) : (1.0 * sample / SHRT_MAX));
}

Expand Down Expand Up @@ -235,17 +233,17 @@ static int jack_init(__attribute__((unused)) int argc, __attribute__((unused)) c
if (!client) {
die("Could not start JACK server. JackStatus is %x", status);
}
sample_rate = jack_get_sample_rate(client);
jack_sample_rate = jack_get_sample_rate(client);
#ifdef CONFIG_SOXR
if (config.jack_soxr_resample_quality >= SOXR_QQ) {
quality_spec = soxr_quality_spec(config.jack_soxr_resample_quality, 0);
io_spec = soxr_io_spec(SOXR_INT16_I, SOXR_FLOAT32_I);
} else
#endif
if (sample_rate != 44100) {
if (jack_sample_rate != 44100) {
die("The JACK server is running at the wrong sample rate (%d) for Shairport Sync."
" Must be 44100 Hz.",
sample_rate);
jack_sample_rate);
}
jack_set_process_callback(client, &process, NULL);
jack_set_graph_order_callback(client, &graph, NULL);
Expand Down Expand Up @@ -329,14 +327,15 @@ static void jack_start(int i_sample_rate, __attribute__((unused)) int i_sample_f
// Nothing to do, JACK client has already been set up at jack_init().
// Also, we have no say over the sample rate or sample format of JACK,
// We convert the 16bit samples to float, and die if the sample rate is != 44k1 without soxr.
sps_sample_rate = i_sample_rate;
#ifdef CONFIG_SOXR
if (config.jack_soxr_resample_quality >= SOXR_QQ) {
// we might improve a bit with soxr_clear if the sample_rate doesn't change
if (soxr) {
soxr_delete(soxr);
}
soxr_error_t e = NULL;
soxr = soxr_create(i_sample_rate, sample_rate, NPORTS, &e, &io_spec, &quality_spec, NULL);
soxr = soxr_create(sps_sample_rate, jack_sample_rate, NPORTS, &e, &io_spec, &quality_spec, NULL);
if (!soxr) {
die("Unable to create soxr resampler for JACK: %s", e);
}
Expand Down Expand Up @@ -366,13 +365,15 @@ static int jack_delay(long *the_delay) {
debug(2, "audio_occupancy_now is %d.", audio_occupancy_now);
pthread_mutex_unlock(&buffer_mutex);

int64_t frames_processed_since_latest_latency_check = (delta * sample_rate) / 1000000000;
int64_t frames_processed_since_latest_latency_check = (delta * jack_sample_rate) / 1000000000;
// debug(1,"delta: %" PRId64 " frames.",frames_processed_since_latest_latency_check);
// jack_latency is set by the graph() callback, it's the average of the maximum
// latencies of all our output ports. Adjust this constant baseline delay according
// to the buffer fill level:
*the_delay = jack_latency + audio_occupancy_now - frames_processed_since_latest_latency_check;
// debug(1,"reporting a delay of %d frames",*the_delay);
int64_t the_delay_in_jack_frames = jack_latency + audio_occupancy_now - frames_processed_since_latest_latency_check;
int64_t the_delay_in_sps_frames = (the_delay_in_jack_frames * sps_sample_rate) / jack_sample_rate;
*the_delay = the_delay_in_sps_frames;
// debug(2, "reporting a delay of %ld frames at Shairport Sync's rate of %d FPS.",*the_delay, sps_sample_rate);
return 0;
}

Expand Down
33 changes: 30 additions & 3 deletions audio_pw.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ static char *audio_lmb, *audio_umb, *audio_toq, *audio_eoq;
static size_t audio_size = buffer_allocation;
static size_t audio_occupancy;
static int enable_fill;
static int stream_is_active;

struct timing_data {
int pw_time_is_valid; // set when the pw_time has been set
Expand Down Expand Up @@ -268,9 +269,9 @@ static int init(__attribute__((unused)) int argc, __attribute__((unused)) char *
// called in a realtime thread.
pw_stream_connect(data.stream, PW_DIRECTION_OUTPUT, PW_ID_ANY,
PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS |
PW_STREAM_FLAG_RT_PROCESS,
PW_STREAM_FLAG_RT_PROCESS | PW_STREAM_FLAG_INACTIVE,
params, 1);

stream_is_active = 0;
pw_thread_loop_unlock(data.loop);
return 0;
}
Expand All @@ -279,9 +280,27 @@ static void start(__attribute__((unused)) int sample_rate,
__attribute__((unused)) int sample_format) {
}

static void prepare_to_play() {
// debug(1, "prepare to play");
if (stream_is_active == 0) {
pw_thread_loop_lock(data.loop);
pw_stream_set_active(data.stream, true);
pw_thread_loop_unlock(data.loop);
stream_is_active = 1;
debug(3, "prepare to play activating stream");
}
}

static int play(__attribute__((unused)) void *buf, int samples,
__attribute__((unused)) int sample_type, __attribute__((unused)) uint32_t timestamp,
__attribute__((unused)) uint64_t playtime) {
if (stream_is_active == 0) {
pw_thread_loop_lock(data.loop);
pw_stream_set_active(data.stream, true);
pw_thread_loop_unlock(data.loop);
stream_is_active = 1;
debug(3, "set stream active");
}
// copy the samples into the queue
debug(3, "play %u samples; %u bytes already in the buffer.", samples, audio_occupancy);
size_t bytes_to_transfer = samples * DEFAULT_CHANNELS * DEFAULT_BYTES_PER_SAMPLE;
Expand Down Expand Up @@ -382,8 +401,15 @@ static void stop(void) {
// if (enable_fill == 0) {
// debug(1, "stop enable_fill");
// }
enable_fill = 1;
pthread_mutex_unlock(&buffer_mutex);
if (stream_is_active == 1) {
pw_thread_loop_lock(data.loop);
// pw_stream_flush(data.stream, true);
pw_stream_set_active(data.stream, false);
pw_thread_loop_unlock(data.loop);
stream_is_active = 0;
debug(3, "set stream inactive");
}
}

audio_output audio_pw = {.name = "pw",
Expand All @@ -398,6 +424,7 @@ audio_output audio_pw = {.name = "pw",
.delay = &delay,
.stats = NULL,
.play = &play,
.prepare_to_play = &prepare_to_play,
.volume = NULL,
.parameters = NULL,
.mute = NULL};
Loading

0 comments on commit a92df98

Please sign in to comment.