rc = pthread_cond_init(&activity_monitor_cv, NULL);
if (rc)
- die("activity_monitor: error %d initialising activity_monitor_cv.");
+ die("activity_monitor: error %d initialising activity_monitor_cv.", rc);
pthread_cleanup_push(activity_thread_cleanup_handler, arg);
uint64_t sec;
}
*p = '\0';
if (strlen(buf) == 0)
- debug(3, "No \"%s\" output format settings.", stanza_name, buf);
+ debug(3, "No \"%s\" output format settings.", stanza_name);
else
debug(3, "The \"%s\" output format settings are: \"%s\".", stanza_name, buf);
return format_set;
}
*p = '\0';
if (strlen(buf) == 0)
- debug(3, "No \"%s\" output rate settings.", stanza_name, buf);
+ debug(3, "No \"%s\" output rate settings.", stanza_name);
else
debug(3, "The \"%s\" output rate settings are: \"%s\".", stanza_name, buf);
return rate_set;
}
*p = '\0';
if (strlen(buf) == 0)
- debug(3, "No \"%s\" output channel settings.", stanza_name, buf);
+ debug(3, "No \"%s\" output channel settings.", stanza_name);
else
debug(3, "The \"%s\" output channel settings are: \"%s\".", stanza_name, buf);
return channel_set;
permissible_configurations[r][f][c] =
0; // i.e. no error, so remove the EINVAL
} else {
- debug(1, "Can't set format of %u for \"%s\": %s.",
+ debug(1, "Can't set format %s for \"%s\": %s.",
sps_format_description_string(f), alsa_out_dev,
snd_strerror(ret));
}
ret = snd_pcm_open(&alsa_handle, "hw:0", SND_PCM_STREAM_PLAYBACK, 0);
if ((ret == 0) || (ret == -EBUSY)) {
// being busy should be okay
- inform("the default ALSA device is inaccessible -- \"hw:0\" used instead.", alsa_out_dev);
+ inform("the default ALSA device is inaccessible -- \"hw:0\" used instead.");
set_alsa_out_dev("hw:0");
}
}
if ((snd_pcm_hw_params_get_rate_numden(alsa_params, &uval, &uval2) == 0) && (uval2 != 0))
// watch for a divide by zero too!
- debug(log_level, " precise (rational) rate = %.3f frames per second (i.e. %u/%u).", uval,
- uval2, ((double)uval) / uval2);
+ debug(log_level, " precise (rational) rate = %.3f frames per second (i.e. %u/%u).", (1.0 * uval) / uval2, uval,
+ uval2);
else
debug(log_level, " precise (rational) rate information unavailable.");
else {
warn("Invalid disable_synchronization option choice \"%s\". It should "
"be \"yes\" or "
- "\"no\". It is set to \"no\".");
+ "\"no\". It is set to \"no\".", str);
config.no_sync = 0;
}
}
else {
warn("Invalid mute_using_playback_switch option choice \"%s\". It "
"should be \"yes\" or "
- "\"no\". It is set to \"no\".");
+ "\"no\". It is set to \"no\".", str);
config.alsa_use_hardware_mute = 0;
}
}
else {
warn("Invalid use_hardware_mute_if_available option choice \"%s\". It "
"should be \"yes\" or "
- "\"no\". It is set to \"no\".");
+ "\"no\". It is set to \"no\".", str);
config.alsa_use_hardware_mute = 0;
}
}
else {
warn("Invalid use_mmap_if_available option choice \"%s\". It should be "
"\"yes\" or \"no\". "
- "It remains set to \"yes\".");
+ "It remains set to \"yes\".", str);
config.no_mmap = 0;
}
}
if (value < 0) {
warn("Invalid alsa disable_standby_mode_default_rate setting %d. It "
"must be greater than 0. Default is %d. No setting is made.",
- dvalue, disable_standby_mode_default_rate);
+ value, disable_standby_mode_default_rate);
} else {
disable_standby_mode_default_rate = value;
}
if (value < 0) {
warn("Invalid alsa disable_standby_mode_default_channels setting %d. It "
"must be greater than 0. Default is %d. No setting is made.",
- dvalue, disable_standby_mode_default_channels);
+ value, disable_standby_mode_default_channels);
} else {
disable_standby_mode_default_channels = value;
}
else {
warn("Invalid use_precision_timing option choice \"%s\". It should be "
"\"yes\", \"auto\" or \"no\". "
- "It remains set to \"%s\".",
+ "It remains set to \"%s\".", str,
config.use_precision_timing == YNA_NO ? "no"
: config.use_precision_timing == YNA_AUTO ? "auto"
: "yes");
*delay = delay_temp;
if (state != NULL)
*state = state_temp;
- debug(3, "precision_delay_and_status returning state: %d and delay %d.", state_temp, delay_temp);
+ debug(3, "precision_delay_and_status returning state: %d and delay %ld.", state_temp, delay_temp);
return ret;
}
dither_random_number_store, current_encoded_output_format);
ret = do_play(silence, frames_of_silence);
- debug(3, "Played %u frames of silence on %u channels, equal to %u bytes.",
+ debug(3, "Played %u frames of silence on %u channels, equal to %lu bytes.",
frames_of_silence, CHANNELS_FROM_ENCODED_FORMAT(current_encoded_output_format),
size_of_silence_buffer);
frame_count++;
rem = req;
} while ((result == -1) && (errno == EINTR));
if (result == -1)
- debug(1, "Error in sps_nanosleep of %d sec and %ld nanoseconds: %d.", sec, nanosec, errno);
+ debug(1, "Error in sps_nanosleep of %ld sec and %ld nanoseconds: %d.", sec, nanosec, errno);
}
// Mac OS X doesn't have pthread_mutex_timedlock
void socket_cleanup(void *arg) {
intptr_t fdp = (intptr_t)arg;
int soc = fdp;
- debug(3, "socket_cleanup called for socket: %" PRIdPTR ".", soc);
+ debug(3, "socket_cleanup called for socket: %d.", soc);
close(fdp);
}
}
if (*b == NULL)
- warn("%s mDNS backend not found");
+ warn("mDNS backend not found");
} else {
// default -- pick the first back end
for (b = mdns_backends; *b; b++) {
/* Called whenever a new services becomes available on the LAN or is removed from the LAN */
switch (event) {
case AVAHI_BROWSER_FAILURE:
- warn("avahi: browser failure.",
+ warn("avahi: browser failure: %s.",
avahi_strerror(avahi_client_errno(avahi_service_browser_get_client(b))));
avahi_threaded_poll_quit(tpoll);
break;
if (offset_to_flush_frame > 0) {
debug(2,
"flush to %u request: flush buffer %u, from "
- "%u to %u. ab_write is: %u.",
+ "%u to %lu. ab_write is: %u.",
conn->flush_rtp_timestamp, conn->ab_read, current_packet->timestamp,
current_packet->timestamp + current_packet->length - 1,
conn->ab_write);
CHANNELS_FROM_ENCODED_FORMAT(config.current_output_configuration) *
fs);
if (silence == NULL)
- debug(1, "Failed to allocate %d byte silence buffer.", fs);
+ debug(1, "Failed to allocate %" PRId64 " byte silence buffer.", fs);
else {
// generate frames of silence with dither if necessary
pthread_cleanup_push(malloc_cleanup, &silence);
1000000000;
// debug(1,"%d frames needed.",frame_gap);
while (frame_gap > 0) {
- ssize_t fs = RATE_FROM_ENCODED_FORMAT(config.current_output_configuration) / 10;
+ int64_t fs = RATE_FROM_ENCODED_FORMAT(config.current_output_configuration) / 10;
if (fs > frame_gap)
fs = frame_gap;
FORMAT_FROM_ENCODED_FORMAT(config.current_output_configuration)) *
CHANNELS_FROM_ENCODED_FORMAT(config.current_output_configuration) * fs);
if (silence == NULL)
- debug(1, "Failed to allocate %d frame silence buffer.", fs);
+ debug(1, "Failed to allocate %" PRId64 " frame silence buffer.", fs);
else {
// debug(1, "No delay function -- outputting %d frames of silence.", fs);
pthread_cleanup_push(malloc_cleanup, &silence);
debug(1,
"Can't see how this could ever happen, but "
"current_input_sample_floor_index %" PRId64
- " has just stepped outside the frame of %" PRId64
- "samples, with stuff %d and current_input_sample_index_fp at %" PRId64 ".%05" PRId64
+ " has just stepped outside the frame of %d samples, with stuff %d and current_input_sample_index_fp at %" PRId64 ".%05" PRId64
".",
current_input_sample_floor_index, length, stuff, current_input_sample_index_int,
current_input_sample_index_low);
debug(1,
"Can't see how this could ever happen, but "
"current_input_sample_ceil_index %" PRId64
- " has just stepped outside the frame of %" PRId64
- "samples, with stuff %d and current_input_sample_index_fp at %" PRId64
+ " has just stepped outside the frame of %d samples, with stuff %d and current_input_sample_index_fp at %" PRId64
".%05" PRId64 ".",
current_input_sample_floor_index, length, stuff, current_input_sample_index_int,
current_input_sample_index_low);
NULL, NULL); // Default configuration.
if (error)
- die("soxr error: %s\n", "error: %s\n", soxr_strerror(error));
+ die("soxr error: %s\n", soxr_strerror(error));
if (odone > (size_t)(length + INTERPOLATION_LIMIT))
- die("odone = %u!\n", odone);
+ die("odone = %lu!\n", odone);
// mean and variance calculations from "online_variance" algorithm at
// https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Online_algorithm
(conn->input_effective_bit_depth > conn->output_bit_depth)) ||
(config.playback_mode == ST_mono)) {
if (conn->enable_dither == 0)
- debug(2, "enabling dither", conn->fix_volume);
+ debug(2, "enabling dither");
conn->enable_dither = 1;
} else {
if (conn->enable_dither != 0)
insertions_plus_deletions_ppm =
(1000000.0 * tsum_of_insertions_and_deletions) / tsum_of_frames;
} else {
- debug(3, "tsum_of_frames: %u.", tsum_of_frames);
+ debug(3, "tsum_of_frames: %lu.", tsum_of_frames);
}
}
if (config.statistics_requested) {
if (skipping_frames_at_start_of_play != 0) {
if (sync_error <= 0) {
debug(3,
- "cancel skipping at start of play -- skip estimate was: %" PRId64
+ "cancel skipping at start of play -- skip estimate was: %" PRId32
", but sync_error is now: %" PRId64 ".",
frames_to_skip, sync_error);
frames_to_skip = 0;
skipping_frames_at_start_of_play = 0;
} else if (frames_to_skip != sync_error) {
debug(3,
- "updating skipping at start of play count from: %" PRId64 " to: %" PRId64
+ "updating skipping at start of play count from: %" PRId32 " to: %" PRId64
".",
frames_to_skip, sync_error);
frames_to_skip = sync_error;
debug(2, "resend-related request packet received, ignoring.");
continue;
}
- debug(1, "Audio receiver -- Unknown RTP packet of type 0x%02X length %d seqno %d", type,
+ debug(1, "Audio receiver -- Unknown RTP packet of type 0x%02X length %ld seqno %d", type,
nread, seqno);
}
- warn("Audio receiver -- Unknown RTP packet of type 0x%02X length %d.", type, nread);
+ warn("Audio receiver -- Unknown RTP packet of type 0x%02X length %ld.", type, nread);
} else {
char em[1024];
strerror_r(errno, em, sizeof(em));
debug(3, "Too-short retransmitted audio packet received in control port, ignored.");
}
} else
- debug(1, "Control Receiver -- Unknown RTP packet of type 0x%02X length %d, ignored.",
+ debug(1, "Control Receiver -- Unknown RTP packet of type 0x%02X length %ld, ignored.",
packet[1], nread);
} else {
debug(3, "Control Receiver -- dropping a packet to simulate a bad network.");
// conn->time_pings[cc].dispersion * pow(2.14,
// 1.0/conn->time_ping_count);
if (conn->time_pings[cc].dispersion > UINT64_MAX / dispersion_factor)
- debug(1, "dispersion factor is too large at %" PRIu64 ".");
+ debug(1, "dispersion factor is too large at %" PRIu64 ".", dispersion_factor);
else
conn->time_pings[cc].dispersion =
(conn->time_pings[cc].dispersion * dispersion_factor) /
return_time);
}
} else {
- debug(1, "Timing port -- Unknown RTP packet of type 0x%02X length %d.", packet[1], nread);
+ debug(1, "Timing port -- Unknown RTP packet of type 0x%02X length %ld.", packet[1], nread);
}
} else {
debug(3, "Timing Receiver Thread -- dropping incoming packet to simulate a bad network.");
pthread_cleanup_pop(1); // release the principal_conn lock
} else {
- debug(1, "Connection %d: %s get_play_lock must have a non-NULL conn.");
+ debug(1, "Connection %d: %s get_play_lock must have a non-NULL conn.", conn->connection_number,
+ get_category_string(conn->airplay_stream_category));
}
return response;
}
if (rc)
debug(1, "Error %d unlocking reference counter lock", rc);
} else {
- debug(1, "invalid rtsp_message pointer 0x%x passed to retain", (uintptr_t)msg);
+ debug(1, "invalid rtsp_message pointer 0x%" PRIxPTR " passed to retain", (uintptr_t)msg);
}
}
// no thread cancellation points here
int rc = debug_mutex_lock(&reference_counter_lock, 500000, 1);
if (rc)
- debug(1, "Error %d locking reference counter lock");
+ debug(1, "Error %d locking reference counter lock", rc);
rtsp_message *msg = malloc(sizeof(rtsp_message));
if (msg) {
rc = pthread_mutex_unlock(&reference_counter_lock);
if (rc)
- debug(1, "Error %d unlocking reference counter lock");
+ debug(1, "Error %d unlocking reference counter lock", rc);
return msg;
}
} else if (*msgh != NULL) {
debug(1,
"msg_free: error attempting to free an allocated but already-freed rtsp_message, number "
- "%d.",
+ "%" PRIxPTR ".",
(uintptr_t)*msgh);
}
debug_mutex_unlock(&reference_counter_lock, 0);
if ((result <= 0) && (errno != 0)) {
char errorstring[1024];
strerror_r(errno, (char *)errorstring, sizeof(errorstring));
- debug(3, "read_from_rtsp_connection error %d \"%s\" attempting to read up to %u bytes.",
+ debug(3, "read_from_rtsp_connection error %d \"%s\" attempting to read up to %lu bytes.",
errno, errorstring, count);
}
} else {
debug(1, "Connection %d: rtsp_read_request: can't get a buffer.", conn->connection_number);
reply = rtsp_read_request_response_error;
} else {
- debug(3, "buf is allocated at 0x%" PRIxPTR ".", buf);
+ debug(3, "buf is allocated at 0x%" PRIxPTR ".", (uintptr_t)buf);
pthread_cleanup_push(malloc_cleanup, &buf);
ssize_t nread;
ssize_t inbuf = 0;
reply = rtsp_read_request_response_error;
// goto shutdown;
} else {
- debug(3, "buf is reallocated at 0x%" PRIxPTR ".", buf);
+ debug(3, "buf is reallocated at 0x%" PRIxPTR ".", (uintptr_t)buf);
buflen = msg_size;
}
}
return -4;
}
if (reply != p - pkt) {
- debug(1, "msg_write_response error -- requested bytes: %d not fully written: %d.", p - pkt,
+ debug(1, "msg_write_response error -- requested bytes: %ld not fully written: %ld.", p - pkt,
reply);
return -5;
}
debug(2,
"Connection %d: SETUP DACP-ID \"%s\" from %s to %s with UDP ports Control: "
"%d, Timing: %d and Audio: %d.",
- conn->connection_number, conn->dacp_id, &conn->client_ip_string,
- &conn->self_ip_string, conn->local_control_port, conn->local_timing_port,
+ conn->connection_number, conn->dacp_id, (char *)&conn->client_ip_string,
+ (char *)&conn->self_ip_string, conn->local_control_port, conn->local_timing_port,
conn->local_audio_port);
} else {
#endif
} else {
- debug(1, "Connection %d, unrecognised parameter: \"%s\" (%d)\n", conn->connection_number, cp,
- strlen(cp));
+ debug(1, "Connection %d, unrecognised parameter: \"%s\"\n", conn->connection_number, cp);
}
cp = next;
}
}
void msg_cleanup_function(void *arg) {
- debug(3, "msg_cleanup_function called 0x%" PRIxPTR ".", arg);
+ debug(3, "msg_cleanup_function called 0x%" PRIxPTR ".", (uintptr_t)arg);
msg_free((rtsp_message **)arg);
}
int i;
for (i = 0; i < nconns; i++) {
if ((conns[i] != NULL) && (conns[i]->connection_number == 0)) {
- debug(1, "conns[%d] at %" PRIxPTR " has a Connection Number of 0!", i, conns[i]);
+ debug(1, "conns[%d] has a Connection Number of 0!", i);
}
}
debug_mutex_unlock(&conns_lock, 3);
debug(1, "rtsp_read_request_response_bad_packet write response error %d: \"%s\".", errno,
(char *)errorstring);
} else if (lreply != (ssize_t)strlen(response_text)) {
- debug(1, "rtsp_read_request_response_bad_packet write %d bytes requested but %d written.",
+ debug(1, "rtsp_read_request_response_bad_packet write %ld bytes requested but %d written.",
strlen(response_text), reply);
}
}
pthread_cleanup_push(malloc_cleanup, &conn);
memset(conn, 0, sizeof(rtsp_conn_info));
conn->connection_number = RTSP_connection_index++;
- debug(2, "Connection %d is at: 0x%" PRIxPTR ".", conn->connection_number, conn);
+ debug(2, "Connection %d is at: 0x%" PRIxPTR ".", conn->connection_number, (uintptr_t)conn);
// this means that the OPTIONS string we send before getting an ANNOUNCE is for AirPlay 2
#ifdef CONFIG_AIRPLAY_2
if (config_lookup_int(config.cfg, "general.port", &value)) {
if ((value < 0) || (value > 65535))
#ifdef CONFIG_AIRPLAY_2
- die("Invalid port number \"%sd\". It should be between 0 and 65535, default is 7000",
+ die("Invalid port number \"%d\". It should be between 0 and 65535, default is 7000",
value);
#else
- die("Invalid port number \"%sd\". It should be between 0 and 65535, default is 5000",
+ die("Invalid port number \"%d\". It should be between 0 and 65535, default is 5000",
value);
#endif
else
/* Get the udp port base setting. */
if (config_lookup_int(config.cfg, "general.udp_port_base", &value)) {
if ((value < 0) || (value > 65535))
- die("Invalid port number \"%sd\". It should be between 0 and 65535, default is 6001",
+ die("Invalid port number \"%d\". It should be between 0 and 65535, default is 6001",
value);
else
config.udp_port_base = value;
* starting at the port base. Only three ports are needed. */
if (config_lookup_int(config.cfg, "general.udp_port_range", &value)) {
if ((value < 3) || (value > 65535))
- die("Invalid port range \"%sd\". It should be between 3 and 65535, default is 10",
+ die("Invalid port range \"%d\". It should be between 3 and 65535, default is 10",
value);
else
config.udp_port_range = value;
if ((dvalue >= 0.0) && (dvalue <= 3.0))
config.diagnostic_drop_packet_fraction = dvalue;
else
- die("Invalid diagnostics drop_this_fraction_of_audio_packets setting \"%d\". It should "
+ die("Invalid diagnostics drop_this_fraction_of_audio_packets setting \"%f\". It should "
"be "
"between 0.0 and 1.0, "
"inclusive.",
} else if (value < 60) {
warn("Invalid value \"%d\" for \"session_timeout\". It must be 0 (i.e. no timeout) or at "
"least 60. "
- "The default of %f will be used instead.",
+ "The default of %d will be used instead.",
value, config.timeout);
config.dont_check_timeout = 0;
} else {
void _display_config(const char *filename, const int linenumber, __attribute__((unused)) int argc,
__attribute__((unused)) char **argv) {
+
+#if defined(__GNUC__) || defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-zero-length"
+#endif
+
_inform(filename, linenumber, ">> Display Config Start.");
// see the man entry on popen
}
}
_inform(filename, linenumber, "");
- _inform(filename, linenumber, ">> Display Config End.");
+ _inform(filename, linenumber, ">> Display Config End.");
+
+ #if defined(__GNUC__) || defined(__clang__)
+ #pragma GCC diagnostic pop
+ #endif
}
#define display_config(argc, argv) _display_config(__FILE__, __LINE__, argc, argv)
EXTERNC int get_show_file_and_line();
EXTERNC void set_show_file_and_line(int setting);
-EXTERNC void _die(const char *filename, const int linenumber, const char *format, ...);
-EXTERNC void _warn(const char *filename, const int linenumber, const char *format, ...);
-EXTERNC void _inform(const char *filename, const int linenumber, const char *format, ...);
-EXTERNC void _debug(const char *filename, const int linenumber, int level, const char *format, ...);
-EXTERNC void _debug_print_buffer(const char *thefilename, const int linenumber, int level,
- void *buf, size_t buf_len);
+#if defined(__GNUC__) || defined(__clang__)
+#define PRINTF_LIKE(fmt, args) __attribute__((format(printf, fmt, args)))
+#else
+#define PRINTF_LIKE(fmt, args)
+#endif
+// Function declarations with printf-style format checking
+EXTERNC void _die(const char *filename, const int linenumber, const char *format, ...) PRINTF_LIKE(3,4);
+EXTERNC void _warn(const char *filename, const int linenumber, const char *format, ...) PRINTF_LIKE(3,4);
+EXTERNC void _inform(const char *filename, const int linenumber, const char *format, ...) PRINTF_LIKE(3,4);
+EXTERNC void _debug(const char *filename, const int linenumber, int level, const char *format, ...) PRINTF_LIKE(4,5);
+EXTERNC void _debug_print_buffer(const char *thefilename, const int linenumber, int level, void *buf,
+ size_t buf_len); // not printf-style, no change needed
#define die(...) _die(__FILE__, __LINE__, __VA_ARGS__)
#define debug(...) _debug(__FILE__, __LINE__, __VA_ARGS__)
#define warn(...) _warn(__FILE__, __LINE__, __VA_ARGS__)
char errorstring[1024];
strerror_r(errno, (char *)errorstring, sizeof(errorstring));
debug(1,
- "error %d accept()ing a socketin ap2_event_receiver %d: \"%s\". Error %d is ignored.",
+ "error %d accept()ing a socketin ap2_event_receiver: \"%s\". (Note: error %d will be ignored.)",
errno, errorstring, EINTR);
}