# HG changeset patch # User Yoshiki Yazawa # Date 1329806764 -32400 # Node ID a910b49dfbee3f9fd7bc70cc59194c6bc8005be1 # Parent f2ae5ddeed7ec2df434f63e47f0c1e4bf8870553 work in progress improvement: - fix bugs around cond_timedwait - try to avoid sticking in PMT analysis diff -r f2ae5ddeed7e -r a910b49dfbee recpt1/recpt1.c --- a/recpt1/recpt1.c Thu Feb 16 13:11:38 2012 +0900 +++ b/recpt1/recpt1.c Tue Feb 21 15:46:04 2012 +0900 @@ -209,18 +209,24 @@ { struct timeval now; struct timespec spec; - - gettimeofday(&now, NULL); - spec.tv_sec = now.tv_sec + 1; - spec.tv_nsec = now.tv_usec * 1000; + int retry_count = 0; pthread_mutex_lock(&p_queue->mutex); /* entered critical section */ /* wait while queue is full */ while(p_queue->num_avail == 0) { + + gettimeofday(&now, NULL); + spec.tv_sec = now.tv_sec + 1; + spec.tv_nsec = now.tv_usec * 1000; + pthread_cond_timedwait(&p_queue->cond_avail, &p_queue->mutex, &spec); + retry_count++; + if(retry_count > 60) { + f_exit = TRUE; + } if(f_exit) { pthread_mutex_unlock(&p_queue->mutex); return; @@ -249,18 +255,24 @@ struct timeval now; struct timespec spec; BUFSZ *buffer; - - gettimeofday(&now, NULL); - spec.tv_sec = now.tv_sec + 1; - spec.tv_nsec = now.tv_usec * 1000; + int retry_count = 0; pthread_mutex_lock(&p_queue->mutex); /* entered the critical section*/ /* wait while queue is empty */ while(p_queue->num_used == 0) { + + gettimeofday(&now, NULL); + spec.tv_sec = now.tv_sec + 1; + spec.tv_nsec = now.tv_usec * 1000; + pthread_cond_timedwait(&p_queue->cond_used, &p_queue->mutex, &spec); + retry_count++; + if(retry_count > 60) { + f_exit = TRUE; + } if(f_exit) { pthread_mutex_unlock(&p_queue->mutex); return NULL; diff -r f2ae5ddeed7e -r a910b49dfbee recpt1/tssplitter_lite.c --- a/recpt1/tssplitter_lite.c Thu Feb 16 13:11:38 2012 +0900 +++ b/recpt1/tssplitter_lite.c Tue Feb 21 15:46:04 2012 +0900 @@ -227,7 +227,7 @@ // PAT if(0x0000 == pid) { result = AnalyzePat(sp, sbuf->data + index); - if(TSS_SUCCESS != result) { + if(result != TSS_SUCCESS) { /* 下位の関数内部でmalloc error発生 */ return result; } @@ -238,7 +238,10 @@ * 残すべきPCR/AUDIO/VIDEO PIDを取得する */ if(sp->pmt_pids[pid] == 1) { /* この中にはPMT毎に一度しか入らないようにしておく */ - AnalyzePmt(sp, sbuf->data + index); + result = AnalyzePmt(sp, sbuf->data + index); + if(result != TSS_SUCCESS) { + return result; + } sp->pmt_pids[pid]++; sp->pmt_counter += 1; } @@ -587,6 +590,7 @@ unsigned char N; int pcr; int epid; + int retry_count = 0; Nall = ((buf[6] & 0x0F) << 4) + buf[7]; if(Nall > LENGTH_PACKET) @@ -627,6 +631,10 @@ sp->pids[epid] = 1; } N += 4 + (((buf[N + 3]) & 0x0F) << 4) + buf[N + 4] + 1; + retry_count++; + if(retry_count > Nall) { + return TSS_ERROR; + } } return TSS_SUCCESS;