int alsa_device_initialised; // boolean to ensure the initialisation is only
// done once
-enum yndk_type precision_delay_available_status =
+yndk_type precision_delay_available_status =
YNDK_DONT_KNOW; // initially, we don't know if the device can do precision delay
snd_pcm_t *alsa_handle = NULL;
snd_pcm_sframes_t (*alsa_pcm_write)(snd_pcm_t *, const void *, snd_pcm_uframes_t) = snd_pcm_writei;
int precision_delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay,
- enum yndk_type *using_update_timestamps);
+ yndk_type *using_update_timestamps);
int standard_delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay,
- enum yndk_type *using_update_timestamps);
+ yndk_type *using_update_timestamps);
// use this to allow the use of standard or precision delay calculations, with standard the, uh,
// standard.
int (*delay_and_status)(snd_pcm_state_t *state, snd_pcm_sframes_t *delay,
- enum yndk_type *using_update_timestamps) = standard_delay_and_status;
+ yndk_type *using_update_timestamps) = standard_delay_and_status;
// this will return true if the DAC can return precision delay information and false if not
// if it is not yet known, it will test the output device to find out
do_play(silence, frames_of_silence);
pthread_cleanup_pop(1);
// now we can get the delay, and we'll note if it uses update timestamps
- enum yndk_type uses_update_timestamps;
+ yndk_type uses_update_timestamps;
snd_pcm_state_t state;
snd_pcm_sframes_t delay;
int ret = precision_delay_and_status(&state, &delay, &uses_update_timestamps);
// be added at the lowest possible level.
// Hence, selecting the greatest bit depth is always either beneficial or neutral.
-enum sps_format_t auto_format_check_sequence[] = {
+sps_format_t auto_format_check_sequence[] = {
SPS_FORMAT_S32, SPS_FORMAT_S32_LE, SPS_FORMAT_S32_BE, SPS_FORMAT_S24, SPS_FORMAT_S24_LE,
SPS_FORMAT_S24_BE, SPS_FORMAT_S24_3LE, SPS_FORMAT_S24_3BE, SPS_FORMAT_S16, SPS_FORMAT_S16_LE,
SPS_FORMAT_S16_BE, SPS_FORMAT_S8, SPS_FORMAT_U8,
}
} else { // auto format
int number_of_formats_to_try;
- enum sps_format_t *formats;
+ sps_format_t *formats;
formats = auto_format_check_sequence;
number_of_formats_to_try = sizeof(auto_format_check_sequence) / sizeof(sps_format_t);
int i = 0;
int format_found = 0;
- enum sps_format_t trial_format = SPS_FORMAT_UNKNOWN;
+ sps_format_t trial_format = SPS_FORMAT_UNKNOWN;
while ((i < number_of_formats_to_try) && (format_found == 0)) {
trial_format = formats[i];
sf = fr[trial_format].alsa_code;
}
int standard_delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay,
- enum yndk_type *using_update_timestamps) {
+ yndk_type *using_update_timestamps) {
int ret = 0;
if (using_update_timestamps)
*using_update_timestamps = YNDK_NO;
}
int precision_delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay,
- enum yndk_type *using_update_timestamps) {
+ yndk_type *using_update_timestamps) {
snd_pcm_status_t *alsa_snd_pcm_status;
snd_pcm_status_alloca(&alsa_snd_pcm_status);
void set_alsa_out_dev(char *);
#endif
+config_t config_file_stuff;
+pthread_t main_thread_id;
+uint64_t fp_time_at_startup, fp_time_at_last_debug_message;
+
// always lock use this when accessing the fp_time_at_last_debug_message
static pthread_mutex_t debug_timing_lock = PTHREAD_MUTEX_INITIALIZER;
"unknown", "S8", "U8", "S16", "S16_LE", "S16_BE", "S24", "S24_LE",
"S24_BE", "S24_3LE", "S24_3BE", "S32", "S32_LE", "S32_BE", "auto", "invalid"};
-const char *sps_format_description_string(enum sps_format_t format) {
+const char *sps_format_description_string(sps_format_t format) {
if ((format >= SPS_FORMAT_UNKNOWN) && (format <= SPS_FORMAT_AUTO))
return sps_format_description_string_array[format];
else
return version_string;
}
-int64_t generate_zero_frames(char *outp, size_t number_of_frames, enum sps_format_t format,
+int64_t generate_zero_frames(char *outp, size_t number_of_frames, sps_format_t format,
int with_dither, int64_t random_number_in) {
// return the last random number used
// assuming the buffer has been assigned
#define sps_extra_code_output_state_cannot_make_ready 32769
// yeah/no/auto
-enum yna_type { YNA_AUTO = -1, YNA_NO = 0, YNA_YES = 1 } yna_type;
+typedef enum { YNA_AUTO = -1, YNA_NO = 0, YNA_YES = 1 } yna_type;
// yeah/no/dont-care
-enum yndk_type { YNDK_DONT_KNOW = -1, YNDK_NO = 0, YNDK_YES = 1 } yndk_type;
+typedef enum { YNDK_DONT_KNOW = -1, YNDK_NO = 0, YNDK_YES = 1 } yndk_type;
-enum endian_type {
+typedef enum {
SS_LITTLE_ENDIAN = 0,
SS_PDP_ENDIAN,
SS_BIG_ENDIAN,
} endian_type;
-enum stuffing_type {
+typedef enum {
ST_basic = 0, // straight deletion or insertion of a frame in a 352-frame packet
ST_soxr, // use libsoxr to make a 352 frame packet one frame longer or shorter
ST_auto, // use soxr if compiled for it and if the soxr_index is low enough
-} s_type;
+} stuffing_type;
-enum playback_mode_type {
+typedef enum {
ST_stereo = 0,
ST_mono,
ST_reverse_stereo,
ST_right_only,
} playback_mode_type;
-enum volume_control_profile_type {
+typedef enum {
VCP_standard = 0,
VCP_flat,
} volume_control_profile_type;
-enum decoders_supported_type {
+typedef enum {
decoder_hammerton = 0,
decoder_apple_alac,
} decoders_supported_type;
-enum disable_standby_mode_type {
+typedef enum {
disable_standby_off = 0,
disable_standby_auto,
disable_standby_always
-};
+} disable_standby_mode_type;
// the following enum is for the formats recognised -- currently only S16LE is recognised for input,
// so these are output only for the present
-enum sps_format_t {
+typedef enum {
SPS_FORMAT_UNKNOWN = 0,
SPS_FORMAT_S8,
SPS_FORMAT_U8,
SPS_FORMAT_INVALID,
} sps_format_t;
-const char *sps_format_description_string(enum sps_format_t format);
+const char *sps_format_description_string(sps_format_t format);
typedef struct {
double resend_control_first_check_time; // wait this long before asking for a missing packet to be resent
int debugger_show_relative_time; // in the debug message, display the time since the last one
int debugger_show_file_and_line; // in the debug message, display the filename and line number
int statistics_requested, use_negotiated_latencies;
- enum playback_mode_type playback_mode;
+ playback_mode_type playback_mode;
char *cmd_start, *cmd_stop, *cmd_set_volume, *cmd_unfixable;
char *cmd_active_start, *cmd_active_stop;
int cmd_blocking, cmd_start_returns_output;
double tolerance; // allow this much drift before attempting to correct it
- enum stuffing_type packet_stuffing;
+ stuffing_type packet_stuffing;
int soxr_delay_index;
int soxr_delay_threshold; // the soxr delay must be less or equal to this for soxr interpolation
// to be enabled under the auto setting
// attenuators, lowering the volume, use all the hw attenuation
// before using
// sw attenuation
- enum volume_control_profile_type volume_control_profile;
+ volume_control_profile_type volume_control_profile;
int output_format_auto_requested; // true if the configuration requests auto configuration
- enum sps_format_t output_format;
+ sps_format_t output_format;
int output_rate_auto_requested; // true if the configuration requests auto configuration
unsigned int output_rate;
float loudness_reference_volume_db;
int alsa_use_hardware_mute;
double alsa_maximum_stall_time;
- enum disable_standby_mode_type disable_standby_mode;
+ disable_standby_mode_type disable_standby_mode;
volatile int keep_dac_busy;
- enum yna_type use_precision_timing; // defaults to no
+ yna_type use_precision_timing; // defaults to no
#if defined(CONFIG_DBUS_INTERFACE)
enum dbus_session_type dbus_service_bus_type;
void resetFreeUDPPort();
uint16_t nextFreeUDPPort();
-volatile int debuglev;
+extern volatile int debuglev;
void _die(const char *filename, const int linenumber, const char *format, ...);
void _warn(const char *filename, const int linenumber, const char *format, ...);
uint64_t get_absolute_time_in_fp(void);
// time at startup for debugging timing
-uint64_t fp_time_at_startup, fp_time_at_last_debug_message;
+extern uint64_t fp_time_at_startup, fp_time_at_last_debug_message;
// this is for reading an unsigned 32 bit number, such as an RTP timestamp
uint32_t uatoi(const char *nptr);
// this is for allowing us to cancel the whole program
-pthread_t main_thread_id;
+extern pthread_t main_thread_id;
-shairport_cfg config;
-config_t config_file_stuff;
+extern shairport_cfg config;
+extern config_t config_file_stuff;
int config_set_lookup_bool(config_t *cfg, char *where, int *dst);
extern sigset_t pselect_sigset;
-pthread_mutex_t the_conn_lock;
+extern pthread_mutex_t the_conn_lock;
#define conn_lock(arg) \
pthread_mutex_lock(&the_conn_lock); \
#define config_unlock pthread_mutex_unlock(&config.lock)
-pthread_mutex_t r64_mutex;
+extern pthread_mutex_t r64_mutex;
#define r64_lock pthread_mutex_lock(&r64_mutex)
void sps_nanosleep(const time_t sec,
const long nanosec); // waits for this time, even through interruptions
-int64_t generate_zero_frames(char *outp, size_t number_of_frames, enum sps_format_t format,
+int64_t generate_zero_frames(char *outp, size_t number_of_frames, sps_format_t format,
int with_dither, int64_t random_number_in);
void malloc_cleanup(void *arg);
#define _MDNS_H
#include "config.h"
-#include <player.h>
+#include "player.h"
#include <stdint.h>
extern int mdns_pid;
return sp >> 32;
}
-static inline void process_sample(int32_t sample, char **outp, enum sps_format_t format, int volume,
+static inline void process_sample(int32_t sample, char **outp, sps_format_t format, int volume,
int dither, rtsp_conn_info *conn) {
/*
{
// formats accepted so far include U8, S8, S16, S24, S24_3LE, S24_3BE and S32
// stuff: 1 means add 1; 0 means do nothing; -1 means remove 1
-static int stuff_buffer_basic_32(int32_t *inptr, int length, enum sps_format_t l_output_format,
+static int stuff_buffer_basic_32(int32_t *inptr, int length, sps_format_t l_output_format,
char *outptr, int stuff, int dither, rtsp_conn_info *conn) {
int tstuff = stuff;
char *l_outptr = outptr;
int64_t packets_processed = 0;
int stuff_buffer_soxr_32(int32_t *inptr, int32_t *scratchBuffer, int length,
- enum sps_format_t l_output_format, char *outptr, int stuff, int dither,
+ sps_format_t l_output_format, char *outptr, int stuff, int dither,
rtsp_conn_info *conn) {
if (scratchBuffer == NULL) {
die("soxr scratchBuffer not initialised.");
#define BUFFER_FRAMES 1024
-enum audio_stream_type {
+typedef enum {
ast_unknown,
ast_uncompressed, // L16/44100/2
ast_apple_lossless,
-} ast_type;
+} audio_stream_type;
typedef struct {
int encrypted;
uint8_t aesiv[16], aeskey[16];
int32_t fmtp[12];
- enum audio_stream_type type;
+ audio_stream_type type;
} stream_cfg;
typedef struct {
rtsp_read_request_response_error
};
-// Mike Brady's part...
+rtsp_conn_info *playing_conn;
+rtsp_conn_info **conns;
int metadata_running = 0;
#include "player.h"
-rtsp_conn_info *playing_conn;
-rtsp_conn_info **conns;
+extern rtsp_conn_info *playing_conn;
+extern rtsp_conn_info **conns;
void rtsp_listen_loop(void);
// void rtsp_shutdown_stream(void);