From b9e59fc18f49f516b737e5930be42dc95fec6290 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Sun, 24 Aug 2014 16:12:22 +0100 Subject: [PATCH] Add support for stuffing option, for the start and end commands and centralise how to get absolute time. --- common.h | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/common.h b/common.h index e154fa46..97f55ae4 100644 --- a/common.h +++ b/common.h @@ -1,12 +1,26 @@ #ifndef _COMMON_H #define _COMMON_H -#include #include #include +#include "config.h" #include "audio.h" #include "mdns.h" +#if defined(__APPLE__) && defined(__MACH__) + /* Apple OSX and iOS (Darwin). ------------------------------ */ +#include +#if TARGET_OS_MAC == 1 + /* OSX */ + #define COMPILE_FOR_OSX 1 +#endif +#endif + +#if defined(__linux__) + /* Linux. --------------------------------------------------- */ + #define COMPILE_FOR_LINUX 1 +#endif + // struct sockaddr_in6 is bigger than struct sockaddr. derp #ifdef AF_INET6 #define SOCKADDR struct sockaddr_storage @@ -17,11 +31,19 @@ #endif +enum stuffing_type { + ST_basic = 0, + ST_soxr, +} type; + + + typedef struct { char *password; char *apname; uint8_t hw_addr[6]; int port; + int resyncthreshold; // if it get's out of whack my more than this, resync. Zero means never resync. char *output_name; audio_output *output; char *mdns_name; @@ -33,12 +55,14 @@ typedef struct { uint32_t AirPlayLatency; //supplied with --AirPlayLatency option int daemonise; char *cmd_start, *cmd_stop; + int cmd_blocking; + enum stuffing_type packet_stuffing; char *pidfile; char *logfile; char *errfile; } shairport_cfg; -extern int debuglev; +int debuglev; void die(char *format, ...); void warn(char *format, ...); void debug(int level, char *format, ...); @@ -53,7 +77,14 @@ uint8_t *rsa_apply(uint8_t *input, int inlen, int *outlen, int mode); // given a volume (0 to -30) and high and low attenuations in dB*100 (e.g. 0 to -6000 for 0 to -60 dB), return an attenuation depending on the transfer function double vol2attn(double vol, long max_db, long min_db); -extern shairport_cfg config; +// return a monolithic (always increasing) time in nanoseconds + +uint64_t get_absolute_time_in_ns(void); + +shairport_cfg config; + +void command_start(void); +void command_stop(void); void shairport_shutdown(); // void shairport_startup_complete(void);