Skip to content

Commit

Permalink
Compiles under gcc-10 with -fno-common
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebrady committed Feb 13, 2020
1 parent 89af8e8 commit f771774
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 48 deletions.
20 changes: 10 additions & 10 deletions audio_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ int frame_size; // in bytes for interleaved stereo
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;
Expand Down Expand Up @@ -159,14 +159,14 @@ int volume_based_mute_is_active =
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
Expand Down Expand Up @@ -216,7 +216,7 @@ int precision_delay_available() {
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);
Expand Down Expand Up @@ -392,7 +392,7 @@ format_record fr[] = {
// 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,
Expand Down Expand Up @@ -508,12 +508,12 @@ int actual_open_alsa_device(int do_auto_setup) {
}
} 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;
Expand Down Expand Up @@ -1422,7 +1422,7 @@ static void start(__attribute__((unused)) int i_sample_rate,
}

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;
Expand All @@ -1444,7 +1444,7 @@ int standard_delay_and_status(snd_pcm_state_t *state, snd_pcm_sframes_t *delay,
}

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);

Expand Down
8 changes: 6 additions & 2 deletions common.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
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;

Expand All @@ -96,7 +100,7 @@ const char *sps_format_description_string_array[] = {
"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
Expand Down Expand Up @@ -1381,7 +1385,7 @@ char *get_version_string() {
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
Expand Down
52 changes: 26 additions & 26 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,51 +34,51 @@ enum dbus_session_type {
#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_left_only,
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,
Expand All @@ -97,7 +97,7 @@ enum sps_format_t {
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
Expand Down Expand Up @@ -182,12 +182,12 @@ typedef struct {
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
Expand Down Expand Up @@ -221,10 +221,10 @@ typedef struct {
// 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;

Expand All @@ -240,9 +240,9 @@ typedef struct {
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;
Expand Down Expand Up @@ -321,7 +321,7 @@ int64_t r64i();
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, ...);
Expand Down Expand Up @@ -352,17 +352,17 @@ double vol2attn(double vol, long max_db, long min_db);
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);

Expand All @@ -377,7 +377,7 @@ void shairport_shutdown();

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); \
Expand Down Expand Up @@ -412,7 +412,7 @@ void pthread_cleanup_debug_mutex_unlock(void *arg);

#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)

Expand All @@ -423,7 +423,7 @@ char *get_version_string(); // mallocs a string space -- remember to free it aft
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);
Expand Down
2 changes: 1 addition & 1 deletion mdns.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define _MDNS_H

#include "config.h"
#include <player.h>
#include "player.h"
#include <stdint.h>

extern int mdns_pid;
Expand Down
6 changes: 3 additions & 3 deletions player.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ int32_t rand_in_range(int32_t exclusive_range_limit) {
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) {
/*
{
Expand Down Expand Up @@ -1392,7 +1392,7 @@ static inline int32_t mean_32(int32_t a, int32_t b) {
// 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;
Expand Down Expand Up @@ -1458,7 +1458,7 @@ double longest_soxr_execution_time_us = 0.0;
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.");
Expand Down
6 changes: 3 additions & 3 deletions player.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ typedef struct audio_buffer_entry { // decoded audio packets

#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 {
Expand Down
3 changes: 2 additions & 1 deletion rtsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ enum rtsp_read_request_response {
rtsp_read_request_response_error
};

// Mike Brady's part...
rtsp_conn_info *playing_conn;
rtsp_conn_info **conns;

int metadata_running = 0;

Expand Down
4 changes: 2 additions & 2 deletions rtsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#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);
Expand Down

0 comments on commit f771774

Please sign in to comment.