mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 15:02:43 +02:00
formatting code using astyle
Origin commit data
------------------
Branch: master
Commit: bc17c13de4
Author: vanhofen <vanhofen@gmx.de>
Date: 2021-05-17 (Mon, 17 May 2021)
Origin message was:
------------------
- formatting code using astyle
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -50,15 +50,16 @@ extern cVideo *videoDecoder;
|
||||
#define hal_debug_z(args...) _hal_debug(HAL_DEBUG_DEMUX, thiz, args)
|
||||
|
||||
#define dmx_err(_errfmt, _errstr, _revents) do { \
|
||||
hal_info("%s " _errfmt " fd:%d, ev:0x%x %s pid:0x%04hx flt:0x%02hx\n", \
|
||||
__func__, _errstr, fd, _revents, DMX_T[dmx_type], pid, flt); \
|
||||
} while(0);
|
||||
hal_info("%s " _errfmt " fd:%d, ev:0x%x %s pid:0x%04hx flt:0x%02hx\n", \
|
||||
__func__, _errstr, fd, _revents, DMX_T[dmx_type], pid, flt); \
|
||||
} while(0);
|
||||
|
||||
cDemux *videoDemux = NULL;
|
||||
cDemux *audioDemux = NULL;
|
||||
//cDemux *pcrDemux = NULL;
|
||||
|
||||
static const char *DMX_T[] = {
|
||||
static const char *DMX_T[] =
|
||||
{
|
||||
"DMX_INVALID",
|
||||
"DMX_VIDEO",
|
||||
"DMX_AUDIO",
|
||||
@@ -92,7 +93,8 @@ static int dmx_source[NUM_DEMUX] = { 0, 0, 0, 0 };
|
||||
#endif
|
||||
|
||||
char dmxdev[32];
|
||||
static char* devname(int adapter, int demux) {
|
||||
static char *devname(int adapter, int demux)
|
||||
{
|
||||
snprintf(dmxdev, sizeof(dmxdev), "/dev/dvb/adapter%d/demux%d", adapter, demux);
|
||||
return dmxdev;
|
||||
}
|
||||
@@ -119,7 +121,8 @@ static bool init[NUM_DEMUXDEV] = { false, false, false, false, false, false, fal
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct dmx_pdata {
|
||||
typedef struct dmx_pdata
|
||||
{
|
||||
int last_source;
|
||||
OpenThreads::Mutex *mutex;
|
||||
} dmx_pdata;
|
||||
@@ -167,17 +170,19 @@ bool cDemux::Open(DMX_CHANNEL_TYPE pes_type, void * /*hVideoBuffer*/, int uBuffe
|
||||
|
||||
static bool _open(cDemux *thiz, int num, int &fd, int &last_source, DMX_CHANNEL_TYPE dmx_type, int buffersize)
|
||||
{
|
||||
int flags = O_RDWR|O_CLOEXEC;
|
||||
int flags = O_RDWR | O_CLOEXEC;
|
||||
int devnum = dmx_source[num];
|
||||
if (last_source == devnum) {
|
||||
if (last_source == devnum)
|
||||
{
|
||||
hal_debug_z("%s #%d: source (%d) did not change\n", __func__, num, last_source);
|
||||
if (fd > -1)
|
||||
return true;
|
||||
}
|
||||
if (fd > -1) {
|
||||
if (fd > -1)
|
||||
{
|
||||
/* we changed source -> close and reopen the fd */
|
||||
hal_debug_z("%s #%d: FD ALREADY OPENED fd = %d lastsource %d devnum %d\n",
|
||||
__func__, num, fd, last_source, devnum);
|
||||
__func__, num, fd, last_source, devnum);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
@@ -191,7 +196,7 @@ static bool _open(cDemux *thiz, int num, int &fd, int &last_source, DMX_CHANNEL_
|
||||
return false;
|
||||
}
|
||||
hal_debug_z("%s #%d pes_type: %s(%d), uBufferSize: %d fd: %d\n", __func__,
|
||||
num, DMX_T[dmx_type], dmx_type, buffersize, fd);
|
||||
num, DMX_T[dmx_type], dmx_type, buffersize, fd);
|
||||
|
||||
/* this would actually need locking, but the worst that weill happen is, that
|
||||
* we'll DMX_SET_SOURCE twice per device, so don't bother... */
|
||||
@@ -262,7 +267,7 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
|
||||
#if 0
|
||||
if (len != 4095 && timeout != 10)
|
||||
fprintf(stderr, "cDemux::%s #%d fd: %d type: %s len: %d timeout: %d\n",
|
||||
__FUNCTION__, num, fd, DMX_T[dmx_type], len, timeout);
|
||||
__FUNCTION__, num, fd, DMX_T[dmx_type], len, timeout);
|
||||
#endif
|
||||
if (fd < 0)
|
||||
{
|
||||
@@ -275,7 +280,7 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
|
||||
int to = timeout;
|
||||
struct pollfd ufds;
|
||||
ufds.fd = fd;
|
||||
ufds.events = POLLIN|POLLPRI|POLLERR;
|
||||
ufds.events = POLLIN | POLLPRI | POLLERR;
|
||||
ufds.revents = 0;
|
||||
|
||||
/* hack: if the frontend loses and regains lock, the demuxer often will not
|
||||
@@ -286,7 +291,7 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
|
||||
|
||||
if (to > 0)
|
||||
{
|
||||
retry:
|
||||
retry:
|
||||
rc = ::poll(&ufds, 1, to);
|
||||
if (ufds.fd != fd)
|
||||
{
|
||||
@@ -331,8 +336,9 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (ufds.fd != fd) /* does this ever happen? and if, is it harmful? */
|
||||
{ /* read(-1,...) will just return EBADF anyway... */
|
||||
if (ufds.fd != fd) /* does this ever happen? and if, is it harmful? */
|
||||
{
|
||||
/* read(-1,...) will just return EBADF anyway... */
|
||||
hal_info("%s:2 ========== fd has changed, %d->%d ==========\n", __func__, ufds.fd, fd);
|
||||
return -1;
|
||||
}
|
||||
@@ -345,9 +351,9 @@ int cDemux::Read(unsigned char *buff, int len, int timeout)
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool cDemux::sectionFilter(unsigned short _pid, const unsigned char * const filter,
|
||||
const unsigned char * const mask, int len, int timeout,
|
||||
const unsigned char * const negmask)
|
||||
bool cDemux::sectionFilter(unsigned short _pid, const unsigned char *const filter,
|
||||
const unsigned char *const mask, int len, int timeout,
|
||||
const unsigned char *const negmask)
|
||||
{
|
||||
struct dmx_sct_filter_params s_flt;
|
||||
memset(&s_flt, 0, sizeof(s_flt));
|
||||
@@ -368,7 +374,7 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char * const filt
|
||||
if (negmask != NULL)
|
||||
memcpy(s_flt.filter.mode, negmask, len);
|
||||
|
||||
s_flt.flags = DMX_IMMEDIATE_START|DMX_CHECK_CRC;
|
||||
s_flt.flags = DMX_IMMEDIATE_START | DMX_CHECK_CRC;
|
||||
|
||||
int to = 0;
|
||||
switch (filter[0])
|
||||
@@ -453,15 +459,22 @@ bool cDemux::sectionFilter(unsigned short _pid, const unsigned char * const filt
|
||||
s_flt.timeout = to;
|
||||
|
||||
hal_debug("%s #%d pid:0x%04hx fd:%d type:%s len:%d to:%d flags:%x flt[0]:%02x\n", __func__, num,
|
||||
pid, fd, DMX_T[dmx_type], len, s_flt.timeout, s_flt.flags, s_flt.filter.filter[0]);
|
||||
pid, fd, DMX_T[dmx_type], len, s_flt.timeout, s_flt.flags, s_flt.filter.filter[0]);
|
||||
|
||||
if (debuglevel == 2) {
|
||||
fprintf(stderr,"filt: "); for (int i = 0; i < len; i++) fprintf(stderr, "%02hhx ", s_flt.filter.filter[i]); fprintf(stderr, "\n");
|
||||
fprintf(stderr,"mask: "); for (int i = 0; i < len; i++) fprintf(stderr, "%02hhx ", s_flt.filter.mask [i]); fprintf(stderr, "\n");
|
||||
fprintf(stderr,"mode: "); for (int i = 0; i < len; i++) fprintf(stderr, "%02hhx ", s_flt.filter.mode [i]); fprintf(stderr, "\n");
|
||||
if (debuglevel == 2)
|
||||
{
|
||||
fprintf(stderr, "filt: ");
|
||||
for (int i = 0; i < len; i++) fprintf(stderr, "%02hhx ", s_flt.filter.filter[i]);
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "mask: ");
|
||||
for (int i = 0; i < len; i++) fprintf(stderr, "%02hhx ", s_flt.filter.mask [i]);
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "mode: ");
|
||||
for (int i = 0; i < len; i++) fprintf(stderr, "%02hhx ", s_flt.filter.mode [i]);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
ioctl (fd, DMX_STOP);
|
||||
ioctl(fd, DMX_STOP);
|
||||
if (ioctl(fd, DMX_SET_FILTER, &s_flt) < 0)
|
||||
return false;
|
||||
|
||||
@@ -477,7 +490,7 @@ bool cDemux::pesFilter(const unsigned short _pid)
|
||||
* this check originally is from tuxbox cvs but I'm not sure
|
||||
* what it is good for...
|
||||
if (pid <= 0x0001 && dmx_type != DMX_PCR_ONLY_CHANNEL)
|
||||
return false;
|
||||
return false;
|
||||
*/
|
||||
if ((pid >= 0x0002 && pid <= 0x000f) || pid >= 0x1fff)
|
||||
return false;
|
||||
@@ -569,7 +582,8 @@ void cDemux::removePid(unsigned short Pid)
|
||||
}
|
||||
for (std::vector<pes_pids>::iterator i = pesfds.begin(); i != pesfds.end(); ++i)
|
||||
{
|
||||
if ((*i).pid == Pid) {
|
||||
if ((*i).pid == Pid)
|
||||
{
|
||||
hal_debug("removePid: removing demux fd %d pid 0x%04x\n", fd, Pid);
|
||||
if (ioctl(fd, DMX_REMOVE_PID, Pid) < 0)
|
||||
hal_info("%s: (DMX_REMOVE_PID, 0x%04hx): %m\n", __func__, Pid);
|
||||
@@ -580,7 +594,7 @@ void cDemux::removePid(unsigned short Pid)
|
||||
hal_info("%s pid 0x%04x not found\n", __FUNCTION__, Pid);
|
||||
}
|
||||
|
||||
void cDemux::getSTC(int64_t * STC)
|
||||
void cDemux::getSTC(int64_t *STC)
|
||||
{
|
||||
/* apparently I can only get the PTS of the video decoder,
|
||||
* but that's good enough for dvbsub */
|
||||
@@ -602,7 +616,8 @@ int cDemux::getUnit(void)
|
||||
|
||||
bool cDemux::SetSource(int unit, int source)
|
||||
{
|
||||
if (unit >= NUM_DEMUX || unit < 0) {
|
||||
if (unit >= NUM_DEMUX || unit < 0)
|
||||
{
|
||||
hal_info_c("%s: unit (%d) out of range, NUM_DEMUX %d\n", __func__, unit, NUM_DEMUX);
|
||||
return false;
|
||||
}
|
||||
@@ -616,7 +631,8 @@ bool cDemux::SetSource(int unit, int source)
|
||||
|
||||
int cDemux::GetSource(int unit)
|
||||
{
|
||||
if (unit >= NUM_DEMUX || unit < 0) {
|
||||
if (unit >= NUM_DEMUX || unit < 0)
|
||||
{
|
||||
hal_info_c("%s: unit (%d) out of range, NUM_DEMUX %d\n", __func__, unit, NUM_DEMUX);
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user