Skip to content

Commit

Permalink
Continue to experiement with metadata. Make it a little more resistan…
Browse files Browse the repository at this point in the history
…t to line drop outs and delays, add too-simple reference counting to rtsp messages.
  • Loading branch information
mikebrady committed Feb 27, 2015
1 parent 46412eb commit 391b48f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
10 changes: 4 additions & 6 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ SUBDIRS = man
bin_PROGRAMS = shairport-sync
shairport_sync_SOURCES = shairport.c metadata.c rtsp.c mdns.c mdns_external.c common.c rtp.c player.c alac.c audio.c audio_dummy.c audio_pipe.c

AM_CFLAGS = -Wno-multichar

if USE_CUSTOMPIDDIR
AM_CFLAGS= \
-DPIDDIR=\"$(CUSTOM_PID_DIR)\" -Wno-multichar
else
AM_CFLAGS= -Wno-multichar
AM_CFLAGS+= \
-DPIDDIR=\"$(CUSTOM_PID_DIR)\"
endif

AM_CFLAGS += -Wno-multichar

if USE_AVAHI
shairport_sync_SOURCES += mdns_avahi.c
endif
Expand Down
4 changes: 2 additions & 2 deletions metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ void metadata_process(uint32_t type,uint32_t code,char *data,uint32_t length) {
debug(1,"Error writing base64 data to pipe: \"%s\".",strerror(errno));
remaining_data+=towrite_count;
remaining_count-=towrite_count;
//ret = write(fd,"\r\n",2);
//if (ret<0)
// ret = write(fd,"\r\n",2);
// if (ret<0)
// debug(1,"Error writing base64 cr/lf to pipe.");
}
snprintf(thestring,1024,"</data>\n");
Expand Down
4 changes: 4 additions & 0 deletions player.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,10 @@ static void *player_thread_func(void *arg) {
} else {
sync_error_out_of_bounds = 0;
}

// mark the frame as finished
inframe->timestamp=0;
inframe->sequence_number = 0;

// debug(1,"Sync error %lld frames. Amount to stuff %d." ,sync_error,amount_to_stuff);

Expand Down
32 changes: 20 additions & 12 deletions rtsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,23 +173,25 @@ static char *nextline(char *in, int inbuf) {
}

typedef struct {
int nheaders;
char *name[16];
char *value[16];
uint32_t referenceCount; // we might start using this...
int nheaders;
char *name[16];
char *value[16];

int contentlength;
char *content;
int contentlength;
char *content;

// for requests
char method[16];
// for requests
char method[16];

// for responses
int respcode;
// for responses
int respcode;
} rtsp_message;

static rtsp_message * msg_init(void) {
rtsp_message *msg = malloc(sizeof(rtsp_message));
memset(msg, 0, sizeof(rtsp_message));
msg->referenceCount = 1;
return msg;
}

Expand Down Expand Up @@ -222,6 +224,7 @@ static void msg_print_debug_headers(rtsp_message *msg) {
}

static void msg_free(rtsp_message *msg) {
if (--(msg->referenceCount)<=0) {
int i;
for (i=0; i<msg->nheaders; i++) {
free(msg->name[i]);
Expand All @@ -230,6 +233,9 @@ static void msg_free(rtsp_message *msg) {
if (msg->content)
free(msg->content);
free(msg);
} else {
debug(1,"rtsp_message reference count non-zero!");
}
}


Expand Down Expand Up @@ -367,10 +373,12 @@ static enum rtsp_read_request_response rtsp_read_request(int fd, rtsp_message**
return reply;

shutdown:
free(buf);
if (msg) {
msg_free(msg);
msg_free(msg); // which will free the content and everything else
}
// in case the message wasn't formed or wasn't fully initialised
if ((msg) && (msg-> content == NULL) || (!msg))
free(buf);
*the_packet = NULL;
return reply;
}
Expand Down Expand Up @@ -992,7 +1000,7 @@ static void *rtsp_conversation_thread_func(void *pconn) {

respond:
msg_write_response(conn->fd, resp);
msg_free(req);
msg_free(req); // we may change this to use reference counting!
msg_free(resp);
} else {
if (reply!=rtsp_read_request_response_shutdown_requested)
Expand Down

0 comments on commit 391b48f

Please sign in to comment.