Skip to content

Commit a92df98

Browse files
committed
4.3.5 master version
2 parents c091f63 + 4895f41 commit a92df98

26 files changed

+399
-107
lines changed

.github/workflows/check_ap2_systemd_basic.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
runs-on: ubuntu-22.04
1414

1515
steps:
16-
- uses: actions/checkout@v3.5.2
16+
- uses: actions/checkout@v4
1717
- name: Install Dependencies
18-
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
18+
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
1919
- name: Configure
2020
run: |
2121
mkdir build

.github/workflows/check_ap2_systemd_full.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313
runs-on: ubuntu-22.04
1414

1515
steps:
16-
- uses: actions/checkout@v3.5.2
16+
- uses: actions/checkout@v4
1717
- name: Install Dependencies
18-
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
18+
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
1919
- name: Configure
2020
run: |
21-
autoreconf -i
21+
autoreconf -fi
2222
./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
2323
- name: Make
2424
run: |

.github/workflows/check_ap2_systemd_full_build_folder.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
- uses: actions/[email protected]
1717
- name: Install Dependencies
18-
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
18+
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
1919
- name: Configure
2020
run: |
2121
mkdir build

.github/workflows/check_ap2_systemv_full.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ jobs:
1313
runs-on: ubuntu-22.04
1414

1515
steps:
16-
- uses: actions/checkout@v3.5.2
16+
- uses: actions/checkout@v4
1717
- name: Install Dependencies
18-
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
18+
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
1919
- name: Configure
2020
run: |
2121
autoreconf -i
22-
./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
22+
./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
2323
- name: Make
2424
run: |
2525
make -j

.github/workflows/check_classic_mac_basic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Basic libao configuration for macOS with BREW -- classic only, because mac
33
on:
44
workflow_dispatch:
55
push:
6-
branches: [ "development", "danger" ]
6+
branches: [ "development" ]
77
pull_request:
88
types: [opened, synchronize, reopened, ready_for_review]
99

.github/workflows/check_classic_systemd_basic.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
runs-on: ubuntu-22.04
1414

1515
steps:
16-
- uses: actions/checkout@v3.5.2
16+
- uses: actions/checkout@v4
1717
- name: Install Dependencies
18-
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
18+
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
1919
- name: Configure
2020
run: |
2121
mkdir build

.github/workflows/check_classic_systemd_full.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Classic (without pa, soundio, apple-alac) for systemd, using a build folde
33
on:
44
workflow_dispatch:
55
push:
6-
branches: [ "development", "danger" ]
6+
branches: [ "development" ]
77
pull_request:
88
types: [opened, synchronize, reopened, ready_for_review]
99

@@ -13,9 +13,9 @@ jobs:
1313
runs-on: ubuntu-22.04
1414

1515
steps:
16-
- uses: actions/checkout@v3.5.2
16+
- uses: actions/checkout@v4
1717
- name: Install Dependencies
18-
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
18+
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
1919
- name: Configure
2020
run: |
2121
mkdir build

BUILD.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ Reboot for these changes to take effect.
107107

108108
Next, install the packages that are needed for Shairport Sync and NQPTP:
109109
```
110-
# pkg install git autotools pkgconf popt libconfig openssl alsa-utils \
110+
# pkg install git autotools pkgconf popt libconfig openssl alsa-utils libsoxr \
111111
libplist libsodium ffmpeg e2fsprogs-libuuid vim
112112
```
113113
If you are building classic Shairport Sync, the list of packages is shorter:
114114
```
115-
# pkg install git autotools pkgconf popt libconfig openssl alsa-utils
115+
# pkg install git autotools pkgconf popt libconfig openssl alsa-utils libsoxr
116116
```
117117
## 3. Build
118118
### NQPTP

RELEASENOTES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Minor Release Notes
22
====
3-
Minor release notes are attached to the release themselves.
3+
Minor release notes are attached to the releases themselves.
44

55
Version 4.3 -- Security Updates, Bug Fixes and Enhancements
66
====

