Mercurial > pt1.oyama
diff recpt1/recpt1.c @ 88:59065b569eec
improve stability on changing channel
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Wed, 27 Jan 2010 14:36:47 +0900 |
parents | 0b00d22b0d1c |
children | d74bcf2d255d |
line wrap: on
line diff
--- a/recpt1/recpt1.c Wed Jan 27 03:48:15 2010 +0900 +++ b/recpt1/recpt1.c Wed Jan 27 14:36:47 2010 +0900 @@ -96,9 +96,6 @@ if(ch && tdata->ch != ch) { /* stop stream */ ioctl(tdata->tfd, STOP_REC, 0); - - /* flush remainder? */ - #if 0 /* re-initialize decoder */ if(tdata->decoder) { @@ -114,6 +111,12 @@ /* tune to new channel */ if(close_tuner(tdata) != 0) return NULL; + + /* wait for remainder */ + while(tdata->queue->num_used > 0) { + usleep(10000); + } + tune(channel, tdata, NULL); /* restart recording */ @@ -1037,6 +1040,10 @@ time(&cur_time); bufptr = malloc(sizeof(BUFSZ)); + if(!bufptr) { + f_exit = TRUE; + break; + } bufptr->size = read(tdata.tfd, bufptr->buffer, MAX_READ_SIZE); if(bufptr->size <= 0) { if((cur_time - tdata.start_time) >= tdata.recsec && !tdata.indefinite) { @@ -1057,6 +1064,10 @@ /* read remaining data */ while(1) { bufptr = malloc(sizeof(BUFSZ)); + if(!bufptr) { + f_exit = TRUE; + break; + } bufptr->size = read(tdata.tfd, bufptr->buffer, MAX_READ_SIZE); if(bufptr->size <= 0) { f_exit = TRUE;