diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index 199f3a485..6f14c3d2c 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -3948,7 +3948,7 @@ static off64_t cut_movie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie) char spart[255]; char dpart[255]; char npart[255]; - unsigned char * buf; + unsigned char psi[PSI_SIZE]; int r, i; off64_t sdone, spos; @@ -3965,9 +3965,9 @@ static off64_t cut_movie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie) time_t tt1; off64_t bpos, bskip; - buf = (unsigned char *) malloc(BUF_SIZE); + unsigned char * buf = new unsigned char[BUF_SIZE]; if(buf == 0) { - perror("malloc"); + perror("new"); return 0; } @@ -4019,7 +4019,10 @@ printf("cut: end bookmark %d at %lld\n", bcount, books[bcount].pos); bcount++; } printf("\n"); - if(!bcount) return 0; + if(!bcount){ + delete [] buf; + return 0; + } qsort(books, bcount, sizeof(struct mybook), compare_book); for(i = 0; i < bcount; i++) { if(books[i].ok) { @@ -4051,6 +4054,7 @@ printf("\n********* new file %s expected size %lld, start time %s", dpart, newsi dstfd = open (dpart, O_CREAT|O_WRONLY|O_TRUNC| O_LARGEFILE, 0644); if(dstfd < 0) { perror(dpart); + delete [] buf; return 0; } part = 0; @@ -4179,7 +4183,7 @@ printf("********* total written %lld tooks %ld secs end time %s", spos, tt1-tt, lseek64 (dstfd, 0, SEEK_SET); ret_err: close(dstfd); - free(buf); + delete [] buf; if(was_cancel) g_RCInput->postMsg(CRCInput::RC_home, 0); return retval; @@ -4195,7 +4199,6 @@ static off64_t copy_movie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie, bool onefi char spart[255]; char dpart[255]; char npart[255]; - unsigned char * buf; unsigned char psi[PSI_SIZE]; int r, i; off64_t sdone, spos = 0, btotal = 0; @@ -4209,9 +4212,9 @@ static off64_t copy_movie(MI_MOVIE_INFO * minfo, CMovieInfo * cmovie, bool onefi bool was_cancel = false; int retval = 0; - buf = (unsigned char *) malloc(BUF_SIZE); + unsigned char * buf = new unsigned char[BUF_SIZE]; if(buf == 0) { - perror("malloc"); + perror("new"); return 0; } @@ -4247,8 +4250,10 @@ printf("copy: jump bookmark %d at %lld len %lld\n", bcount, books[bcount].pos, b bcount++; } } - if(!bcount) return 0; - + if(!bcount){ + delete [] buf; + return 0; + } tt = time(0); printf("********* %d boormarks, to %s file(s), expected size to copy %lld, start time %s", bcount, onefile ? "one" : "many", newsize, ctime (&tt)); snprintf(npart, sizeof(npart), "%s", name); @@ -4389,7 +4394,7 @@ printf("copy: ********* %s: total written %lld took %ld secs\n", dpart, spos, tt } retval = 1; ret_err: - free(buf); + delete [] buf; if(was_cancel) g_RCInput->postMsg(CRCInput::RC_home, 0); return retval; diff --git a/src/gui/streaminfo2.cpp b/src/gui/streaminfo2.cpp index e508ea134..25ca76582 100644 --- a/src/gui/streaminfo2.cpp +++ b/src/gui/streaminfo2.cpp @@ -776,8 +776,6 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos) /* * some definition */ -#define TS_LEN 188 -#define TS_BUF_SIZE (TS_LEN * 2048) /* fix dmx buffer size */ static unsigned long timeval_to_ms (const struct timeval *tv) { @@ -789,7 +787,6 @@ long delta_time_ms (struct timeval *tv, struct timeval *last_tv) return timeval_to_ms (tv) - timeval_to_ms (last_tv); } -uint64_t b_total; static cDemux * dmx; int CStreamInfo2::ts_setup () @@ -804,13 +801,22 @@ int CStreamInfo2::ts_setup () if( !g_RemoteControl->current_PIDs.APIDs.empty() ) apid = g_RemoteControl->current_PIDs.APIDs[g_RemoteControl->current_PIDs.PIDs.selected_apid].pid; + short ret = -1; if(vpid == 0 && apid == 0) - return -1; + return ret; dmx = new cDemux(0); if(!dmx) - return -1; + return ret; +#define TS_LEN 188 +#define TS_BUF_SIZE (TS_LEN * 2048) /* fix dmx buffer size */ + dmxbuf = new unsigned char[TS_BUF_SIZE]; + if(!dmxbuf){ + delete dmx; + dmx = NULL; + return ret; + } dmx->Open(DMX_TP_CHANNEL, NULL, 3 * 3008 * 62); if(vpid > 0) { @@ -825,8 +831,8 @@ int CStreamInfo2::ts_setup () gettimeofday (&first_tv, NULL); last_tv.tv_sec = first_tv.tv_sec; last_tv.tv_usec = first_tv.tv_usec; - b_total = 0; - return 0; + ret = b_total = 0; + return ret; } int CStreamInfo2::update_rate () @@ -834,8 +840,6 @@ int CStreamInfo2::update_rate () if(!dmx) return 0; - - unsigned char buf[TS_BUF_SIZE] = {0}; long b = 0; int ret = 0; @@ -843,7 +847,7 @@ int CStreamInfo2::update_rate () int timeout = 100; - b_len = dmx->Read(buf, sizeof (buf), timeout); + b_len = dmx->Read(dmxbuf, TS_BUF_SIZE, timeout); //printf("ts: read %d\n", b_len); b = b_len; @@ -881,6 +885,9 @@ int CStreamInfo2::ts_close () if(dmx) delete dmx; dmx = NULL; + if(dmxbuf) + delete [] dmxbuf; + dmxbuf = NULL; return 0; } diff --git a/src/gui/streaminfo2.h b/src/gui/streaminfo2.h index dd6b553d2..e24c48ca4 100644 --- a/src/gui/streaminfo2.h +++ b/src/gui/streaminfo2.h @@ -84,7 +84,7 @@ class CStreamInfo2 : public CMenuTarget uint64_t bit_s; uint64_t abit_s; uint64_t b_total; - + unsigned char *dmxbuf; int update_rate(); int ts_setup(); int ts_close();