audio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ typedef struct {
3131
int (*init)(int argc, char **argv);
3232
// at end of program
3333
void (*deinit)(void);
34+
void (*prepare_to_play)(void); // sent when audio is received for the first time -- advance warning.
3435

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

audio_jack.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* jack output driver. This file is part of Shairport Sync.
3-
* Copyright (c) 2019 -- 2022 Mike Brady <[email protected]>,
3+
* Copyright (c) 2019 -- 2024 Mike Brady <[email protected]>,
44
* Jörn Nettingsmeier <[email protected]>
55
*
66
* All rights reserved.
@@ -50,8 +50,11 @@ pthread_mutex_t client_mutex = PTHREAD_MUTEX_INITIALIZER;
5050
jack_port_t *port[NPORTS];
5151
const char *port_name[NPORTS] = {"out_L", "out_R"};
5252

53+
54+
int sps_sample_rate;
55+
5356
jack_client_t *client;
54-
jack_nframes_t sample_rate;
57+
jack_nframes_t jack_sample_rate;
5558
jack_nframes_t jack_latency;
5659

5760
jack_ringbuffer_t *jackbuf;
@@ -85,12 +88,7 @@ soxr_io_spec_t io_spec;
8588
#endif
8689

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

@@ -235,17 +233,17 @@ static int jack_init(__attribute__((unused)) int argc, __attribute__((unused)) c
235233
if (!client) {
236234
die("Could not start JACK server. JackStatus is %x", status);
237235
}
238-
sample_rate = jack_get_sample_rate(client);
236+
jack_sample_rate = jack_get_sample_rate(client);
239237
#ifdef CONFIG_SOXR
240238
if (config.jack_soxr_resample_quality >= SOXR_QQ) {
241239
quality_spec = soxr_quality_spec(config.jack_soxr_resample_quality, 0);
242240
io_spec = soxr_io_spec(SOXR_INT16_I, SOXR_FLOAT32_I);
243241
} else
244242
#endif
245-
if (sample_rate != 44100) {
243+
if (jack_sample_rate != 44100) {
246244
die("The JACK server is running at the wrong sample rate (%d) for Shairport Sync."
247245
" Must be 44100 Hz.",
248-
sample_rate);
246+
jack_sample_rate);
249247
}
250248
jack_set_process_callback(client, &process, NULL);
251249
jack_set_graph_order_callback(client, &graph, NULL);
@@ -329,14 +327,15 @@ static void jack_start(int i_sample_rate, __attribute__((unused)) int i_sample_f
329327
// Nothing to do, JACK client has already been set up at jack_init().
330328
// Also, we have no say over the sample rate or sample format of JACK,
331329
// We convert the 16bit samples to float, and die if the sample rate is != 44k1 without soxr.
330+
sps_sample_rate = i_sample_rate;
332331
#ifdef CONFIG_SOXR
333332
if (config.jack_soxr_resample_quality >= SOXR_QQ) {
334333
// we might improve a bit with soxr_clear if the sample_rate doesn't change
335334
if (soxr) {
336335
soxr_delete(soxr);
337336
}
338337
soxr_error_t e = NULL;
339-
soxr = soxr_create(i_sample_rate, sample_rate, NPORTS, &e, &io_spec, &quality_spec, NULL);
338+
soxr = soxr_create(sps_sample_rate, jack_sample_rate, NPORTS, &e, &io_spec, &quality_spec, NULL);
340339
if (!soxr) {
341340
die("Unable to create soxr resampler for JACK: %s", e);
342341
}
@@ -366,13 +365,15 @@ static int jack_delay(long *the_delay) {
366365
debug(2, "audio_occupancy_now is %d.", audio_occupancy_now);
367366
pthread_mutex_unlock(&buffer_mutex);
368367

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

audio_pw.c

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ static char *audio_lmb, *audio_umb, *audio_toq, *audio_eoq;
5656
static size_t audio_size = buffer_allocation;
5757
static size_t audio_occupancy;
5858
static int enable_fill;
59+
static int stream_is_active;
5960

6061
struct timing_data {
6162
int pw_time_is_valid; // set when the pw_time has been set
@@ -268,9 +269,9 @@ static int init(__attribute__((unused)) int argc, __attribute__((unused)) char *
268269
// called in a realtime thread.
269270
pw_stream_connect(data.stream, PW_DIRECTION_OUTPUT, PW_ID_ANY,
270271
PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS |
271-
PW_STREAM_FLAG_RT_PROCESS,
272+
PW_STREAM_FLAG_RT_PROCESS | PW_STREAM_FLAG_INACTIVE,
272273
params, 1);
273-
274+
stream_is_active = 0;
274275
pw_thread_loop_unlock(data.loop);
275276
return 0;
276277
}
@@ -279,9 +280,27 @@ static void start(__attribute__((unused)) int sample_rate,
279280
__attribute__((unused)) int sample_format) {
280281
}
281282

283+
static void prepare_to_play() {
284+
// debug(1, "prepare to play");
285+
if (stream_is_active == 0) {
286+
pw_thread_loop_lock(data.loop);
287+
pw_stream_set_active(data.stream, true);
288+
pw_thread_loop_unlock(data.loop);
289+
stream_is_active = 1;
290+
debug(3, "prepare to play activating stream");
291+
}
292+
}
293+
282294
static int play(__attribute__((unused)) void *buf, int samples,
283295
__attribute__((unused)) int sample_type, __attribute__((unused)) uint32_t timestamp,
284296
__attribute__((unused)) uint64_t playtime) {
297+
if (stream_is_active == 0) {
298+
pw_thread_loop_lock(data.loop);
299+
pw_stream_set_active(data.stream, true);
300+
pw_thread_loop_unlock(data.loop);
301+
stream_is_active = 1;
302+
debug(3, "set stream active");
303+
}
285304
// copy the samples into the queue
286305
debug(3, "play %u samples; %u bytes already in the buffer.", samples, audio_occupancy);
287306
size_t bytes_to_transfer = samples * DEFAULT_CHANNELS * DEFAULT_BYTES_PER_SAMPLE;
@@ -382,8 +401,15 @@ static void stop(void) {
382401
// if (enable_fill == 0) {
383402
// debug(1, "stop enable_fill");
384403
// }
385-
enable_fill = 1;
386404
pthread_mutex_unlock(&buffer_mutex);
405+
if (stream_is_active == 1) {
406+
pw_thread_loop_lock(data.loop);
407+
// pw_stream_flush(data.stream, true);
408+
pw_stream_set_active(data.stream, false);
409+
pw_thread_loop_unlock(data.loop);
410+
stream_is_active = 0;
411+
debug(3, "set stream inactive");
412+
}
387413
}
388414

389415
audio_output audio_pw = {.name = "pw",
@@ -398,6 +424,7 @@ audio_output audio_pw = {.name = "pw",
398424
.delay = &delay,
399425
.stats = NULL,
400426
.play = &play,
427+
.prepare_to_play = &prepare_to_play,
401428
.volume = NULL,
402429
.parameters = NULL,
403430
.mute = NULL};

0 commit comments

Comments
 (0)