Many changes to compilation and linking flags. Stop using HAVE_* flags except where necessary, use CONFIG_* for optional stuff, use HAS_* for immediate definitions, use USE_* for AM definitions. Probably introduced bgs, sigh.

This commit is contained in:
Mike Brady
2018-09-09 20:41:31 +01:00
parent 69642bb7de
commit c9b3d2a2f4
11 changed files with 116 additions and 121 deletions
+3 -3
View File
@@ -17,7 +17,7 @@ else
endif
endif
if USE_ALAC
if USE_APPLE_ALAC
shairport_sync_SOURCES += apple_alac.cpp
endif
@@ -104,7 +104,7 @@ noinst_HEADERS += $(BUILT_SOURCES)
CLEANFILES += $(BUILT_SOURCES)
dbus-interface.h dbus-interface.c: org.gnome.ShairportSync.xml
gdbus-codegen --interface-prefix org.gnome --generate-c-code dbus-interface org.gnome.ShairportSync.xml
gdbus-codegen --interface-prefix org.gnome --c-generate-autocleanup all --generate-c-code dbus-interface org.gnome.ShairportSync.xml
endif
if USE_MPRIS
@@ -116,7 +116,7 @@ noinst_HEADERS += $(BUILT_SOURCES)
CLEANFILES += $(BUILT_SOURCES)
mpris-interface.h mpris-interface.c: org.mpris.MediaPlayer2.xml
gdbus-codegen --interface-prefix org.mpris --generate-c-code mpris-interface org.mpris.MediaPlayer2.xml
gdbus-codegen --interface-prefix org.mpris --c-generate-autocleanup all --generate-c-code mpris-interface org.mpris.MediaPlayer2.xml
endif
noinst_PROGRAMS =
+18 -17
View File
@@ -2,6 +2,7 @@
* Utility routines. This file is part of Shairport.
* Copyright (c) James Laird 2013
* The volume to attenuation function vol2attn copyright (c) Mike Brady 2014
* Further changes (c) Mike Brady 2014 -- 2018
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
@@ -46,7 +47,7 @@
#include <mach/mach_time.h>
#endif
#ifdef HAVE_LIBSSL
#ifdef CONFIG_OPENSSL
#include <openssl/bio.h>
#include <openssl/buffer.h>
#include <openssl/evp.h>
@@ -54,7 +55,7 @@
#include <openssl/rsa.h>
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
#include "polarssl/ctr_drbg.h"
#include "polarssl/entropy.h"
#include <polarssl/base64.h>
@@ -67,7 +68,7 @@
#endif
#endif
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
#include "mbedtls/ctr_drbg.h"
#include "mbedtls/entropy.h"
#include <mbedtls/base64.h>
@@ -247,7 +248,7 @@ int mkpath(const char *path, mode_t mode) {
return (status);
}
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
char *base64_enc(uint8_t *input, int length) {
char *buf = NULL;
size_t dlen = 0;
@@ -300,7 +301,7 @@ uint8_t *base64_dec(char *input, int *outlen) {
}
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
char *base64_enc(uint8_t *input, int length) {
char *buf = NULL;
size_t dlen = 0;
@@ -353,7 +354,7 @@ uint8_t *base64_dec(char *input, int *outlen) {
}
#endif
#ifdef HAVE_LIBSSL
#ifdef CONFIG_OPENSSL
char *base64_enc(uint8_t *input, int length) {
BIO *bmem, *b64;
BUF_MEM *bptr;
@@ -432,7 +433,7 @@ static char super_secret_key[] =
"2gG0N5hvJpzwwhbhXqFKA4zaaSrw622wDniAK5MlIE0tIAKKP4yxNGjoD2QYjhBGuhvkWKY=\n"
"-----END RSA PRIVATE KEY-----\0";
#ifdef HAVE_LIBSSL
#ifdef CONFIG_OPENSSL
uint8_t *rsa_apply(uint8_t *input, int inlen, int *outlen, int mode) {
RSA *rsa = NULL;
if (!rsa) {
@@ -456,7 +457,7 @@ uint8_t *rsa_apply(uint8_t *input, int inlen, int *outlen, int mode) {
}
#endif
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
uint8_t *rsa_apply(uint8_t *input, int inlen, int *outlen, int mode) {
mbedtls_pk_context pkctx;
mbedtls_rsa_context *trsa;
@@ -513,7 +514,7 @@ uint8_t *rsa_apply(uint8_t *input, int inlen, int *outlen, int mode) {
}
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
uint8_t *rsa_apply(uint8_t *input, int inlen, int *outlen, int mode) {
rsa_context trsa;
const char *pers = "rsa_encrypt";
@@ -1164,16 +1165,16 @@ int _debug_mutex_unlock(pthread_mutex_t *mutex, const char *filename, const int
void pthread_cleanup_debug_mutex_unlock(void *arg) { pthread_mutex_unlock((pthread_mutex_t *)arg); }
char *get_version_string() {
char *version_string = malloc(200);
char *version_string = malloc(1024);
if (version_string) {
strcpy(version_string, PACKAGE_VERSION);
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
strcat(version_string, "-mbedTLS");
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
strcat(version_string, "-PolarSSL");
#endif
#ifdef HAVE_LIBSSL
#ifdef CONFIG_OPENSSL
strcat(version_string, "-OpenSSL");
#endif
#ifdef CONFIG_TINYSVCMDNS
@@ -1209,7 +1210,7 @@ char *get_version_string() {
#ifdef CONFIG_PIPE
strcat(version_string, "-pipe");
#endif
#ifdef HAVE_LIBSOXR
#ifdef CONFIG_SOXR
strcat(version_string, "-soxr");
#endif
#ifdef CONFIG_CONVOLUTION
@@ -1218,13 +1219,13 @@ char *get_version_string() {
#ifdef CONFIG_METADATA
strcat(version_string, "-metadata");
#endif
#ifdef HAVE_LIBMOSQUITTO
#ifdef CONFIG_MQTT
strcat(version_string, "-mqtt");
#endif
#ifdef HAVE_DBUS
#ifdef CONFIG_DBUS_INTERFACE
strcat(version_string, "-dbus");
#endif
#ifdef HAVE_MPRIS
#ifdef CONFIG_MPRIS_INTERFACE
strcat(version_string, "-mpris");
#endif
strcat(version_string, "-sysconfdir:");
+4 -4
View File
@@ -23,7 +23,7 @@
#define SAFAMILY sa_family
#endif
#if defined(HAVE_DBUS) || defined(HAVE_MPRIS)
#if defined(CONFIG_DBUS_INTERFACE) || defined(CONFIG_MPRIS_INTERFACE)
enum dbus_session_type {
DBT_system = 0, // use the session bus
DBT_session, // use the system bus
@@ -94,7 +94,7 @@ typedef struct {
size_t metadata_sockmsglength;
int get_coverart;
#endif
#ifdef HAVE_LIBMOSQUITTO
#ifdef CONFIG_MQTT
int mqtt_enabled;
char *mqtt_hostname;
int mqtt_port;
@@ -182,10 +182,10 @@ typedef struct {
int loudness;
float loudness_reference_volume_db;
int alsa_use_hardware_mute;
#if defined(HAVE_DBUS)
#if defined(CONFIG_DBUS_INTERFACE)
enum dbus_session_type dbus_service_bus_type;
#endif
#if defined(HAVE_MPRIS)
#if defined(CONFIG_MPRIS_INTERFACE)
enum dbus_session_type mpris_service_bus_type;
#endif
+19 -25
View File
@@ -63,8 +63,7 @@ if test "x${with_pkg_config}" = xyes ; then
PKG_CHECK_MODULES(
[POPT], [popt],
[CFLAGS="${POPT_CFLAGS} ${CFLAGS}"
LIBS="${POPT_LIBS} ${LIBS}"
AC_DEFINE([HAVE_LIBPOPT],[1],[Define to 1 if you have the popt library])])
LIBS="${POPT_LIBS} ${LIBS}"])
else
AC_CHECK_LIB([popt],[poptGetContext], , AC_MSG_ERROR(libpopt needed))
fi
@@ -111,16 +110,16 @@ AM_CONDITIONAL([INSTALL_CONFIG_FILES], [test "x$with_configfiles" = "xyes"])
# Look for Apple ALAC flag
AC_ARG_WITH(apple-alac, [ --with-apple-alac = include support for the Apple ALAC decoder],
[AC_MSG_RESULT(>>Including the Apple ALAC Decoder)
REQUESTED_ALAC=1
AC_DEFINE([CONFIG_APPLE_ALAC], 1, [Include support for using the Apple ALAC Decoder])
REQUESTED_APPLE_ALAC=1
if test "x${with_pkg_config}" = xyes ; then
PKG_CHECK_MODULES(
[ALAC], [alac],
[LIBS="${ALAC_LIBS} ${LIBS}"
AC_DEFINE([HAVE_ALAC],[1],[Define to 1 if you are using the Apple ALAC Decoder])])
[LIBS="${ALAC_LIBS} ${LIBS}"])
else
AC_CHECK_LIB([alac], [BitBufferInit], , AC_MSG_ERROR(Apple ALAC Decoder support requires the alac library!))
fi ])
AM_CONDITIONAL([USE_ALAC], [test "x$REQUESTED_ALAC" = "x1"])
AM_CONDITIONAL([USE_APPLE_ALAC], [test "x$REQUESTED_APPLE_ALAC" = "x1"])
# Look for piddir flag
AC_ARG_WITH(piddir, [ --with-piddir=<pathname> Specify a pathname to a directory in which to write the PID file.], [
@@ -143,17 +142,17 @@ AC_ARG_WITH(ssl, [ choose --with-ssl=openssl, --with-ssl=mbedtls or --with-ssl=p
AC_MSG_ERROR(choose "openssl", "mbedtls" or "polarssl" encryption)
fi
if test "x${with_ssl}" = xopenssl ; then
AC_DEFINE([CONFIG_OPENSSL], 1, [Use the OpenSSL libraries for encryption and encoding and decoding])
if test "x${with_pkg_config}" = xyes ; then
PKG_CHECK_MODULES(
[SSL], [libssl,libcrypto],
[LIBS="${SSL_LIBS} ${LIBS}"
AC_DEFINE([HAVE_LIBCRYPTO],[1],[Define to 1 if you have libcrypto])
AC_DEFINE([HAVE_LIBSSL],[1],[Define to 1 if you have libssl])])
[LIBS="${SSL_LIBS} ${LIBS}"])
else
AC_CHECK_LIB([crypto], [main], , AC_MSG_ERROR(libcrypto selected but the library cannot be found!))
AC_CHECK_LIB([ssl], [main], , AC_MSG_ERROR(libssl selected but the library cannot be found!))
fi
elif test "x${with_ssl}" = xmbedtls ; then
AC_DEFINE([CONFIG_MBEDTLS], 1, [Use the mbed TLS libraries for encryption and encoding and decoding])
AC_CHECK_LIB([mbedtls],[mbedtls_ssl_init],,
[AC_MSG_ERROR([mbed tls support requires the mbedtls library -- libmbedtls-dev suggested],1)])
AC_CHECK_LIB([mbedcrypto], [mbedtls_entropy_func],,
@@ -161,6 +160,7 @@ AC_ARG_WITH(ssl, [ choose --with-ssl=openssl, --with-ssl=mbedtls or --with-ssl=p
AC_CHECK_LIB([mbedx509], [mbedtls_pk_init],,
[AC_MSG_ERROR([mbed tls support requires the mbedx509 library -- libmbedx509-0 suggested],1)])
elif test "x${with_ssl}" = xpolarssl ; then
AC_DEFINE([CONFIG_POLARSSL], 1, [Use the PolarSSL libraries for encryption and encoding and decoding])
AC_CHECK_LIB([polarssl],[ssl_init], , AC_MSG_ERROR(PolarSSL is selected but the library cannot be found and is deprecated. Consider selecting mbed TLS instead using --with-ssl=mbedtls.))
else
AC_MSG_ERROR(unknown option "${with_ssl}"." Please choose with "openssl", "mbedtls" or "polarssl")
@@ -171,11 +171,10 @@ AC_ARG_WITH(ssl, [ choose --with-ssl=openssl, --with-ssl=mbedtls or --with-ssl=p
AC_ARG_WITH(soxr, [ --with-soxr = choose libsoxr for high-quality interpolation], [
AC_MSG_RESULT(>>Including support for soxr-based interpolation)
if test "x${with_pkg_config}" = xyes ; then
AC_DEFINE([CONFIG_SOXR], 1, [Include support for using the SoX Resampler library for interpolation])
PKG_CHECK_MODULES(
[SOXR], [soxr],
[LIBS="${SOXR_LIBS} ${LIBS}"
AC_DEFINE([HAVE_LIBSOXR],[1],[Define to 1 if you are including support for soxr interpolation])])
[LIBS="${SOXR_LIBS} ${LIBS}"])
else
AC_CHECK_LIB([avutil],[av_get_cpu_flags])
if test "x${ac_cv_lib_avutil_av_get_cpu_flags}" = xyes ; then
@@ -218,8 +217,7 @@ AC_ARG_WITH(alsa, [ --with-alsa = choose ALSA API support (GNU/Linux only)],
if test "x${with_pkg_config}" = xyes ; then
PKG_CHECK_MODULES(
[ALSA], [alsa],
[LIBS="${ALSA_LIBS} ${LIBS}"
AC_DEFINE([HAVE_LIBASOUND],[1],[Define to 1 if you have ALSA])])
[LIBS="${ALSA_LIBS} ${LIBS}"])
else
AC_CHECK_LIB([asound], [snd_pcm_open], , AC_MSG_ERROR(ALSA support requires the asound library!))
fi ])
@@ -233,8 +231,7 @@ AC_ARG_WITH(jack, [ --with-jack = include a Jack Audio Connection Kit (jack) ba
if test "x${with_pkg_config}" = xyes ; then
PKG_CHECK_MODULES(
[JACK], [jack],
[LIBS="${JACK_LIBS} ${LIBS}"
AC_DEFINE([HAVE_JACK],[1],[Define to 1 if you have Jack audio])],
[LIBS="${JACK_LIBS} ${LIBS}"],
[AC_MSG_ERROR(Jack Audio Connection Kit support requires the jack library -- libjack-dev suggested!)])
else
AC_CHECK_LIB([jack], [jack_client_open], , AC_MSG_ERROR(Jack Audio Connection Kit support requires the jack library -- libjack-dev suggested!))
@@ -293,15 +290,15 @@ AM_CONDITIONAL([USE_CONVOLUTION], [test "x$REQUESTED_CONVOLUTION" = "x1"])
AC_ARG_WITH(dns_sd, [ --with-dns_sd = choose dns_sd mDNS support], [
AC_MSG_RESULT(>>Including dns_sd for mDNS support)
REQUESTED_DNS_SD=1
AC_DEFINE([CONFIG_HAVE_DNS_SD_H], 1, [Needed by the compiler.])
AC_DEFINE([CONFIG_DNS_SD], 1, [Needed by the compiler.])
AC_SEARCH_LIBS([DNSServiceRefDeallocate], [dns_sd], , AC_MSG_ERROR(dns_sd support requires the dns_sd library!))], )
AM_CONDITIONAL([USE_DNS_SD], [test "x$REQUESTED_DNS_SD" = "x1"])
# Look for dbus flag
AC_ARG_WITH(dbus-interface, [ --with-dbus-interface = include support for the native Shairport Sync D-Bus interface], [
AC_MSG_RESULT(>>Including dbus support)
AC_DEFINE([CONFIG_DBUS_INTERFACE], 1, [Include support for the native Shairport Sync D-Bus interface])
REQUESTED_DBUS=1
AC_DEFINE([HAVE_DBUS], 1, [Needed by the compiler.])
PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= 2.30.0],[CFLAGS="${GIO_UNIX_CFLAGS} ${CFLAGS}" LIBS="${GIO_UNIX_LIBS} ${LIBS}"],[AC_MSG_ERROR(dbus messaging support requires the glib 2.0 library -- libglib2.0-dev suggested!)])
], )
AM_CONDITIONAL([USE_DBUS], [test "x$REQUESTED_DBUS" = "x1"])
@@ -310,16 +307,15 @@ AM_CONDITIONAL([USE_DBUS], [test "x$REQUESTED_DBUS" = "x1"])
AC_ARG_WITH(dbus-test-client, [ --with-dbus-test-client = compile dbus test client], [
AC_MSG_RESULT(>>Including dbus test client)
REQUESTED_DBUS_CLIENT=1
AC_DEFINE([HAVE_DBUS_CLIENT], 1, [Needed by the compiler.])
PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= 2.30.0],[CFLAGS="${GIO_UNIX_CFLAGS} ${CFLAGS}" LIBS="${GIO_UNIX_LIBS} ${LIBS}"],[AC_MSG_ERROR(dbus client support requires the glib 2.0 library -- libglib2.0-dev suggested!)])
], )
AM_CONDITIONAL([USE_DBUS_CLIENT], [test "x$REQUESTED_DBUS_CLIENT" = "x1"])
# Look for mpris flag
AC_ARG_WITH(mpris-interface, [ --with-mpris-interface = include support for a Shairport Sync D-Bus interface conforming to the MPRIS standard], [
AC_ARG_WITH(mpris-interface, [ --with-mpris-interface = include support for a D-Bus interface conforming to the MPRIS standard], [
AC_MSG_RESULT(>>Including the MPRIS D-Bus Interface)
AC_DEFINE([CONFIG_MPRIS_INTERFACE], 1, [Include support for a D-Bus interface conforming to the MPRIS standard])
REQUESTED_MPRIS=1
AC_DEFINE([HAVE_MPRIS], 1, [Needed by the compiler.])
PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= 2.30.0],[CFLAGS="${GIO_UNIX_CFLAGS} ${CFLAGS}" LIBS="${GIO_UNIX_LIBS} ${LIBS}"],[AC_MSG_ERROR(dbus messaging support for mpris requires the glib 2.0 library -- libglib2.0-dev suggested!)])
], )
AM_CONDITIONAL([USE_MPRIS], [test "x$REQUESTED_MPRIS" = "x1"])
@@ -328,15 +324,13 @@ AM_CONDITIONAL([USE_MPRIS], [test "x$REQUESTED_MPRIS" = "x1"])
AC_ARG_WITH(mpris-test-client, [ --with-mpris-test-client = compile mpris test client], [
AC_MSG_RESULT(>>Including mpris test client)
REQUESTED_MPRIS_CLIENT=1
AC_DEFINE([HAVE_MPRIS_CLIENT], 1, [Needed by the compiler.])
PKG_CHECK_MODULES([GIO_UNIX], [gio-unix-2.0 >= 2.30.0],[CFLAGS="${GIO_UNIX_CFLAGS} ${CFLAGS}" LIBS="${GIO_UNIX_LIBS} ${LIBS}"],[AC_MSG_ERROR(mpris client support requires the glib 2.0 library -- libglib2.0-dev suggested!)])
], )
AM_CONDITIONAL([USE_MPRIS_CLIENT], [test "x$REQUESTED_MPRIS_CLIENT" = "x1"])
#AM_CONDITIONAL([USE_DBUS_CORE_AND_DACP], [test "x$REQUESTED_MPRIS" = "x1" -o "x$REQUESTED_DBUS" = "x1"])
# Look for mqtt flag
AC_ARG_WITH(mqtt-client, [ --with-mqtt-client = include support for the native Shairport Sync MQTT interface], [
AC_ARG_WITH(mqtt-client, [ --with-mqtt-client = include a client for MQTT -- the Message Queuing Telemetry Transport protocol], [
AC_DEFINE([CONFIG_MQTT], 1, [Include a client for MQTT, the Message Queuing Telemetry Transport protocol])
AC_MSG_RESULT(>>Including MQTT support)
REQUESTED_MQTT=1
AC_CHECK_LIB([mosquitto], [mosquitto_lib_init], , AC_MSG_ERROR(MQTT support requires the mosquitto library -- libmosquitto-dev suggested!))
+4 -4
View File
@@ -420,7 +420,7 @@ gboolean notify_drift_tolerance_callback(ShairportSync *skeleton,
gboolean notify_alacdecoder_callback(ShairportSync *skeleton,
__attribute__((unused)) gpointer user_data) {
char *th = (char *)shairport_sync_get_alacdecoder(skeleton);
#ifdef HAVE_ALAC
#ifdef CONFIG_APPLE_ALAC
if (strcasecmp(th, "hammerton") == 0)
config.use_apple_decoder = 0;
else if (strcasecmp(th, "apple") == 0)
@@ -451,7 +451,7 @@ gboolean notify_alacdecoder_callback(ShairportSync *skeleton,
gboolean notify_interpolation_callback(ShairportSync *skeleton,
__attribute__((unused)) gpointer user_data) {
char *th = (char *)shairport_sync_get_interpolation(skeleton);
#ifdef HAVE_LIBSOXR
#ifdef CONFIG_SOXR
if (strcasecmp(th, "basic") == 0)
config.packet_stuffing = ST_basic;
else if (strcasecmp(th, "soxr") == 0)
@@ -677,7 +677,7 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name
config.loudness_reference_volume_db);
shairport_sync_set_drift_tolerance(SHAIRPORT_SYNC(shairportSyncSkeleton), config.tolerance);
#ifdef HAVE_ALAC
#ifdef CONFIG_APPLE_ALAC
if (config.use_apple_decoder == 0) {
shairport_sync_set_alacdecoder(SHAIRPORT_SYNC(shairportSyncSkeleton), "hammerton");
debug(1, ">> ALACDecoder set to \"hammerton\"");
@@ -691,7 +691,7 @@ static void on_dbus_name_acquired(GDBusConnection *connection, const gchar *name
#endif
#ifdef HAVE_LIBSOXR
#ifdef CONFIG_SOXR
if (config.packet_stuffing == ST_basic) {
shairport_sync_set_interpolation(SHAIRPORT_SYNC(shairportSyncSkeleton), "basic");
debug(1, ">> interpolation set to \"basic\" (soxr support built in)");
+2 -2
View File
@@ -36,7 +36,7 @@
extern mdns_backend mdns_avahi;
extern mdns_backend mdns_external_avahi;
#endif
#ifdef CONFIG_HAVE_DNS_SD_H
#ifdef CONFIG_DNS_SD
extern mdns_backend mdns_dns_sd;
extern mdns_backend mdns_external_dns_sd;
#endif
@@ -49,7 +49,7 @@ static mdns_backend *mdns_backends[] = {
&mdns_avahi,
&mdns_external_avahi,
#endif
#ifdef CONFIG_HAVE_DNS_SD_H
#ifdef CONFIG_DNS_SD
&mdns_dns_sd,
&mdns_external_dns_sd,
#endif
+6 -6
View File
@@ -45,15 +45,15 @@
#include "dacp.h"
#include "metadata_hub.h"
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
#include <mbedtls/md5.h>
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
#include <polarssl/md5.h>
#endif
#ifdef HAVE_LIBSSL
#ifdef CONFIG_OPENSSL
#include <openssl/md5.h>
#endif
@@ -219,21 +219,21 @@ char *metadata_write_image_file(const char *buf, int len) {
uint8_t img_md5[16];
// uint8_t ap_md5[16];
#ifdef HAVE_LIBSSL
#ifdef CONFIG_SSL
MD5_CTX ctx;
MD5_Init(&ctx);
MD5_Update(&ctx, buf, len);
MD5_Final(img_md5, &ctx);
#endif
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
mbedtls_md5_context tctx;
mbedtls_md5_starts(&tctx);
mbedtls_md5_update(&tctx, (const unsigned char *)buf, len);
mbedtls_md5_finish(&tctx, img_md5);
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
md5_context tctx;
md5_starts(&tctx);
md5_update(&tctx, (const unsigned char *)buf, len);
+17 -17
View File
@@ -45,21 +45,21 @@
#include "config.h"
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
#include <mbedtls/aes.h>
#include <mbedtls/havege.h>
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
#include <polarssl/aes.h>
#include <polarssl/havege.h>
#endif
#ifdef HAVE_LIBSSL
#ifdef CONFIG_OPENSSL
#include <openssl/aes.h>
#endif
#ifdef HAVE_LIBSOXR
#ifdef CONFIG_SOXR
#include <soxr.h>
#endif
@@ -82,7 +82,7 @@
#include "alac.h"
#ifdef HAVE_ALAC
#ifdef CONFIG_APPLE_ALAC
#include "apple_alac.h"
#endif
@@ -260,17 +260,17 @@ static int alac_decode(short *dest, int *destlen, uint8_t *buf, int len, rtsp_co
unsigned char iv[16];
int aeslen = len & ~0xf;
memcpy(iv, conn->stream.aesiv, sizeof(iv));
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
mbedtls_aes_crypt_cbc(&conn->dctx, MBEDTLS_AES_DECRYPT, aeslen, iv, buf, packet);
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
aes_crypt_cbc(&conn->dctx, AES_DECRYPT, aeslen, iv, buf, packet);
#endif
#ifdef HAVE_LIBSSL
#ifdef CONFIG_OPENSSL
AES_cbc_encrypt(buf, packet, aeslen, &conn->aes, iv, AES_DECRYPT);
#endif
memcpy(packet + aeslen, buf + aeslen, len - aeslen);
#ifdef HAVE_ALAC
#ifdef CONFIG_APPLE_ALAC
if (config.use_apple_decoder) {
if (conn->decoder_in_use != 1 << decoder_apple_alac) {
debug(2, "Apple ALAC Decoder used on encrypted audio.");
@@ -289,7 +289,7 @@ static int alac_decode(short *dest, int *destlen, uint8_t *buf, int len, rtsp_co
}
} else {
// not encrypted
#ifdef HAVE_ALAC
#ifdef CONFIG_APPLE_ALAC
if (config.use_apple_decoder) {
if (conn->decoder_in_use != 1 << decoder_apple_alac) {
debug(2, "Apple ALAC Decoder used on unencrypted audio.");
@@ -431,7 +431,7 @@ static int init_decoder(int32_t fmtp[12], rtsp_conn_info *conn) {
alac->setinfo_8a_rate = fmtp[11];
alac_allocate_buffers(alac); // no pthread cancellation point in here
#ifdef HAVE_ALAC
#ifdef CONFIG_APPLE_ALAC
apple_alac_init(fmtp); // no pthread cancellation point in here
#endif
@@ -440,7 +440,7 @@ static int init_decoder(int32_t fmtp[12], rtsp_conn_info *conn) {
static void terminate_decoders(rtsp_conn_info *conn) {
alac_free(conn->decoder_info);
#ifdef HAVE_ALAC
#ifdef CONFIG_APPLE_ALAC
apple_alac_terminate();
#endif
}
@@ -1320,7 +1320,7 @@ static int stuff_buffer_basic_32(int32_t *inptr, int length, enum sps_format_t l
return length + tstuff;
}
#ifdef HAVE_LIBSOXR
#ifdef CONFIG_SOXR
// this takes an array of signed 32-bit integers and
// (a) uses libsoxr to
// resample the array to have one more or one less frame, as specified in
@@ -1520,17 +1520,17 @@ void *player_thread_func(void *arg) {
init_buffer(conn); // will need a corresponding deallocation
if (conn->stream.encrypted) {
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
memset(&conn->dctx, 0, sizeof(mbedtls_aes_context));
mbedtls_aes_setkey_dec(&conn->dctx, conn->stream.aeskey, 128);
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
memset(&conn->dctx, 0, sizeof(aes_context));
aes_setkey_dec(&conn->dctx, conn->stream.aeskey, 128);
#endif
#ifdef HAVE_LIBSSL
#ifdef CONFIG_OPENSSL
AES_set_decrypt_key(conn->stream.aeskey, 128, &conn->aes);
#endif
}
@@ -2204,7 +2204,7 @@ void *player_thread_func(void *arg) {
stuff_buffer_basic_32((int32_t *)conn->tbuf, inbuflength, config.output_format,
conn->outbuf, amount_to_stuff, enable_dither, conn);
}
#ifdef HAVE_LIBSOXR
#ifdef CONFIG_SOXR
else if (config.packet_stuffing == ST_soxr) {
// if (amount_to_stuff) debug(1,"Soxr stuff...");
play_samples = stuff_buffer_soxr_32((int32_t *)conn->tbuf, (int32_t *)conn->sbuf,
+6 -6
View File
@@ -7,17 +7,17 @@
#include "config.h"
#include "definitions.h"
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
#include <mbedtls/aes.h>
#include <mbedtls/havege.h>
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
#include <polarssl/aes.h>
#include <polarssl/havege.h>
#endif
#ifdef HAVE_LIBSSL
#ifdef CONFIG_OPENSSL
#include <openssl/aes.h>
#endif
@@ -140,15 +140,15 @@ typedef struct {
uint64_t time_of_last_audio_packet;
seq_t ab_read, ab_write;
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
mbedtls_aes_context dctx;
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
aes_context dctx;
#endif
#ifdef HAVE_LIBSSL
#ifdef CONFIG_OPENSSL
AES_KEY aes;
#endif
+11 -11
View File
@@ -46,15 +46,15 @@
#include "config.h"
#ifdef HAVE_LIBSSL
#ifdef CONFIG_OPENSSL
#include <openssl/md5.h>
#endif
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
#include <mbedtls/md5.h>
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
#include <polarssl/md5.h>
#endif
@@ -67,7 +67,7 @@
#include "metadata_hub.h"
#endif
#ifdef HAVE_LIBMOSQUITTO
#ifdef CONFIG_MQTT
#include "mqtt.h"
#endif
@@ -1301,7 +1301,7 @@ void *metadata_thread_function(__attribute__((unused)) void *ignore) {
#ifdef CONFIG_METADATA_HUB
metadata_hub_process_metadata(pack.type, pack.code, pack.data, pack.length);
#endif
#ifdef HAVE_LIBMOSQUITTO
#ifdef CONFIG_MQTT
if (config.mqtt_enabled) {
mqtt_process_metadata(pack.type, pack.code, pack.data, pack.length);
}
@@ -1836,7 +1836,7 @@ static int rtsp_auth(char **nonce, rtsp_message *req, rtsp_message *resp) {
uint8_t digest_urp[16], digest_mu[16], digest_total[16];
#ifdef HAVE_LIBSSL
#ifdef CONFIG_OPENSSL
MD5_CTX ctx;
MD5_Init(&ctx);
@@ -1853,7 +1853,7 @@ static int rtsp_auth(char **nonce, rtsp_message *req, rtsp_message *resp) {
MD5_Final(digest_mu, &ctx);
#endif
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
mbedtls_md5_context tctx;
mbedtls_md5_starts(&tctx);
mbedtls_md5_update(&tctx, (const unsigned char *)username, strlen(username));
@@ -1869,7 +1869,7 @@ static int rtsp_auth(char **nonce, rtsp_message *req, rtsp_message *resp) {
mbedtls_md5_finish(&tctx, digest_mu);
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
md5_context tctx;
md5_starts(&tctx);
md5_update(&tctx, (const unsigned char *)username, strlen(username));
@@ -1890,7 +1890,7 @@ static int rtsp_auth(char **nonce, rtsp_message *req, rtsp_message *resp) {
for (i = 0; i < 16; i++)
snprintf((char *)buf + 2 * i, 3, "%02x", digest_urp[i]);
#ifdef HAVE_LIBSSL
#ifdef CONFIG_OPENSSL
MD5_Init(&ctx);
MD5_Update(&ctx, buf, 32);
MD5_Update(&ctx, ":", 1);
@@ -1902,7 +1902,7 @@ static int rtsp_auth(char **nonce, rtsp_message *req, rtsp_message *resp) {
MD5_Final(digest_total, &ctx);
#endif
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
mbedtls_md5_starts(&tctx);
mbedtls_md5_update(&tctx, buf, 32);
mbedtls_md5_update(&tctx, (unsigned char *)":", 1);
@@ -1914,7 +1914,7 @@ static int rtsp_auth(char **nonce, rtsp_message *req, rtsp_message *resp) {
mbedtls_md5_finish(&tctx, digest_total);
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
md5_starts(&tctx);
md5_update(&tctx, buf, 32);
md5_update(&tctx, (unsigned char *)":", 1);
+26 -26
View File
@@ -43,19 +43,19 @@
#include "config.h"
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
#include <mbedtls/md5.h>
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
#include <polarssl/md5.h>
#endif
#ifdef HAVE_LIBSSL
#ifdef CONFIG_OPENSSL
#include <openssl/md5.h>
#endif
#if defined(HAVE_DBUS)
#if defined(CONFIG_DBUS_INTERFACE)
#include <glib.h>
#endif
@@ -72,15 +72,15 @@
#include "metadata_hub.h"
#endif
#ifdef HAVE_DBUS
#ifdef CONFIG_DBUS_INTERFACE
#include "dbus-service.h"
#endif
#ifdef HAVE_LIBMOSQUITTO
#ifdef CONFIG_MQTT
#include "mqtt.h"
#endif
#ifdef HAVE_MPRIS
#ifdef CONFIG_MPRIS_INTERFACE
#include "mpris-service.h"
#endif
@@ -434,7 +434,7 @@ int parse_options(int argc, char **argv) {
if (strcasecmp(str, "basic") == 0)
config.packet_stuffing = ST_basic;
else if (strcasecmp(str, "soxr") == 0)
#ifdef HAVE_LIBSOXR
#ifdef CONFIG_SOXR
config.packet_stuffing = ST_soxr;
#else
die("The soxr option not available because this version of shairport-sync was built "
@@ -827,7 +827,7 @@ int parse_options(int argc, char **argv) {
config_error_file(&config_file_stuff), config_error_text(&config_file_stuff));
}
}
#if defined(HAVE_DBUS)
#if defined(CONFIG_DBUS_INTERFACE)
/* Get the dbus service sbus setting. */
if (config_lookup_string(config.cfg, "general.dbus_service_bus", &str)) {
if (strcasecmp(str, "system") == 0)
@@ -840,7 +840,7 @@ int parse_options(int argc, char **argv) {
}
#endif
#if defined(HAVE_MPRIS)
#if defined(CONFIG_MPRIS_INTERFACE)
/* Get the mpris service sbus setting. */
if (config_lookup_string(config.cfg, "general.mpris_service_bus", &str)) {
if (strcasecmp(str, "system") == 0)
@@ -853,7 +853,7 @@ int parse_options(int argc, char **argv) {
}
#endif
#ifdef HAVE_LIBMOSQUITTO
#ifdef CONFIG_MQTT
int tmpval = 0;
config_set_lookup_bool(config.cfg, "mqtt.enabled", &config.mqtt_enabled);
if (config.mqtt_enabled && !config.metadata_enabled) {
@@ -954,7 +954,7 @@ int parse_options(int argc, char **argv) {
if (strcmp(stuffing, "basic") == 0)
config.packet_stuffing = ST_basic;
else if (strcmp(stuffing, "soxr") == 0)
#ifdef HAVE_LIBSOXR
#ifdef CONFIG_SOXR
config.packet_stuffing = ST_soxr;
#else
die("The soxr option not available because this version of shairport-sync was built "
@@ -1007,7 +1007,7 @@ int parse_options(int argc, char **argv) {
free(i3);
free(vs);
#ifdef HAVE_LIBMOSQUITTO
#ifdef CONFIG_MQTT
// mqtt topic was not set. As we have the service name just now, set it
if (config.mqtt_topic == NULL) {
int topic_length = 1 + strlen(config.service_name) + 1;
@@ -1032,7 +1032,7 @@ int parse_options(int argc, char **argv) {
return optind + 1;
}
#if defined(HAVE_DBUS) || defined(HAVE_MPRIS)
#if defined(CONFIG_DBUS_INTERFACE) || defined(CONFIG_MPRIS_INTERFACE)
GMainLoop *g_main_loop;
pthread_t dbus_thread;
@@ -1124,17 +1124,17 @@ void exit_function() {
void main_cleanup_handler(__attribute__((unused)) void *arg) {
debug(1, "main cleanup handler called.");
#ifdef HAVE_LIBMOSQUITTO
#ifdef CONFIG_MQTT
if (config.mqtt_enabled) {
// terminate_mqtt();
}
#endif
#if defined(HAVE_DBUS) || defined(HAVE_MPRIS)
#ifdef HAVE_MPRIS
#if defined(CONFIG_DBUS_INTERFACE) || defined(CONFIG_MPRIS_INTERFACE)
#ifdef CONFIG_MPRIS_INTERFACE
// stop_mpris_service();
#endif
#ifdef HAVE_DBUS
#ifdef CONFIG_DBUS_INTERFACE
stop_dbus_service();
#endif
debug(1, "Stopping DBUS Loop Thread");
@@ -1239,7 +1239,7 @@ int main(int argc, char **argv) {
config.output_rate = 44100; // default
config.decoders_supported =
1 << decoder_hammerton; // David Hammerton's decoder supported by default
#ifdef HAVE_ALAC
#ifdef CONFIG_APPLE_ALAC
config.decoders_supported += 1 << decoder_apple_alac;
#endif
@@ -1570,21 +1570,21 @@ int main(int argc, char **argv) {
uint8_t ap_md5[16];
#ifdef HAVE_LIBSSL
#ifdef CONFIG_OPENSSL
MD5_CTX ctx;
MD5_Init(&ctx);
MD5_Update(&ctx, config.service_name, strlen(config.service_name));
MD5_Final(ap_md5, &ctx);
#endif
#ifdef HAVE_LIBMBEDTLS
#ifdef CONFIG_MBEDTLS
mbedtls_md5_context tctx;
mbedtls_md5_starts(&tctx);
mbedtls_md5_update(&tctx, (unsigned char *)config.service_name, strlen(config.service_name));
mbedtls_md5_finish(&tctx, ap_md5);
#endif
#ifdef HAVE_LIBPOLARSSL
#ifdef CONFIG_POLARSSL
md5_context tctx;
md5_starts(&tctx);
md5_update(&tctx, (unsigned char *)config.service_name, strlen(config.service_name));
@@ -1605,19 +1605,19 @@ int main(int argc, char **argv) {
dacp_monitor_start();
#endif
#if defined(HAVE_DBUS) || defined(HAVE_MPRIS)
#if defined(CONFIG_DBUS_INTERFACE) || defined(CONFIG_MPRIS_INTERFACE)
// Start up DBUS services after initial settings are all made
// debug(1, "Starting up D-Bus services");
pthread_create(&dbus_thread, NULL, &dbus_thread_func, NULL);
#ifdef HAVE_DBUS
#ifdef CONFIG_DBUS_INTERFACE
start_dbus_service();
#endif
#ifdef HAVE_MPRIS
#ifdef CONFIG_MPRIS_INTERFACE
start_mpris_service();
#endif
#endif
#ifdef HAVE_LIBMOSQUITTO
#ifdef CONFIG_MQTT
if (config.mqtt_enabled) {
initialise_mqtt();
}