Eliminate almost all warnings from -Wall

This commit is contained in:
Mike Brady
2018-03-07 14:29:14 +00:00
parent a7d82ae823
commit 07e46565ca
12 changed files with 125 additions and 96 deletions
+26 -22
View File
@@ -103,8 +103,8 @@ int volume_based_mute_is_active =
static snd_pcm_sframes_t (*alsa_pcm_write)(snd_pcm_t *, const void *,
snd_pcm_uframes_t) = snd_pcm_writei;
static int play_number;
static int64_t accumulated_delay, accumulated_da_delay;
// static int play_number;
// static int64_t accumulated_delay, accumulated_da_delay;
int alsa_characteristics_already_listed = 0;
static snd_pcm_uframes_t period_size_requested, buffer_size_requested;
@@ -170,7 +170,7 @@ static int init(int argc, char **argv) {
// debug(2,"audio_alsa init called.");
const char *str;
int value;
double dvalue;
// double dvalue;
// set up default values first
set_period_size_request = 0;
@@ -433,8 +433,8 @@ static int init(int argc, char **argv) {
*/
}
}
if ((config.alsa_use_playback_switch_for_mute == 1) &&
(snd_mixer_selem_has_playback_switch(alsa_mix_elem)) ||
if (((config.alsa_use_playback_switch_for_mute == 1) &&
(snd_mixer_selem_has_playback_switch(alsa_mix_elem))) ||
mixer_volume_setting_gives_mute) {
audio_alsa.mute = &mute; // insert the mute function now we know it can do muting stuff
// debug(1, "Has mixer and mute ability we will use.");
@@ -462,13 +462,16 @@ int open_alsa_device(void) {
const snd_pcm_uframes_t minimal_buffer_headroom =
352 * 2; // we accept this much headroom in the hardware buffer, but we'll
// accept less
/*
const snd_pcm_uframes_t requested_buffer_headroom =
minimal_buffer_headroom + 2048; // we ask for this much headroom in the
// hardware buffer, but we'll accept less
*/
int ret, dir = 0;
unsigned int my_sample_rate = desired_sample_rate;
// snd_pcm_uframes_t frames = 441 * 10;
snd_pcm_uframes_t buffer_size, actual_buffer_length;
snd_pcm_uframes_t actual_buffer_length;
snd_pcm_access_t access;
// ensure no calls are made to the alsa device enquiring about the buffer length if
@@ -545,6 +548,7 @@ int open_alsa_device(void) {
break;
default:
pthread_mutex_unlock(&alsa_mutex);
sf = SND_PCM_FORMAT_S16; // this is just to quieten a compiler warning
die("Unsupported output format at audio_alsa.c");
}
ret = snd_pcm_hw_params_set_format(alsa_handle, alsa_params, sf);
@@ -591,13 +595,13 @@ int open_alsa_device(void) {
pthread_mutex_unlock(&alsa_mutex);
die("audio_alsa: cannot set buffer size of %lu: %s", buffer_size_requested,
snd_strerror(ret));
snd_pcm_uframes_t actual_buffer_size;
snd_pcm_hw_params_get_buffer_size(alsa_params, &actual_buffer_size);
if (actual_buffer_size != buffer_size_requested)
inform("Actual period size set to a different value than requested. Requested: %lu, actual "
"setting: %lu",
buffer_size, actual_buffer_size);
}
snd_pcm_uframes_t actual_buffer_size;
snd_pcm_hw_params_get_buffer_size(alsa_params, &actual_buffer_size);
if (actual_buffer_size != buffer_size_requested)
inform("Actual period size set to a different value than requested. Requested: %lu, actual "
"setting: %lu",
buffer_size_requested, actual_buffer_size);
}
ret = snd_pcm_hw_params(alsa_handle, alsa_params);
@@ -650,11 +654,11 @@ int open_alsa_device(void) {
if (alsa_characteristics_already_listed == 0) {
alsa_characteristics_already_listed = 1;
int log_level = 2; // the level at which debug information should be output
int rc;
// int rc;
snd_pcm_access_t access_type;
snd_pcm_format_t format_type;
snd_pcm_subformat_t subformat_type;
unsigned int val, val2;
// unsigned int val, val2;
unsigned int uval, uval2;
int sval;
int dir;
@@ -799,14 +803,14 @@ int delay(long *the_delay) {
return -ENODEV;
} else {
pthread_mutex_lock(&alsa_mutex);
int derr, ignore;
int derr;
if (snd_pcm_state(alsa_handle) == SND_PCM_STATE_RUNNING) {
*the_delay = 0; // just to see what happens
reply = snd_pcm_delay(alsa_handle, the_delay);
if (reply != 0) {
debug(1, "Error %d in delay(): \"%s\". Delay reported is %d frames.", reply,
snd_strerror(reply), *the_delay);
ignore = snd_pcm_recover(alsa_handle, reply, 1);
snd_pcm_recover(alsa_handle, reply, 1);
}
} else if (snd_pcm_state(alsa_handle) == SND_PCM_STATE_PREPARED) {
*the_delay = 0;
@@ -820,7 +824,7 @@ int delay(long *the_delay) {
debug(1, "Error -- ALSA delay(): bad state: %d.", snd_pcm_state(alsa_handle));
}
if ((derr = snd_pcm_prepare(alsa_handle))) {
ignore = snd_pcm_recover(alsa_handle, derr, 1);
snd_pcm_recover(alsa_handle, derr, 1);
debug(1, "Error preparing after delay error: \"%s\".", snd_strerror(derr));
}
}
@@ -848,11 +852,11 @@ static void play(short buf[], int samples) {
}
if (ret == 0) {
pthread_mutex_lock(&alsa_mutex);
snd_pcm_sframes_t current_delay = 0;
int err, ignore;
// snd_pcm_sframes_t current_delay = 0;
int err;
if (snd_pcm_state(alsa_handle) == SND_PCM_STATE_XRUN) {
if ((err = snd_pcm_prepare(alsa_handle))) {
ignore = snd_pcm_recover(alsa_handle, err, 1);
snd_pcm_recover(alsa_handle, err, 1);
debug(1, "Error preparing after underrun: \"%s\".", snd_strerror(err));
}
}
@@ -867,14 +871,14 @@ static void play(short buf[], int samples) {
if (err < 0) {
debug(1, "Error %d writing %d samples in play(): \"%s\".", err, samples,
snd_strerror(err));
ignore = snd_pcm_recover(alsa_handle, err, 1);
snd_pcm_recover(alsa_handle, err, 1);
}
}
} else {
debug(1, "Error -- ALSA device in incorrect state (%d) for play.",
snd_pcm_state(alsa_handle));
if ((err = snd_pcm_prepare(alsa_handle))) {
ignore = snd_pcm_recover(alsa_handle, err, 1);
snd_pcm_recover(alsa_handle, err, 1);
debug(1, "Error preparing after play error: \"%s\".", snd_strerror(err));
}
}
+2
View File
@@ -45,11 +45,13 @@
static pthread_mutex_t buffer_mutex = PTHREAD_MUTEX_INITIALIZER;
/*
static struct {
char *server;
char *sink;
char *service_name;
} pulse_options = {.server = NULL, .sink = NULL, .service_name = NULL};
*/
pa_threaded_mainloop *mainloop;
pa_mainloop_api *mainloop_api;
+3 -3
View File
@@ -82,9 +82,9 @@ static void stop(void) {
static int init(int argc, char **argv) {
debug(1, "pipe init");
const char *str;
int value;
double dvalue;
// const char *str;
// int value;
// double dvalue;
// set up default values first
+1 -1
View File
@@ -969,7 +969,7 @@ uint64_t ranarray64u() { return (ranarrayval()); }
int64_t ranarray64i() { return (ranarrayval() >> 1); }
uint32_t nctohl(const char * p) { // read 4 characters from the p and do ntohl on them
uint32_t nctohl(const uint8_t * p) { // read 4 characters from the p and do ntohl on them
// this is to avoid possible aliasing violations
uint32_t holder;
memcpy(&holder,p,sizeof(holder));
+1 -1
View File
@@ -178,7 +178,7 @@ typedef struct {
} shairport_cfg;
uint32_t nctohl(const char * p); // read 4 characters from the p and do ntohl on them
uint32_t nctohl(const uint8_t * p); // read 4 characters from the p and do ntohl on them
// true if Shairport Sync is supposed to be sending output to the output device, false otherwise
+7 -6
View File
@@ -616,7 +616,7 @@ uint32_t dacp_tlv_crawl(char **p, int32_t *length) {
}
int dacp_get_client_volume(int32_t *result) {
debug(1,"dacp_get_client_volume");
// debug(1,"dacp_get_client_volume");
char *server_reply = NULL;
int32_t overall_volume = -1;
ssize_t reply_size;
@@ -650,7 +650,7 @@ int dacp_get_client_volume(int32_t *result) {
} */
if (result) {
*result=overall_volume;
debug(1,"dacp_get_client_volume returns: %" PRId32 ".",overall_volume);
// debug(1,"dacp_get_client_volume returns: %" PRId32 ".",overall_volume);
}
return response;
}
@@ -796,7 +796,7 @@ int dacp_get_volume(int32_t *the_actual_volume) {
int32_t actual_volume = 0;
int http_response = dacp_get_client_volume(&overall_volume);
if (http_response==200) {
debug(1,"Overall volume is: %u.",overall_volume);
// debug(1,"Overall volume is: %u.",overall_volume);
int speaker_count = 0;
http_response = dacp_get_speaker_list((dacp_spkr_stuff *)&speaker_info, 50,&speaker_count);
if (http_response==200) {
@@ -813,17 +813,18 @@ int dacp_get_volume(int32_t *the_actual_volume) {
for (i = 0; i < speaker_count; i++) {
if (speaker_info[i].speaker_number == machine_number) {
relative_volume = speaker_info[i].volume;
/*
debug(1,"Our speaker was found with a relative volume of: %u.",relative_volume);
if (speaker_info[i].active)
debug(1,"Our speaker is active.");
else
debug(1,"Our speaker is inactive.");
*/
}
}
actual_volume = (overall_volume * relative_volume + 50) / 100;
debug(1,"Overall volume: %d, relative volume: %d%, actual volume: %d.",overall_volume,relative_volume,actual_volume);
// debug(1,"Overall volume: %d, relative volume: %d%, actual volume: %d.",overall_volume,relative_volume,actual_volume);
// debug(1,"Our actual speaker volume is %d.",actual_volume);
//metadata_hub_modify_prolog();
//metadata_store.speaker_volume = actual_volume;
@@ -835,7 +836,7 @@ int dacp_get_volume(int32_t *the_actual_volume) {
debug(1,"Unexpected return code %d from dacp_get_client_volume.",http_response);
}
if (the_actual_volume) {
debug(1,"dacp_get_volume returns %d.",actual_volume);
// debug(1,"dacp_get_volume returns %d.",actual_volume);
*the_actual_volume = actual_volume;
}
return http_response;
+3 -3
View File
@@ -1,7 +1,7 @@
/*
* Embedded Avahi client. This file is part of Shairport.
* Copyright (c) James Laird 2013
* Additions for metadata and for detecting IPv6 Copyright (c) Mike Brady 2015
* Additions for metadata and for detecting IPv6 Copyright (c) Mike Brady 2015--2018
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
@@ -71,7 +71,7 @@ static void resolve_callback(AvahiServiceResolver *r, AVAHI_GCC_UNUSED AvahiIfIn
assert(r);
rtsp_conn_info *conn = (rtsp_conn_info *)userdata;
dacp_browser_struct *dbs = (dacp_browser_struct *)conn->mdns_private_pointer;
// dacp_browser_struct *dbs = (dacp_browser_struct *)conn->mdns_private_pointer;
/* Called whenever a service has been resolved successfully or timed out */
switch (event) {
@@ -80,7 +80,7 @@ static void resolve_callback(AvahiServiceResolver *r, AVAHI_GCC_UNUSED AvahiIfIn
type, domain, avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r))));
break;
case AVAHI_RESOLVER_FOUND: {
char a[AVAHI_ADDRESS_STR_MAX], *t;
// char a[AVAHI_ADDRESS_STR_MAX], *t;
// debug(1, "Resolve callback: Service '%s' of type '%s' in domain '%s':", name, type, domain);
char *dacpid = strstr(name, "iTunes_Ctrl_");
if (dacpid) {
+2 -1
View File
@@ -63,7 +63,8 @@ static int fork_execvp(const char *file, char *const argv[]) {
// If we reach this point then execve has failed.
// Write erno's value into the pipe and exit.
int ignore = write(execpipe[1], &errno, sizeof(errno));
if(write(execpipe[1], &errno, sizeof(errno)) != sizeof(errno))
debug(1,"Execve has failed and there was a further error writing an error message, duh.");
debug(1, "execve has failed.");
_exit(-1);
return 0; // Just to make the compiler happy.
+4 -2
View File
@@ -441,10 +441,12 @@ void metadata_hub_process_metadata(uint32_t type, uint32_t code, char *data, uin
default: {
char typestring[5];
*(uint32_t *)typestring = htonl(type);
uint32_t tm = htonl(type);
memcpy(typestring,&tm,sizeof(uint32_t));
typestring[4] = 0;
char codestring[5];
*(uint32_t *)codestring = htonl(code);
uint32_t cm = htonl(code);
memcpy(codestring,&cm,sizeof(uint32_t));
codestring[4] = 0;
char *payload;
if (length < 2048)
+15 -15
View File
@@ -218,8 +218,8 @@ static inline int seq_order(seq_t a, seq_t b, seq_t base) {
}
static inline seq_t seq_sum(seq_t a, seq_t b) {
uint32_t p = a & 0xffff;
uint32_t q = b & 0x0ffff;
// uint32_t p = a & 0xffff;
// uint32_t q = b & 0x0ffff;
uint32_t r = (a + b) & 0xffff;
return r;
}
@@ -254,7 +254,7 @@ static int alac_decode(short *dest, int *destlen, uint8_t *buf, int len, rtsp_co
return -1;
}
unsigned char packet[MAX_PACKET];
unsigned char packetp[MAX_PACKET];
// unsigned char packetp[MAX_PACKET];
assert(len <= MAX_PACKET);
int reply = 0; // everything okay
int outsize = conn->input_bytes_per_frame * (*destlen); // the size the output should be, in bytes
@@ -578,7 +578,7 @@ int32_t rand_in_range(int32_t exclusive_range_limit) {
static inline void process_sample(int32_t sample, char **outp, enum sps_format_t format, int volume,
int dither, rtsp_conn_info *conn) {
int64_t hyper_sample = sample;
int result;
int result = 0;
if (config.loudness) {
hyper_sample <<=
@@ -606,7 +606,7 @@ static inline void process_sample(int32_t sample, char **outp, enum sps_format_t
// http://www.ece.rochester.edu/courses/ECE472/resources/Papers/Lipshitz_1992.pdf
// by Lipshitz, Wannamaker and Vanderkooy, 1992.
int64_t dither_mask;
int64_t dither_mask = 0;
switch (format) {
case SPS_FORMAT_S32:
dither_mask = (int64_t)1 << (64 + 1 - 32);
@@ -708,7 +708,7 @@ static inline void process_sample(int32_t sample, char **outp, enum sps_format_t
// get the next frame, when available. return 0 if underrun/stream reset.
static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
int16_t buf_fill;
// int16_t buf_fill;
uint64_t local_time_now;
// struct timespec tn;
abuf_t *abuf = 0;
@@ -811,7 +811,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
notified_buffer_empty = 0; // at least one buffer now -- diagnostic only.
if (conn->ab_buffering) { // if we are getting packets but not yet forwarding them to the
// player
int have_sent_prefiller_silence; // set true when we have sent some silent frames to the
int have_sent_prefiller_silence = 0; // set true when we have sent some silent frames to the
// DAC
int64_t reference_timestamp;
uint64_t reference_timestamp_time, remote_reference_timestamp_time;
@@ -1163,7 +1163,7 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
return 0;
}
seq_t read = conn->ab_read;
// seq_t read = conn->ab_read;
// check if t+8, t+16, t+32, t+64, t+128, ... (buffer_start_fill / 2)
// packets have arrived... last-chance resend
@@ -1502,7 +1502,7 @@ static void *player_thread_func(void *arg) {
conn->buffer_occupancy = 0;
int play_samples;
int play_samples = 0;
int64_t current_delay;
int play_number = 0;
conn->play_number_after_flush = 0;
@@ -1689,9 +1689,9 @@ static void *player_thread_func(void *arg) {
case 16: {
int i, j;
int16_t ls, rs;
int32_t ll, rl;
int32_t ll = 0, rl = 0;
int16_t *inps = inbuf;
int16_t *outps = tbuf;
// int16_t *outps = tbuf;
int32_t *outpl = (int32_t *)tbuf;
for (i = 0; i < inbuflength; i++) {
ls = *inps++;
@@ -1983,7 +1983,7 @@ static void *player_thread_func(void *arg) {
// Volume must be applied here because the loudness filter will increase the
// signal level and it would saturate the int32_t otherwise
float gain = conn->fix_volume / 65536.0f;
float gain_db = 20 * log10(gain);
// float gain_db = 20 * log10(gain);
// debug(1, "Applying soft volume dB: %f k: %f", gain_db, gain);
for (i = 0; i < inbuflength; ++i) {
@@ -2134,7 +2134,7 @@ static void *player_thread_func(void *arg) {
double moving_average_correction = (1.0 * tsum_of_corrections) / number_of_statistics;
double moving_average_insertions_plus_deletions =
(1.0 * tsum_of_insertions_and_deletions) / number_of_statistics;
double moving_average_drift = (1.0 * tsum_of_drifts) / number_of_statistics;
// double moving_average_drift = (1.0 * tsum_of_drifts) / number_of_statistics;
// if ((play_number/print_interval)%20==0)
if (config.statistics_requested) {
if (at_least_one_frame_seen) {
@@ -2307,7 +2307,7 @@ void player_volume_without_notification(double airplay_volume, rtsp_conn_info *c
// Thus, we ask our vol2attn function for an appropriate dB between -96.3 and 0 dB and translate
// it back to a number.
int32_t hw_min_db, hw_max_db, hw_range_db, range_to_use, min_db,
int32_t hw_min_db, hw_max_db, hw_range_db, min_db,
max_db; // hw_range_db is a flag; if 0 means no mixer
if (config.output->parameters) {
@@ -2410,7 +2410,7 @@ void player_volume_without_notification(double airplay_volume, rtsp_conn_info *c
}
}
*/
double hardware_attenuation, software_attenuation;
double hardware_attenuation, software_attenuation = 0.0;
double scaled_attenuation = hw_min_db + sw_min_db;
// now, we can map the input to the desired output volume
+41 -36
View File
@@ -183,8 +183,8 @@ void *rtp_control_receiver(void *arg) {
conn->reference_timestamp = 0; // nothing valid received yet
uint8_t packet[2048], *pktp;
struct timespec tn;
uint64_t remote_time_of_sync, local_time_now, remote_time_now;
// struct timespec tn;
uint64_t remote_time_of_sync;
int64_t sync_rtp_timestamp;
ssize_t nread;
while (conn->please_stop == 0) {
@@ -199,7 +199,7 @@ void *rtp_control_receiver(void *arg) {
break;
}
nread = recv(conn->control_socket, packet, sizeof(packet), 0);
local_time_now = get_absolute_time_in_fp();
// local_time_now = get_absolute_time_in_fp();
// clock_gettime(CLOCK_MONOTONIC,&tn);
// local_time_now=((uint64_t)tn.tv_sec<<32)+((uint64_t)tn.tv_nsec<<32)/1000000000;
@@ -396,22 +396,21 @@ void *rtp_timing_receiver(void *arg) {
// we inherit the signal mask (SIGUSR1)
rtsp_conn_info *conn = (rtsp_conn_info *)arg;
uint8_t packet[2048], *pktp;
uint8_t packet[2048];
ssize_t nread;
conn->timing_sender_stop = 0;
pthread_t timer_requester;
pthread_create(&timer_requester, NULL, &rtp_timing_sender, arg);
// struct timespec att;
uint64_t distant_receive_time, distant_transmit_time, arrival_time, return_time, transit_time,
processing_time;
uint64_t distant_receive_time, distant_transmit_time, arrival_time, return_time;
local_to_remote_time_jitters = 0;
local_to_remote_time_jitters_count = 0;
uint64_t first_remote_time = 0;
// uint64_t first_remote_time = 0;
uint64_t first_local_time = 0;
uint64_t first_local_to_remote_time_difference = 0;
uint64_t first_local_to_remote_time_difference_time;
uint64_t l2rtd = 0;
// uint64_t first_local_to_remote_time_difference_time;
// uint64_t l2rtd = 0;
while (conn->please_stop == 0) {
fd_set readfds;
FD_ZERO(&readfds);
@@ -430,7 +429,7 @@ void *rtp_timing_receiver(void *arg) {
if (nread < 0)
break;
ssize_t plen = nread;
// ssize_t plen = nread;
// debug(1,"Packet Received on Timing Port.");
if (packet[1] == 0xd3) { // timing reply
/*
@@ -469,14 +468,14 @@ void *rtp_timing_receiver(void *arg) {
distant_transmit_time = (uint64_t)nctohl(&packet[24]) << 32;
distant_transmit_time += nctohl(&packet[28]);
processing_time = distant_transmit_time - distant_receive_time;
// processing_time = distant_transmit_time - distant_receive_time;
// debug(1,"Return trip time: %lluuS, remote processing time:
// %lluuS.",(return_time*1000000)>>32,(processing_time*1000000)>>32);
uint64_t local_time_by_remote_clock = distant_transmit_time + return_time / 2;
unsigned int cc, chosen;
unsigned int cc;
for (cc = time_ping_history - 1; cc > 0; cc--) {
conn->time_pings[cc] = conn->time_pings[cc - 1];
conn->time_pings[cc].dispersion =
@@ -494,30 +493,30 @@ void *rtp_timing_receiver(void *arg) {
uint64_t local_time_chosen = arrival_time;
;
uint64_t remote_time_chosen = distant_transmit_time;
// uint64_t remote_time_chosen = distant_transmit_time;
// now pick the timestamp with the lowest dispersion
uint64_t l2rtd = conn->time_pings[0].local_to_remote_difference;
uint64_t tld = conn->time_pings[0].dispersion;
chosen = 0;
// chosen = 0;
for (cc = 1; cc < conn->time_ping_count; cc++)
if (conn->time_pings[cc].dispersion < tld) {
l2rtd = conn->time_pings[cc].local_to_remote_difference;
chosen = cc;
// chosen = cc;
tld = conn->time_pings[cc].dispersion;
local_time_chosen = conn->time_pings[cc].local_time;
remote_time_chosen = conn->time_pings[cc].remote_time;
// remote_time_chosen = conn->time_pings[cc].remote_time;
}
int64_t ji;
// int64_t ji;
if (conn->time_ping_count > 1) {
if (l2rtd > conn->local_to_remote_time_difference) {
local_to_remote_time_jitters =
local_to_remote_time_jitters + l2rtd - conn->local_to_remote_time_difference;
ji = l2rtd - conn->local_to_remote_time_difference;
// ji = l2rtd - conn->local_to_remote_time_difference;
} else {
local_to_remote_time_jitters =
local_to_remote_time_jitters + conn->local_to_remote_time_difference - l2rtd;
ji = -(conn->local_to_remote_time_difference - l2rtd);
// ji = -(conn->local_to_remote_time_difference - l2rtd);
}
local_to_remote_time_jitters_count += 1;
}
@@ -529,28 +528,34 @@ void *rtp_timing_receiver(void *arg) {
conn->local_to_remote_time_difference = l2rtd;
if (first_local_to_remote_time_difference == 0) {
first_local_to_remote_time_difference = conn->local_to_remote_time_difference;
first_local_to_remote_time_difference_time = get_absolute_time_in_fp();
// first_local_to_remote_time_difference_time = get_absolute_time_in_fp();
}
int64_t clock_drift, clock_drift_in_usec;
double clock_drift_ppm = 0.0;
// int64_t clock_drift;
// int64_t clock_drift_in_usec;
// double clock_drift_ppm = 0.0;
if (first_local_time == 0) {
first_local_time = local_time_chosen;
first_remote_time = remote_time_chosen;
clock_drift = 0;
// first_remote_time = remote_time_chosen;
// clock_drift = 0;
} else {
uint64_t local_time_change = local_time_chosen - first_local_time;
uint64_t remote_time_change = remote_time_chosen - first_remote_time;
// uint64_t local_time_change = local_time_chosen - first_local_time;
// uint64_t remote_time_change = remote_time_chosen - first_remote_time;
/*
if (remote_time_change >= local_time_change)
clock_drift = remote_time_change - local_time_change;
else
clock_drift = -(local_time_change - remote_time_change);
*/
/*
if (clock_drift >= 0)
clock_drift_in_usec = (clock_drift * 1000000) >> 32;
else
clock_drift_in_usec = -(((-clock_drift) * 1000000) >> 32);
clock_drift_ppm = (1.0 * clock_drift_in_usec) / (local_time_change >> 32);
*/
// clock_drift_ppm = (1.0 * clock_drift_in_usec) / (local_time_change >> 32);
}
int64_t source_drift_usec;
@@ -697,10 +702,10 @@ void rtp_setup(SOCKADDR *local, SOCKADDR *remote, int cport, int tport, int *lsp
debug(2, "rtp_setup: cport=%d tport=%d.", cport, tport);
// print out what we know about the client
void *client_addr, *self_addr;
int client_port, self_port;
char client_port_str[64];
char self_addr_str[64];
void *client_addr = NULL, *self_addr = NULL;
// int client_port, self_port;
// char client_port_str[64];
// char self_addr_str[64];
conn->connection_ip_family =
remote->SAFAMILY; // keep information about the kind of ip of the client
@@ -709,20 +714,20 @@ void rtp_setup(SOCKADDR *local, SOCKADDR *remote, int cport, int tport, int *lsp
if (conn->connection_ip_family == AF_INET6) {
struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)remote;
client_addr = &(sa6->sin6_addr);
client_port = ntohs(sa6->sin6_port);
// client_port = ntohs(sa6->sin6_port);
sa6 = (struct sockaddr_in6 *)local;
self_addr = &(sa6->sin6_addr);
self_port = ntohs(sa6->sin6_port);
// self_port = ntohs(sa6->sin6_port);
conn->self_scope_id = sa6->sin6_scope_id;
}
#endif
if (conn->connection_ip_family == AF_INET) {
struct sockaddr_in *sa4 = (struct sockaddr_in *)remote;
client_addr = &(sa4->sin_addr);
client_port = ntohs(sa4->sin_port);
// client_port = ntohs(sa4->sin_port);
sa4 = (struct sockaddr_in *)local;
self_addr = &(sa4->sin_addr);
self_port = ntohs(sa4->sin_port);
// self_port = ntohs(sa4->sin_port);
}
inet_ntop(conn->connection_ip_family, client_addr, conn->client_ip_string,
+20 -6
View File
@@ -376,6 +376,7 @@ static void debug_print_msg_headers(int level, rtsp_message *msg) {
}
}
/*
static void debug_print_msg_content(int level, rtsp_message *msg) {
if (msg->contentlength) {
char *obf = malloc(msg->contentlength * 2 + 1);
@@ -396,6 +397,7 @@ static void debug_print_msg_content(int level, rtsp_message *msg) {
debug(level, "No content");
}
}
*/
static void msg_free(rtsp_message *msg) {
@@ -432,6 +434,7 @@ static int msg_handle_line(rtsp_message **pmsg, char *line) {
msg = msg_init();
*pmsg = msg;
char *sp, *p;
sp = NULL; // this is to quieten a compiler warning
// debug(1, "received request: %s", line);
@@ -653,15 +656,18 @@ static void msg_write_response(int fd, rtsp_message *resp) {
die("Attempted to write overlong RTSP packet");
}
int ignore = write(fd, pkt, p - pkt);
if (write(fd, pkt, p - pkt) != p - pkt)
debug(1,"Error writing an RTSP packet -- requested bytes not fully written.");
// Here, if there's content, write it
if (resp->contentlength) {
debug(1, "Content is \"%s\"", resp->content);
ignore = write(fd, resp->content, resp->contentlength);
if (write(fd, resp->content, resp->contentlength) != resp->contentlength)
debug(1,"Error writing RTSP content -- requested bytes not fully written.");
}
ignore = write(fd, "\r\n", strlen("\r\n"));
if (write(fd, "\r\n", strlen("\r\n")) != strlen("\r\n"))
debug(1,"Error terminating RTSP content.");
}
static void handle_record(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) {
@@ -843,10 +849,12 @@ error:
resp->respcode = 451; // invalid arguments
}
/*
static void handle_ignore(rtsp_conn_info *conn, rtsp_message *req, rtsp_message *resp) {
debug(1, "Connection thread %d: IGNORE", conn->connection_number);
resp->respcode = 200;
}
*/
static void handle_set_parameter_parameter(rtsp_conn_info *conn, rtsp_message *req,
rtsp_message *resp) {
@@ -1009,7 +1017,7 @@ char *base64_encode_so(const unsigned char *data, size_t input_length, char *enc
//
static int fd = -1;
static int dirty = 0;
// static int dirty = 0;
pc_queue metadata_queue;
static int metadata_sock = -1;
static struct sockaddr_in metadata_sockaddr;
@@ -1077,10 +1085,12 @@ void metadata_open(void) {
free(path);
}
/*
static void metadata_close(void) {
close(fd);
fd = -1;
}
*/
void metadata_process(uint32_t type, uint32_t code, char *data, uint32_t length) {
// debug(2, "Process metadata with type %x, code %x and length %u.", type, code, length);
@@ -1167,7 +1177,7 @@ void metadata_process(uint32_t type, uint32_t code, char *data, uint32_t length)
// thus, we send groups of (76/4)*3 = 57 bytes to the encoder at a time
size_t remaining_count = length;
char *remaining_data = data;
size_t towrite_count;
// size_t towrite_count;
char outbuf[76];
while ((remaining_count) && (ret >= 0)) {
size_t towrite_count = remaining_count;
@@ -1669,7 +1679,9 @@ static char *make_nonce(void) {
int fd = open("/dev/random", O_RDONLY);
if (fd < 0)
die("could not open /dev/random!");
int ignore = read(fd, random, sizeof(random));
// int ignore =
if (read(fd, random, sizeof(random)) != sizeof(random))
debug(1,"Error reading /dev/random");
close(fd);
return base64_enc(random, 8);
}
@@ -1934,6 +1946,7 @@ static void *rtsp_conversation_thread_func(void *pconn) {
return NULL;
}
/*
// this function is not thread safe.
static const char *format_address(struct sockaddr *fsa) {
static char string[INETx_ADDRSTRLEN];
@@ -1950,6 +1963,7 @@ static const char *format_address(struct sockaddr *fsa) {
}
return inet_ntop(fsa->sa_family, addr, string, sizeof(string));
}
*/
void rtsp_listen_loop(void) {
struct addrinfo hints, *info, *p;