Remove extra returns and generally clean up some debug messages.

This commit is contained in:
Mike Brady
2014-05-19 19:12:13 +01:00
parent 0b07f99f9e
commit 1a0932d92a
6 changed files with 107 additions and 107 deletions
+21 -21
View File
@@ -156,16 +156,16 @@ static int init(int argc, char **argv) {
if (alsa_mix_mindb==-9999999) {
// trying to say that the lowest vol is mute, maybe? Raspberry Pi does this
if (snd_mixer_selem_ask_playback_vol_dB(alsa_mix_elem,alsa_mix_minv+1,&alsa_mix_mindb)==0)
debug(1,"Can't get dB value corresponding to a \"volume\" of 1.\n");
debug(1,"Can't get dB value corresponding to a \"volume\" of 1.");
}
debug(1,"Hardware mixer has dB volume from %f to %f.\n",(1.0*alsa_mix_mindb)/100.0,(1.0*alsa_mix_maxdb)/100.0);
debug(1,"Hardware mixer has dB volume from %f to %f.",(1.0*alsa_mix_mindb)/100.0,(1.0*alsa_mix_maxdb)/100.0);
} else {
debug(1,"Hardware mixer does not have dB volume -- not used.\n");
debug(1,"Hardware mixer does not have dB volume -- not used.");
}
}
if (snd_mixer_selem_has_playback_switch(alsa_mix_elem)) {
has_mute=1;
debug(1,"Has mute ability.\n");
debug(1,"Has mute ability.");
}
return 0;
}
@@ -187,7 +187,7 @@ static void start(int sample_rate) {
snd_pcm_uframes_t buffer_size = frames*4;
ret = snd_pcm_open(&alsa_handle, alsa_out_dev, SND_PCM_STREAM_PLAYBACK, 0);
if (ret < 0)
die("Alsa initialization failed: unable to open pcm device: %s\n", snd_strerror(ret));
die("Alsa initialization failed: unable to open pcm device: %s.", snd_strerror(ret));
snd_pcm_hw_params_alloca(&alsa_params);
snd_pcm_hw_params_any(alsa_handle, alsa_params);
@@ -199,7 +199,7 @@ static void start(int sample_rate) {
// snd_pcm_hw_params_set_buffer_size_near(alsa_handle, alsa_params, &buffer_size);
ret = snd_pcm_hw_params(alsa_handle, alsa_params);
if (ret < 0)
die("unable to set hw parameters: %s\n", snd_strerror(ret));
die("unable to set hw parameters: %s.", snd_strerror(ret));
if (mysamplerate!=sample_rate) {
die("Can't set the D/A converter to %d -- set to %d instead./n",sample_rate,mysamplerate);
}
@@ -212,17 +212,17 @@ static uint32_t delay() {
if (derr = snd_pcm_delay(alsa_handle,&current_delay)) {
if (derr != 0) {
derr = snd_pcm_recover(alsa_handle, derr, 0);
debug(1,"Error in delay(): %s\n", snd_strerror(derr));
debug(1,"Error in delay(): %s.", snd_strerror(derr));
}
current_delay=-1;
}
} else if (snd_pcm_state(alsa_handle)==SND_PCM_STATE_PREPARED) {
current_delay=0;
} else {
debug(1,"Error -- ALSA device not in correct state (%d) for delay.\n",snd_pcm_state(alsa_handle));
debug(1,"Error -- ALSA device not in correct state (%d) for delay.",snd_pcm_state(alsa_handle));
if (derr = snd_pcm_prepare(alsa_handle)) {
derr = snd_pcm_recover(alsa_handle, derr, 0);
debug(1,"Error preparing after delay error: %s\n", snd_strerror(derr));
debug(1,"Error preparing after delay error: %s.", snd_strerror(derr));
}
current_delay = -1;
}
@@ -236,13 +236,13 @@ static void play(short buf[], int samples) {
err = snd_pcm_writei(alsa_handle, (char*)buf, samples);
if (err < 0) {
err = snd_pcm_recover(alsa_handle, err, 0);
debug(1,"Error writing in play(): %s\n", snd_strerror(err));
debug(1,"Error writing in play(): %s.", snd_strerror(err));
}
} else {
debug(1,"Error -- ALSA device not in correct state (%d) for play.\n",snd_pcm_state(alsa_handle));
debug(1,"Error -- ALSA device not in correct state (%d) for play.",snd_pcm_state(alsa_handle));
if (err = snd_pcm_prepare(alsa_handle)) {
err = snd_pcm_recover(alsa_handle, err, 0);
debug(1,"Error preparing after play error: %s\n", snd_strerror(err));
debug(1,"Error preparing after play error: %s.", snd_strerror(err));
}
}
}
@@ -250,21 +250,21 @@ static void play(short buf[], int samples) {
static void flush(void) {
int derr;
if (alsa_handle) {
// debug(1,"Dropping frames for flush...\n");
// debug(1,"Dropping frames for flush...");
if (derr = snd_pcm_drop(alsa_handle))
debug(1,"Error dropping frames: %s\n", snd_strerror(derr));
// debug(1,"Dropped frames ok. State is %d.\n",snd_pcm_state(alsa_handle));
debug(1,"Error dropping frames: %s.", snd_strerror(derr));
// debug(1,"Dropped frames ok. State is %d.",snd_pcm_state(alsa_handle));
if (derr = snd_pcm_prepare(alsa_handle))
debug(1,"Error preparing after flush: %s\n", snd_strerror(derr));
// debug(1,"Frames successfully dropped.\n");
debug(1,"Error preparing after flush: %s.", snd_strerror(derr));
// debug(1,"Frames successfully dropped.");
/*
if (snd_pcm_state(alsa_handle)==SND_PCM_STATE_PREPARED)
debug(1,"Flush returns to SND_PCM_STATE_PREPARED state.\n");
debug(1,"Flush returns to SND_PCM_STATE_PREPARED state.");
if (snd_pcm_state(alsa_handle)==SND_PCM_STATE_RUNNING)
debug(1,"Flush returns to SND_PCM_STATE_RUNNING state.\n");
debug(1,"Flush returns to SND_PCM_STATE_RUNNING state.");
*/
if (!((snd_pcm_state(alsa_handle)==SND_PCM_STATE_PREPARED) || (snd_pcm_state(alsa_handle)==SND_PCM_STATE_RUNNING)))
debug(1,"Flush returning unexpected state -- %d.\n",snd_pcm_state(alsa_handle));
debug(1,"Flush returning unexpected state -- %d.",snd_pcm_state(alsa_handle));
}
}
@@ -278,7 +278,7 @@ static void stop(void) {
static void volume(double vol) {
double vol_setting = vol2attn(vol,alsa_mix_maxdb,alsa_mix_mindb);
debug(1,"Setting volume db to %f, for volume input of %f.\n",vol_setting,vol);
debug(1,"Setting volume db to %f, for volume input of %f.",vol_setting,vol);
if (snd_mixer_selem_set_playback_dB_all(alsa_mix_elem, vol_setting, -1) != 0)
die ("Failed to set playback dB volume");
if (has_mute)
+4 -4
View File
@@ -200,7 +200,7 @@ double vol2attn(double vol, long max_db, long min_db) {
if ((vol<=0.0) && (vol>=-30.0)) {
long range_db = max_db-min_db; // this will be a positive nunmber
// debug(1,"Volume min %ddB, max %ddB, range %ddB.\n",min_db,max_db,range_db);
// debug(1,"Volume min %ddB, max %ddB, range %ddB.",min_db,max_db,range_db);
double first_slope = -2500.0; // this is the slope of the attenuation at the high end -- 25dB for the full rotation.
if (-range_db>first_slope)
first_slope = range_db;
@@ -209,18 +209,18 @@ double vol2attn(double vol, long max_db, long min_db) {
for (i=0;i<order;i++) {
if (vol<=lines[i][0]) {
double tvol = lines[i][1]*(vol-lines[i][0])/(-30-lines[i][0]);
// debug(1,"On line %d, end point of %f, input vol %f yields output vol %f.\n",i,lines[i][1],vol,tvol);
// debug(1,"On line %d, end point of %f, input vol %f yields output vol %f.",i,lines[i][1],vol,tvol);
if (tvol<vol_setting)
vol_setting=tvol;
}
}
vol_setting+=max_db;
} else if (vol!=-144.0) {
debug(1,"Volume request value %f is out of range: should be from 0.0 to -30.0 or -144.0.\n",vol);
debug(1,"Volume request value %f is out of range: should be from 0.0 to -30.0 or -144.0.",vol);
} else {
vol_setting = min_db; // for safety, return the lowest setting...
}
// debug(1,"returning an attenuation of %f.\n",vol_setting);
// debug(1,"returning an attenuation of %f.",vol_setting);
return vol_setting;
}
+3 -3
View File
@@ -50,7 +50,7 @@ static void egroup_callback(AvahiEntryGroup *g,
}
static void register_service(AvahiClient *c) {
debug(1, "avahi: register_service\n");
debug(1, "avahi: register_service.");
if (!group)
group = avahi_entry_group_new(c, egroup_callback, NULL);
if (!group)
@@ -102,7 +102,7 @@ static void client_callback(AvahiClient *c,
}
static int avahi_register(char *srvname, int srvport) {
debug(1, "avahi: avahi_register\n");
debug(1, "avahi: avahi_register.");
name = strdup(srvname);
port = srvport;
@@ -129,7 +129,7 @@ static int avahi_register(char *srvname, int srvport) {
}
static void avahi_unregister(void) {
debug(1, "avahi: avahi_unregister\n");
debug(1, "avahi: avahi_unregister.");
if (tpoll)
avahi_threaded_poll_stop(tpoll);
tpoll = NULL;
+26 -26
View File
@@ -214,13 +214,13 @@ static void free_buffer(void) {
void player_put_packet(seq_t seqno,uint32_t timestamp, uint8_t *data, int len) {
packet_count++;
//if (packet_count<10)
// debug(1,"Packet %llu received.\n",packet_count);
// debug(1,"Packet %llu received.",packet_count);
abuf_t *abuf = 0;
int16_t buf_fill;
pthread_mutex_lock(&ab_mutex);
if (!ab_synced) {
debug(2, "syncing to first seqno %04X\n", seqno);
debug(2, "syncing to first seqno %04X.", seqno);
ab_write = seqno-1;
ab_read = seqno;
ab_synced = 1;
@@ -239,7 +239,7 @@ void player_put_packet(seq_t seqno,uint32_t timestamp, uint8_t *data, int len) {
} else { // too late.
too_late_packets++;
if (!late_packet_message_sent) {
debug(1, "late packet %04X (%04X:%04X).\n", seqno, ab_read, ab_write);
debug(1, "late packet %04X (%04X:%04X).", seqno, ab_read, ab_write);
late_packet_message_sent=1;
}
}
@@ -257,7 +257,7 @@ void player_put_packet(seq_t seqno,uint32_t timestamp, uint8_t *data, int len) {
int rc = pthread_cond_signal(&flowcontrol);
if (rc)
debug(1,"Error signalling flowcontrol.\n");
debug(1,"Error signalling flowcontrol.");
pthread_mutex_unlock(&ab_mutex);
}
@@ -312,17 +312,17 @@ static abuf_t *buffer_get_frame(void) {
if (curframe->ready) {
if ((flush_rtp_timestamp) && (flush_rtp_timestamp>=curframe->timestamp)) {
// debug(1,"Dropping flushed packet %u.\n",curframe->timestamp);
// debug(1,"Dropping flushed packet %u.",curframe->timestamp);
curframe->ready=0;
ab_read++;
} else if (ab_buffering) { // if we are getting packets but not yet forwarding them to the player
if (first_packet_timestamp==0) { // if this is the very first packet
// debug(1,"First frame seen, time %u, with %d frames...\n",curframe->timestamp,seq_diff(ab_read, ab_write));
// debug(1,"First frame seen, time %u, with %d frames...",curframe->timestamp,seq_diff(ab_read, ab_write));
uint32_t reference_timestamp;
uint64_t reference_timestamp_time;
get_reference_timestamp_stuff(&reference_timestamp,&reference_timestamp_time);
if (reference_timestamp) { // if we have a reference time
// debug(1,"First frame seen with timestamp...\n");
// debug(1,"First frame seen with timestamp...");
first_packet_timestamp=curframe->timestamp; // we will keep buffering until we are supposed to start playing this
// here, see if we should start playing. We need to know when to allow the packets to be sent to the player
@@ -338,7 +338,7 @@ static abuf_t *buffer_get_frame(void) {
first_packet_time_to_play = reference_timestamp_time+((delta+(int64_t)config.latency)<<32)/44100; // using the latency requested...
if (local_time_now>=first_packet_time_to_play)
debug(1,"First packet is late! It should have played before now...\n");
debug(1,"First packet is late! It should have played before now...");
}
}
@@ -355,7 +355,7 @@ static abuf_t *buffer_get_frame(void) {
uint64_t tn = ((uint64_t)time_now.tv_sec<<32)+((uint64_t)time_now.tv_nsec<<32)/1000000000;
if (tn>=first_packet_time_to_play) {
// we've gone past the time...
// debug(1,"Run past the exact start time by %llu frames, with time now of %llx, fpttp of %llx and dac_delay of %d and %d packets; flush.\n",(((tn-first_packet_time_to_play)*44100)>>32)+dac_delay,tn,first_packet_time_to_play,dac_delay,seq_diff(ab_read, ab_write));
// debug(1,"Run past the exact start time by %llu frames, with time now of %llx, fpttp of %llx and dac_delay of %d and %d packets; flush.",(((tn-first_packet_time_to_play)*44100)>>32)+dac_delay,tn,first_packet_time_to_play,dac_delay,seq_diff(ab_read, ab_write));
if (config.output->flush)
config.output->flush();
@@ -367,7 +367,7 @@ static abuf_t *buffer_get_frame(void) {
int64_t exact_frame_gap = gross_frame_gap-dac_delay;
if (exact_frame_gap<=0) {
// we've gone past the time...
// debug(1,"Run a bit past the exact start time by %lld frames, with time now of %llx, fpttp of %llx and dac_delay of %d and %d packets; flush.\n",-exact_frame_gap,tn,first_packet_time_to_play,dac_delay,seq_diff(ab_read, ab_write));
// debug(1,"Run a bit past the exact start time by %lld frames, with time now of %llx, fpttp of %llx and dac_delay of %d and %d packets; flush.",-exact_frame_gap,tn,first_packet_time_to_play,dac_delay,seq_diff(ab_read, ab_write));
if (config.output->flush)
config.output->flush();
ab_resync();
@@ -382,7 +382,7 @@ static abuf_t *buffer_get_frame(void) {
signed short *silence;
silence = malloc(FRAME_BYTES(fs));
memset(silence, 0, FRAME_BYTES(fs));
//debug(1,"Exact frame gap is %llu; play %d frames of silence. Dac_delay is %d, with %d packets.\n",exact_frame_gap,fs,dac_delay,seq_diff(ab_read, ab_write));
//debug(1,"Exact frame gap is %llu; play %d frames of silence. Dac_delay is %d, with %d packets.",exact_frame_gap,fs,dac_delay,seq_diff(ab_read, ab_write));
config.output->play(silence, fs);
free(silence);
}
@@ -413,14 +413,14 @@ static abuf_t *buffer_get_frame(void) {
// if (buf_fill < 1 || !ab_synced) {
// if (buf_fill < 1)
if (dac_delay==0) {// we just got underrun
debug(1,"Underrun!\n");
debug(1,"Underrun!");
ab_resync(); // starting over
}
}
if (please_stop) {
pthread_mutex_unlock(&ab_mutex);
debug(1,"Exiting from buffer_get_frame.\n");
debug(1,"Exiting from buffer_get_frame.");
return 0;
}
@@ -451,7 +451,7 @@ static abuf_t *buffer_get_frame(void) {
if (!curframe->ready) {
// debug(1, "missing frame %04X. Supplying a silent frame.\n", read);
// debug(1, "missing frame %04X. Supplying a silent frame.", read);
missing_packets++;
memset(curframe->data, 0, FRAME_BYTES(frame_size));
}
@@ -473,12 +473,12 @@ static int stuff_buffer(short *inptr, short *outptr, int32_t stuff) {
};
if (stuff) {
if (stuff==1) {
debug(3, "+++++++++\n");
debug(3, "+++++++++");
// interpolate one sample
*outptr++ = dithered_vol(((long)inptr[-2] + (long)inptr[0]) >> 1);
*outptr++ = dithered_vol(((long)inptr[-1] + (long)inptr[1]) >> 1);
} else if (stuff==-1) {
debug(3, "---------\n");
debug(3, "---------");
inptr++;
inptr++;
}
@@ -645,7 +645,7 @@ static void *player_thread_func(void *arg) {
int64_t td_in_frames;
int64_t td = local_time_now-reference_timestamp_time;
// debug(1,"td is %lld.\n",td);
// debug(1,"td is %lld.",td);
if (td>=0) {
td_in_frames = (td*44100)>>32;
} else {
@@ -656,7 +656,7 @@ static void *player_thread_func(void *arg) {
// if ((play_number<(10)) || (play_number%500==0))
// if ((play_number<(10)))
// debug(1,"Latency error for packet %d: %d frames.\n",play_number,delay-config.latency);
// debug(1,"Latency error for packet %d: %d frames.",play_number,delay-config.latency);
if (number_of_delays==averaging_interval) { // the array of delays is full
sum_of_delays-=delays[oldest_delay];
@@ -681,13 +681,13 @@ static void *player_thread_func(void *arg) {
current_latency=accumulated_delay/print_interval;
if ((play_number/print_interval)%100==0)
{ // only print every hundredth one, in verbose mode
//debug(1,"Valid frames: %lld; overall frames added/subtracted %lld; frames added + frames deleted %lld; average D/A delay, average latency (frames): %llu, %llu; average buffers in use: %llu, moving average delay (number of delays): %llu (%lu).\n",
//debug(1,"Valid frames: %lld; overall frames added/subtracted %lld; frames added + frames deleted %lld; average D/A delay, average latency (frames): %llu, %llu; average buffers in use: %llu, moving average delay (number of delays): %llu (%lu).",
// frames-(additions-deletions), additions-deletions, additions+deletions, accumulated_da_delay/print_interval,current_latency,accumulated_buffers_in_use/print_interval,moving_average_delay,number_of_delays);
//debug(1,"Frames %lld, correction %lld, mods %lld, dac_buffer %llu, latency %llu, missing_packets %llu, late_packets %llu, too_late_packets %llu resend_requests %llu.\n",
//debug(1,"Frames %lld, correction %lld, mods %lld, dac_buffer %llu, latency %llu, missing_packets %llu, late_packets %llu, too_late_packets %llu resend_requests %llu.",
//frames-(additions-deletions), additions-deletions, additions+deletions,accumulated_da_delay/print_interval,moving_average_delay,missing_packets,late_packets,too_late_packets,resend_requests);
debug(1,"Drift: %.1f (ppm); Corrections: %.1f (ppm); missing_packets %llu; late_packets %llu; too_late_packets %llu; resend_requests %llu.\n", -moving_average_correction*1000000/352, moving_average_insertions_and_deletions*1000000/352,missing_packets,late_packets,too_late_packets,resend_requests);
debug(1,"Drift: %.1f (ppm); Corrections: %.1f (ppm); missing_packets %llu; late_packets %llu; too_late_packets %llu; resend_requests %llu.", -moving_average_correction*1000000/352, moving_average_insertions_and_deletions*1000000/352,missing_packets,late_packets,too_late_packets,resend_requests);
}
if (previous_latency==0)
previous_latency=current_latency;
@@ -746,7 +746,7 @@ void player_flush(uint32_t timestamp) {
*/
int player_play(stream_cfg *stream) {
debug(1,"player_play called...\n");
debug(1,"player_play called...");
packet_count = 0;
if (config.buffer_start_fill > BUFFER_FRAMES)
die("specified buffer starting fill %d > buffer size %d",
@@ -773,7 +773,7 @@ int player_play(stream_cfg *stream) {
pthread_condattr_setclock( &attr, CLOCK_MONOTONIC);
int rc = pthread_cond_init(&flowcontrol,&attr);
if (rc)
debug(1,"Error initialising condition variable.\n");
debug(1,"Error initialising condition variable.");
config.output->start(sampling_rate);
pthread_create(&player_thread, NULL, player_thread_func, NULL);
@@ -781,7 +781,7 @@ int player_play(stream_cfg *stream) {
}
void player_stop(void) {
debug(1,"player_stop called...\n");
debug(1,"player_stop called...");
please_stop = 1;
pthread_cond_signal(&flowcontrol); // tell it to give up
pthread_join(player_thread, NULL);
@@ -798,6 +798,6 @@ void player_stop(void) {
#endif
int rc = pthread_cond_destroy(&flowcontrol);
if (rc)
debug(1,"Error destroying condition variable.\n");
debug(1,"player_stop finished...\n");
debug(1,"Error destroying condition variable.");
debug(1,"player_stop finished...");
}
+33 -33
View File
@@ -101,7 +101,7 @@ static void *rtp_audio_receiver(void *arg) {
uint32_t timestamp = ntohl(*(unsigned long *)(pktp+4));
//if (packet[1]&0x10)
// debug(1,"Audio packet Extension bit set.\n");
// debug(1,"Audio packet Extension bit set.");
pktp += 12;
plen -= 12;
@@ -112,15 +112,15 @@ static void *rtp_audio_receiver(void *arg) {
continue;
}
if (type == 0x56 && seqno == 0) {
debug(2, "resend-related request packet received, ignoring.\n");
debug(2, "resend-related request packet received, ignoring.");
continue;
}
debug(1, "Unknown RTP packet of type 0x%02X length %d seqno %d\n", type, nread, seqno);
debug(1, "Unknown RTP packet of type 0x%02X length %d seqno %d", type, nread, seqno);
}
warn("Unknown RTP packet of type 0x%02X length %d", type, nread);
warn("Unknown RTP packet of type 0x%02X length %d.", type, nread);
}
debug(1, "Server RTP thread interrupted. terminating.\n");
debug(1, "Server RTP thread interrupted. terminating.");
close(audio_socket);
return NULL;
@@ -155,14 +155,14 @@ static void *rtp_control_receiver(void *arg) {
obfp+=2;
};
*obfp=0;
debug(1,"Sync Packet Received: \"%s\"\n",obf);
debug(1,"Sync Packet Received: \"%s\"",obf);
*/
if (local_to_remote_time_difference) { // need a time packet to be interchanged first...
remote_time_of_sync = (uint64_t)ntohl(*((uint32_t*)&packet[8]))<<32;
remote_time_of_sync += ntohl(*((uint32_t*)&packet[12]));
// debug(1,"Remote Sync Time: %0llx.\n",remote_time_of_sync);
// debug(1,"Remote Sync Time: %0llx.",remote_time_of_sync);
rtp_timestamp_less_latency = ntohl(*((uint32_t*)&packet[4]));
sync_rtp_timestamp = ntohl(*((uint32_t*)&packet[16]));
@@ -179,16 +179,16 @@ static void *rtp_control_receiver(void *arg) {
// get estimated remote time now
remote_time_now = local_time_now+local_to_remote_time_difference;
//debug(1,"Sync Time is %lld us late (remote times).\n",((remote_time_now-remote_time_of_sync)*1000000)>>32);
//debug(1,"Sync Time is %lld us late (local times).\n",((local_time_now-reference_timestamp_time)*1000000)>>32);
//debug(1,"Sync Time is %lld us late (remote times).",((remote_time_now-remote_time_of_sync)*1000000)>>32);
//debug(1,"Sync Time is %lld us late (local times).",((local_time_now-reference_timestamp_time)*1000000)>>32);
} else {
debug(1,"Sync packet received before we got a timing packet back.\n");
debug(1,"Sync packet received before we got a timing packet back.");
}
} else
debug(1,"Control Port -- Unknown RTP packet of type 0x%02X length %d\n", packet[1], nread);
debug(1,"Control Port -- Unknown RTP packet of type 0x%02X length %d.", packet[1], nread);
}
debug(1, "Control RTP thread interrupted. terminating.\n");
debug(1, "Control RTP thread interrupted. terminating.");
close(control_socket);
return NULL;
@@ -205,7 +205,7 @@ static void *rtp_timing_sender(void *arg) {
uint64_t request_number=0;
debug(1, "Timing requester startup.\n");
debug(1, "Timing requester startup.");
struct timing_request req; // *not* a standard RTCP NACK
@@ -224,7 +224,7 @@ static void *rtp_timing_sender(void *arg) {
if (!running)
die("rtp_timing_sender called without active stream!");
//debug(1, "Requesting ntp timestamp exchange.\n");
//debug(1, "Requesting ntp timestamp exchange.");
req.filler = 0;
req.origin = req.receive = req.transmit=0;
@@ -237,7 +237,7 @@ static void *rtp_timing_sender(void *arg) {
else
sleep(3);
}
debug(1, "rtp_timing_sender thread interrupted. terminating.\n");
debug(1, "rtp_timing_sender thread interrupted. terminating.");
return NULL;
}
@@ -260,7 +260,7 @@ static void *rtp_timing_receiver(void *arg) {
break;
ssize_t plen = nread;
//debug(1,"Packet Received on Timing Port.\n");
//debug(1,"Packet Received on Timing Port.");
if (packet[1] == 0xd3) { // timing reply
/*
char obf[4096];
@@ -271,7 +271,7 @@ static void *rtp_timing_receiver(void *arg) {
obfp+=2;
};
*obfp=0;
//debug(1,"Timing Packet Received: \"%s\"\n",obf);
//debug(1,"Timing Packet Received: \"%s\"",obf);
*/
arrival_time = ((uint64_t)att.tv_sec<<32)+((uint64_t)att.tv_nsec<<32)/1000000000;
@@ -279,7 +279,7 @@ static void *rtp_timing_receiver(void *arg) {
return_time = arrival_time-departure_time;
// uint64_t rtus = (return_time*1000000)>>32; debug(1,"Time ping turnaround time: %lld us.\n",rtus);
// uint64_t rtus = (return_time*1000000)>>32; debug(1,"Time ping turnaround time: %lld us.",rtus);
//distant_receive_time = ((uint64_t)ntohl(*((uint32_t*)&packet[16])))<<32+ntohl(*((uint32_t*)&packet[20]));
@@ -293,7 +293,7 @@ static void *rtp_timing_receiver(void *arg) {
processing_time = distant_transmit_time-distant_receive_time;
// debug(1,"Return trip time: %lluuS, remote processing time: %lluuS\n",(return_time*1000000)>>32,(processing_time*1000000)>>32);
// 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;
@@ -315,20 +315,20 @@ static void *rtp_timing_receiver(void *arg) {
local_to_remote_time_difference=time_pings[cc].local_to_remote_difference;
tld=time_pings[cc].dispersion;
}
// rtus = (tld*1000000)>>32; debug(1,"Choosing time difference with dispersion of %lld us.\n",rtus);
// rtus = (tld*1000000)>>32; debug(1,"Choosing time difference with dispersion of %lld us.",rtus);
} else {
debug(1, "Unknown RTP packet of type 0x%02X length %d.\n", packet[1], nread);
debug(1, "Unknown RTP packet of type 0x%02X length %d.", packet[1], nread);
}
}
debug(1, "Timing RTP thread interrupted. terminating.\n");
debug(1, "Timing RTP thread interrupted. terminating.");
void *retval;
pthread_kill(timer_requester, SIGUSR1);
pthread_join(timer_requester, &retval);
debug(1,"Closed and terminated timer requester thread.\n");
debug(1, "Timing RTP thread terminated.\n");
debug(1,"Closed and terminated timer requester thread.");
debug(1, "Timing RTP thread terminated.");
close(timing_socket);
return NULL;
@@ -349,7 +349,7 @@ static int bind_port(SOCKADDR *remote,int *sock, int desired_port ) {
int ret = getaddrinfo(NULL,buffer, &hints, &info);
if (ret < 0)
die("failed to get usable addrinfo?! %s\n", gai_strerror(ret));
die("failed to get usable addrinfo?! %s.", gai_strerror(ret));
*sock = socket(remote->SAFAMILY, SOCK_DGRAM, IPPROTO_UDP);
ret = bind(*sock, info->ai_addr, info->ai_addrlen);
@@ -357,7 +357,7 @@ static int bind_port(SOCKADDR *remote,int *sock, int desired_port ) {
freeaddrinfo(info);
if (ret < 0)
die("could not bind a UDP port!\n");
die("could not bind a UDP port!");
int sport;
SOCKADDR local;
@@ -380,9 +380,9 @@ static int bind_port(SOCKADDR *remote,int *sock, int desired_port ) {
void rtp_setup(SOCKADDR *remote, int cport, int tport, int *lsport, int *lcport, int *ltport) {
if (running)
die("rtp_setup called with active stream!\n");
die("rtp_setup called with active stream!");
debug(2, "rtp_setup: cport=%d tport=%d\n", cport, tport);
debug(2, "rtp_setup: cport=%d tport=%d.", cport, tport);
// we do our own timing and ignore the timing port.
// an audio perfectionist may wish to learn the protocol.
@@ -421,7 +421,7 @@ void rtp_setup(SOCKADDR *remote, int cport, int tport, int *lsport, int *lcport,
*lcport = bind_port(remote,&control_socket,6001);
*ltport = bind_port(remote,&timing_socket,6002);
debug(2, "listening for audio, control and timing on ports %d, %d, %d\n", *lsport, *lcport, *ltport);
debug(2, "listening for audio, control and timing on ports %d, %d, %d.", *lsport, *lcport, *ltport);
please_shutdown = 0;
reference_timestamp=0;
@@ -449,9 +449,9 @@ void clear_reference_timestamp(void) {
void rtp_shutdown(void) {
if (!running)
die("rtp_shutdown called without active stream!\n");
die("rtp_shutdown called without active stream!");
debug(2, "shutting down RTP thread\n");
debug(2, "shutting down RTP thread");
please_shutdown = 1;
void *retval;
reference_timestamp=0;
@@ -467,7 +467,7 @@ void rtp_shutdown(void) {
void rtp_request_resend(seq_t first, seq_t last) {
if (running) {
if (!request_sent) {
debug(2, "requesting resend on %d packets (%04X:%04X).\n",
debug(2, "requesting resend on %d packets (%04X:%04X).",
seq_diff(first,last) + 1, first, last);
request_sent=1;
}
@@ -482,7 +482,7 @@ void rtp_request_resend(seq_t first, seq_t last) {
sendto(audio_socket, req, sizeof(req), 0, (struct sockaddr*)&rtp_client_control_socket, sizeof(rtp_client_control_socket));
} else {
if (!request_sent) {
debug(2,"rtp_request_resend called without active stream!\n");
debug(2,"rtp_request_resend called without active stream!");
request_sent=1;
}
}
+20 -20
View File
@@ -81,7 +81,7 @@ static void rtsp_take_player(void) {
return;
if (pthread_mutex_trylock(&playing_mutex)) {
debug(1, "shutting down playing thread\n");
debug(1, "shutting down playing thread.");
// XXX minor race condition between please_shutdown and signal delivery
please_shutdown = 1;
pthread_kill(playing_thread, SIGUSR1);
@@ -107,12 +107,12 @@ static void track_thread(rtsp_conn_info *conn) {
static void cleanup_threads(void) {
void *retval;
int i;
debug(2, "culling threads.\n");
debug(2, "culling threads.");
for (i=0; i<nconns; ) {
if (conns[i]->running == 0) {
pthread_join(conns[i]->thread, &retval);
free(conns[i]);
debug(2, "one joined\n");
debug(2, "one joined...");
nconns--;
if (nconns)
conns[i] = conns[nconns];
@@ -207,7 +207,7 @@ static int msg_handle_line(rtsp_message **pmsg, char *line) {
*pmsg = msg;
char *sp, *p;
// debug(1, "received request: %s\n", line);
// debug(1, "received request: %s", line);
p = strtok_r(line, " ", &sp);
if (!p)
@@ -237,7 +237,7 @@ static int msg_handle_line(rtsp_message **pmsg, char *line) {
*p = 0;
p += 2;
msg_add_header(msg, line, p);
debug(2, " %s: %s\n", line, p);
debug(2, " %s: %s.", line, p);
return -1;
} else {
char *cl = msg_get_header(msg, "Content-Length");
@@ -265,12 +265,12 @@ static rtsp_message * rtsp_read_request(int fd) {
while (msg_size < 0) {
if (please_shutdown) {
debug(1, "RTSP shutdown requested\n");
debug(1, "RTSP shutdown requested.");
goto shutdown;
}
nread = read(fd, buf+inbuf, buflen - inbuf);
if (!nread) {
debug(1, "RTSP connection closed\n");
debug(1, "RTSP connection closed.");
goto shutdown;
}
if (nread < 0) {
@@ -344,7 +344,7 @@ static void msg_write_response(int fd, rtsp_message *resp) {
p += n;
for (i=0; i<resp->nheaders; i++) {
debug(2, " %s: %s\n", resp->name[i], resp->value[i]);
debug(2, " %s: %s.", resp->name[i], resp->value[i]);
n = snprintf(p, pktfree, "%s: %s\r\n", resp->name[i], resp->value[i]);
pktfree -= n;
p += n;
@@ -363,7 +363,7 @@ static void handle_record(rtsp_conn_info *conn,
rtsp_message *req, rtsp_message *resp) {
char * hdr = msg_get_header(req,"Range");
// debug(1,"RECORD message received: \"%s\".\n",hdr);
// debug(1,"RECORD message received: \"%s\".",hdr);
resp->respcode = 200;
msg_add_header(resp, "Audio-Latency","88200");
}
@@ -392,7 +392,7 @@ static void handle_flush(rtsp_conn_info *conn,
return;
char * hdr = msg_get_header(req,"RTP-Info");
// debug(1,"FLUSH message received: \"%s\".\n",hdr);
// debug(1,"FLUSH message received: \"%s\".",hdr);
// get the rtp timestamp
char *p;
uint32_t rtptime=0;
@@ -468,7 +468,7 @@ static void handle_ignore(rtsp_conn_info *conn,
static void handle_set_parameter(rtsp_conn_info *conn,
rtsp_message *req, rtsp_message *resp) {
if (!req->contentlength)
debug(1, "received empty SET_PARAMETER request\n");
debug(1, "received empty SET_PARAMETER request.");
char *cp = req->content;
int cp_left = req->contentlength;
@@ -479,10 +479,10 @@ static void handle_set_parameter(rtsp_conn_info *conn,
if (!strncmp(cp, "volume: ", 8)) {
float volume = atof(cp + 8);
// debug(1, "volume: %f\n", volume);
// debug(1, "volume: %f.", volume);
player_volume(volume);
} else {
debug(1, "unrecognised parameter: >>%s<< (%d)\n", cp, strlen(cp));
debug(1, "unrecognised parameter: >>%s<< (%d).", cp, strlen(cp));
}
cp = next;
}
@@ -758,7 +758,7 @@ respond:
msg_free(resp);
}
debug(1, "closing RTSP connection\n");
debug(1, "closing RTSP connection.");
if (conn->fd > 0)
close(conn->fd);
if (rtsp_playing()) {
@@ -770,7 +770,7 @@ respond:
if (auth_nonce)
free(auth_nonce);
conn->running = 0;
debug(2, "terminating RTSP thread\n");
debug(2, "terminating RTSP thread.");
return NULL;
}
@@ -830,10 +830,10 @@ void rtsp_listen_loop(void) {
// one of the address families will fail on some systems that
// report its availability. do not complain.
if (ret) {
debug(1, "Failed to bind to address %s\n", format_address(p->ai_addr));
debug(1, "Failed to bind to address %s.", format_address(p->ai_addr));
continue;
}
debug(1, "Bound to address %s\n", format_address(p->ai_addr));
debug(1, "Bound to address %s.", format_address(p->ai_addr));
listen(fd, 5);
nsock++;
@@ -857,8 +857,8 @@ void rtsp_listen_loop(void) {
mdns_register();
printf("Listening for connections.\n");
shairport_startup_complete();
// printf("Listening for connections.");
// shairport_startup_complete();
int acceptfd;
struct timeval tv;
@@ -892,7 +892,7 @@ void rtsp_listen_loop(void) {
memset(conn, 0, sizeof(rtsp_conn_info));
socklen_t slen = sizeof(conn->remote);
debug(1, "new RTSP connection\n");
debug(1, "new RTSP connection.");
conn->fd = accept(acceptfd, (struct sockaddr *)&conn->remote, &slen);
if (conn->fd < 0) {
perror("failed to accept connection");