Merge pull request #765 from mikebrady/use_disposable_libraries

1. Separate compilation of automatically generated code from regular code to avoid compiler warnings.

2. Reorder some header includes to avoid compilation errors in OpenBSD.

3. Add a few extra warnings to the `alsa` interface to check for failure to recover from errors.
This commit is contained in:
Mike Brady
2018-11-01 08:49:00 +00:00
committed by GitHub
5 changed files with 50 additions and 15 deletions
+1
View File
@@ -32,6 +32,7 @@ shairport-sync.core
/org.gnome.ShairportSync.service
/dbus-interface.*
/mpris-interface.*
/lib_*.*
# Some eclipse project files
.cproject
+20 -6
View File
@@ -1,4 +1,8 @@
SUBDIRS = man
ARFLAGS = cr
lib_dbus_interface_a_CFLAGS = -pthread
lib_mpris_interface_a_CFLAGS = -pthread
bin_PROGRAMS = shairport-sync
@@ -7,8 +11,8 @@ bin_PROGRAMS = shairport-sync
shairport_sync_SOURCES = shairport.c rtsp.c mdns.c mdns_external.c common.c rtp.c player.c alac.c audio.c loudness.c
if BUILD_FOR_FREEBSD
AM_CXXFLAGS = -I/usr/local/include -Wno-multichar -Wall -Wextra -pthread -DSYSCONFDIR=\"$(sysconfdir)\" -O2
AM_CFLAGS = -Wno-multichar -Wall -Wextra -pthread -DSYSCONFDIR=\"$(sysconfdir)\" -O2
AM_CXXFLAGS = -I/usr/local/include -Wno-multichar -Wall -Wextra -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
AM_CFLAGS = -Wno-multichar -Wall -Wextra -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
else
if BUILD_FOR_OPENBSD
AM_CXXFLAGS = -I/usr/local/include -Wno-multichar -Wall -Wextra -Wno-clobbered -Wno-psabi -pthread -DSYSCONFDIR=\"$(sysconfdir)\"
@@ -96,9 +100,14 @@ endif
BUILT_SOURCES =
noinst_HEADERS =
CLEANFILES =
shairport_sync_LDADD =
noinst_LIBRARIES =
if USE_DBUS
shairport_sync_SOURCES += dbus-service.c dbus-interface.c
shairport_sync_LDADD += lib_dbus_interface.a
noinst_LIBRARIES += lib_dbus_interface.a
lib_dbus_interface_a_SOURCES = dbus-interface.c
shairport_sync_SOURCES += dbus-service.c
BUILT_SOURCES += dbus-interface.h dbus-interface.c
# We don't want to install this header
noinst_HEADERS += $(BUILT_SOURCES)
@@ -110,7 +119,10 @@ dbus-interface.h dbus-interface.c: org.gnome.ShairportSync.xml
endif
if USE_MPRIS
shairport_sync_SOURCES += mpris-service.c mpris-interface.c
shairport_sync_LDADD += lib_mpris_interface.a
noinst_LIBRARIES += lib_mpris_interface.a
lib_mpris_interface_a_SOURCES = mpris-interface.c
shairport_sync_SOURCES += mpris-service.c
BUILT_SOURCES += mpris-interface.h mpris-interface.c
# We don't want to install this header
noinst_HEADERS += $(BUILT_SOURCES)
@@ -126,13 +138,15 @@ noinst_PROGRAMS =
if USE_DBUS_CLIENT
#Make it, but don't install it anywhere
noinst_PROGRAMS += shairport-sync-dbus-test-client
shairport_sync_dbus_test_client_SOURCES = dbus-interface.c dbus-interface.h shairport-sync-dbus-test-client.c
shairport_sync_dbus_test_client_SOURCES = shairport-sync-dbus-test-client.c
shairport_sync_dbus_test_client_LDADD = lib_dbus_interface.a
endif
if USE_MPRIS_CLIENT
#Make it, but don't install it anywhere
noinst_PROGRAMS += shairport-sync-mpris-test-client
shairport_sync_mpris_test_client_SOURCES = mpris-interface.c mpris-interface.h shairport-sync-mpris-test-client.c
shairport_sync_mpris_test_client_SOURCES = shairport-sync-mpris-test-client.c
shairport_sync_mpris_test_client_LDADD = lib_mpris_interface.a
endif
install-exec-hook:
+26 -7
View File
@@ -883,7 +883,11 @@ int delay(long *the_delay) {
if (reply != 0) {
debug(1, "Error %d in delay(): \"%s\". Delay reported is %d frames.", reply,
snd_strerror(reply), *the_delay);
snd_pcm_recover(alsa_handle, reply, 1);
derr = snd_pcm_recover(alsa_handle, reply, 1);
if (derr < 0)
warn("Error %d -- could not clear an error after attempting delay(): \"%s\".", derr,
snd_strerror(derr));
frame_index = 0;
measurement_data_is_valid = 0;
} else {
@@ -908,8 +912,11 @@ int delay(long *the_delay) {
debug(2, "Error -- ALSA delay(): bad state: %d.", dac_state);
}
if ((derr = snd_pcm_prepare(alsa_handle))) {
snd_pcm_recover(alsa_handle, derr, 1);
debug(1, "Error preparing after delay error: \"%s\".", snd_strerror(derr));
derr = snd_pcm_recover(alsa_handle, derr, 1);
if (derr < 0)
warn("Error %d -- could not clear an error after attempting to recover following a delay(): \"%s\".", derr,
snd_strerror(derr));
}
}
}
@@ -957,8 +964,11 @@ static int play(void *buf, int samples) {
int err, err2;
if (snd_pcm_state(alsa_handle) == SND_PCM_STATE_XRUN) {
if ((err = snd_pcm_prepare(alsa_handle))) {
snd_pcm_recover(alsa_handle, err, 1);
debug(1, "Error preparing after underrun: \"%s\".", snd_strerror(err));
err = snd_pcm_recover(alsa_handle, err, 1);
if (err < 0)
warn("Error %d -- could not clear an error after detecting underrun in play(): \"%s\".", err,
snd_strerror(err));
}
frame_index = 0; // we'll be starting over
measurement_data_is_valid = 0;
@@ -975,7 +985,10 @@ static int play(void *buf, int samples) {
measurement_data_is_valid = 0;
debug(1, "Error %d writing %d samples in play(): \"%s\".", err, samples,
snd_strerror(err));
snd_pcm_recover(alsa_handle, err, 1);
err = snd_pcm_recover(alsa_handle, err, 1);
if (err < 0)
warn("Error %d -- could not clear an error after attempting to write %d samples in play(): \"%s\".", err, samples,
snd_strerror(err));
}
if (frame_index == 0) {
frames_sent_for_playing = samples;
@@ -989,9 +1002,12 @@ static int play(void *buf, int samples) {
long fl = 0;
err2 = snd_pcm_delay(alsa_handle, &fl);
if (err2 != 0) {
debug(1, "Error %d in delay(): \"%s\". Delay reported is %d frames.", err2,
debug(1, "Error %d in delay in play(): \"%s\". Delay reported is %d frames.", err2,
snd_strerror(err2), fl);
snd_pcm_recover(alsa_handle, err2, 1);
err2 = snd_pcm_recover(alsa_handle, err2, 1);
if (err2 < 0)
warn("Error %d -- could not clear an error after checking delay in play(): \"%s\".", err2,
snd_strerror(err2));
frame_index = 0;
measurement_data_is_valid = 0;
} else {
@@ -1016,8 +1032,11 @@ static int play(void *buf, int samples) {
debug(1, "Error -- ALSA device in incorrect state (%d) for play.",
snd_pcm_state(alsa_handle));
if ((err = snd_pcm_prepare(alsa_handle))) {
snd_pcm_recover(alsa_handle, err, 1);
debug(1, "Error preparing after play error: \"%s\".", snd_strerror(err));
err2 = snd_pcm_recover(alsa_handle, err, 1);
if (err2 < 0)
warn("Error %d -- could not clear an error after reporting ALSA device in incorrect state for play: \"%s\".", err2,
snd_strerror(err2));
}
frame_index = 0;
measurement_data_is_valid = 0;
+1
View File
@@ -6,6 +6,7 @@ AC_INIT([shairport-sync], [3.3d19], [mikebrady@eircom.net])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([shairport.c])
AC_CONFIG_HEADERS([config.h])
AC_PROG_RANLIB
# Derived from the Avahi configure.ac file
# Specifying the OS type, defaulting to linux.
+2 -2
View File
@@ -25,6 +25,8 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include <sys/socket.h>
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
@@ -35,9 +37,7 @@
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>