Continue to experiement with metadata. Make it a little more resistant to line drop outs and delays, add too-simple reference counting to rtsp messages.

This commit is contained in:
Mike Brady
2015-02-27 17:21:00 +00:00
parent 46412eb148
commit 391b48f62a
4 changed files with 31 additions and 21 deletions
+5 -7
View File
@@ -3,14 +3,12 @@ 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
if USE_CUSTOMPIDDIR
AM_CFLAGS= \
-DPIDDIR=\"$(CUSTOM_PID_DIR)\" -Wno-multichar
else
AM_CFLAGS= -Wno-multichar
endif
AM_CFLAGS = -Wno-multichar
AM_CFLAGS += -Wno-multichar
if USE_CUSTOMPIDDIR
AM_CFLAGS+= \
-DPIDDIR=\"$(CUSTOM_PID_DIR)\"
endif
if USE_AVAHI
shairport_sync_SOURCES += mdns_avahi.c
+2 -2
View File
@@ -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");
+4
View File
@@ -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);
+20 -12
View File
@@ -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;
}
@@ -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]);
@@ -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!");
}
}
@@ -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;
}
@@ -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)