Skip to content

Commit

Permalink
3.1.2 pretty-print using clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebrady committed Sep 7, 2017
1 parent bbdefd9 commit 3001f39
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 99 deletions.
2 changes: 1 addition & 1 deletion alac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ alac_file *alac_create(int samplesize, int numchannels) {
newfile->numchannels = numchannels;
newfile->bytespersample = (samplesize / 8) * numchannels;
} else {
fprintf(stderr, "FIXME: can not allocate memory for a new file in alac_cxreate.");
fprintf(stderr, "FIXME: can not allocate memory for a new file in alac_cxreate.");
}
return newfile;
}
2 changes: 1 addition & 1 deletion common.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ char *base64_enc(uint8_t *input, int length) {
BIO_get_mem_ptr(b64, &bptr);

char *buf = (char *)malloc(bptr->length);
if (buf==NULL)
if (buf == NULL)
die("could not allocate memory for buf in base64_enc");
if (bptr->length) {
memcpy(buf, bptr->data, bptr->length - 1);
Expand Down
41 changes: 22 additions & 19 deletions player.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,10 +710,12 @@ static abuf_t *buffer_get_frame(rtsp_conn_info *conn) {
if ((conn->time_of_last_audio_packet != 0) && (conn->stop == 0) &&
(config.dont_check_timeout == 0)) {
uint64_t ct = config.timeout; // go from int to 64-bit int
// if (conn->packet_count>500) { //for testing -- about 4 seconds of play first
// if (conn->packet_count>500) { //for testing -- about 4 seconds of play first
if ((local_time_now > conn->time_of_last_audio_packet) &&
(local_time_now - conn->time_of_last_audio_packet >= ct << 32)) {
debug(1, "As Yeats almost said, \"Too long a silence / can make a stone of the heart\" from RTSP conversation %d.",conn->connection_number);
debug(1, "As Yeats almost said, \"Too long a silence / can make a stone of the heart\" "
"from RTSP conversation %d.",
conn->connection_number);
conn->stop = 1;
pthread_kill(conn->thread, SIGUSR1);
}
Expand Down Expand Up @@ -1830,12 +1832,13 @@ static void *player_thread_func(void *arg) {
} else if ((sync_error < 0) && ((-sync_error) > filler_length)) {
// debug(1, "Large negative sync error: %lld. Inserting silence.", sync_error);
size_t silence_length = -sync_error;
if (silence_length>(filler_length*5))
silence_length = filler_length*5;
if (silence_length > (filler_length * 5))
silence_length = filler_length * 5;

char *long_silence = malloc(conn->output_bytes_per_frame * silence_length);
if (long_silence == NULL)
die("Failed to allocate memory for a long_silence buffer of %d frames.",silence_length);
die("Failed to allocate memory for a long_silence buffer of %d frames.",
silence_length);
memset(long_silence, 0, conn->output_bytes_per_frame * silence_length);
config.output->play((short *)long_silence, silence_length);
free(long_silence);
Expand Down Expand Up @@ -2187,8 +2190,8 @@ static void *player_thread_func(void *arg) {
rc = pthread_mutex_destroy(&conn->vol_mutex);
if (rc)
debug(1, "Error destroying vol_mutex variable.");
debug(1, "Player thread exit on RTSP conversation thread %d.",conn->connection_number);

debug(1, "Player thread exit on RTSP conversation thread %d.", conn->connection_number);
if (outbuf)
free(outbuf);
if (silence)
Expand Down Expand Up @@ -2440,7 +2443,7 @@ void player_flush(int64_t timestamp, rtsp_conn_info *conn) {

int player_play(rtsp_conn_info *conn) {
// need to use conn in place of streram below. Need to put the stream as a parameter to he
if (conn->player_thread!=NULL)
if (conn->player_thread != NULL)
die("Trying to create a second player thread for this RTSP session");
if (config.buffer_start_fill > BUFFER_FRAMES)
die("specified buffer starting fill %d > buffer size %d", config.buffer_start_fill,
Expand All @@ -2450,7 +2453,7 @@ int player_play(rtsp_conn_info *conn) {
send_ssnc_metadata('pbeg', NULL, 0, 1);
#endif
pthread_t *pt = malloc(sizeof(pthread_t));
if (pt==NULL)
if (pt == NULL)
die("Couldn't allocate space for pthread_t");
conn->player_thread = pt;
size_t size = (PTHREAD_STACK_MIN + 256 * 1024);
Expand All @@ -2466,17 +2469,17 @@ int player_play(rtsp_conn_info *conn) {

void player_stop(rtsp_conn_info *conn) {
if (conn->player_thread) {
conn->player_thread_please_stop = 1;
pthread_cond_signal(&conn->flowcontrol); // tell it to give up
pthread_kill(*conn->player_thread, SIGUSR1);
pthread_join(*conn->player_thread, NULL);
conn->player_thread_please_stop = 1;
pthread_cond_signal(&conn->flowcontrol); // tell it to give up
pthread_kill(*conn->player_thread, SIGUSR1);
pthread_join(*conn->player_thread, NULL);
#ifdef CONFIG_METADATA
send_ssnc_metadata('pend', NULL, 0, 1);
send_ssnc_metadata('pend', NULL, 0, 1);
#endif
command_stop();
free(conn->player_thread);
conn->player_thread = NULL;
command_stop();
free(conn->player_thread);
conn->player_thread = NULL;
} else {
debug(3,"player thread of RTSP conversation %d is already deleted.",conn->connection_number);
debug(3, "player thread of RTSP conversation %d is already deleted.", conn->connection_number);
}
}
2 changes: 1 addition & 1 deletion player.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ typedef struct {
int stop;
int running;
pthread_t thread;

// pthread_t *ptp;
pthread_t *player_thread;

Expand Down
12 changes: 7 additions & 5 deletions rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ void *rtp_control_receiver(void *arg) {
debug(3, "Too-short retransmitted audio packet received in control port, ignored.");
}
} else
debug(1, "Control Port -- Unknown RTP packet of type 0x%02X length %d, ignored.", packet[1], nread);
debug(1, "Control Port -- Unknown RTP packet of type 0x%02X length %d, ignored.", packet[1],
nread);
}

debug(3, "Control RTP thread interrupted. terminating.");
Expand Down Expand Up @@ -290,7 +291,8 @@ void *rtp_timing_sender(void *arg) {
// debug(1,"Send a timing request");

if (!conn->rtp_running)
debug(1,"rtp_timing_sender called without active stream in RTSP conversation thread %d!",conn->connection_number);
debug(1, "rtp_timing_sender called without active stream in RTSP conversation thread %d!",
conn->connection_number);

// debug(1, "Requesting ntp timestamp exchange.");

Expand Down Expand Up @@ -639,8 +641,8 @@ void rtp_setup(SOCKADDR *local, SOCKADDR *remote, int cport, int tport, uint32_t
inet_ntop(conn->connection_ip_family, self_addr, conn->self_ip_string,
sizeof(conn->self_ip_string));

debug(1, "Set up play connection from %s to self at %s on RTSP conversation thread %d.", conn->client_ip_string,
conn->self_ip_string, conn->connection_number);
debug(1, "Set up play connection from %s to self at %s on RTSP conversation thread %d.",
conn->client_ip_string, conn->self_ip_string, conn->connection_number);

// set up a the record of the remote's control socket
struct addrinfo hints;
Expand Down Expand Up @@ -713,7 +715,7 @@ void get_reference_timestamp_stuff(int64_t *timestamp, uint64_t *timestamp_time,
pthread_mutex_lock(&conn->reference_time_mutex);
*timestamp = conn->reference_timestamp;
*timestamp_time = conn->reference_timestamp_time;
//if ((*timestamp == 0) && (*timestamp_time == 0)) {
// if ((*timestamp == 0) && (*timestamp_time == 0)) {
// debug(1,"Reference timestamp is invalid.");
//}
*remote_timestamp_time = conn->remote_reference_timestamp_time;
Expand Down
Loading

0 comments on commit 3001f39

Please sign in to comment.