mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-29 16:31:05 +02:00
use new for buf, fix possible memlaek
Origin commit data
------------------
Commit: a84ba36e0b
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2012-09-18 (Tue, 18 Sep 2012)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user