mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-31 17:31:11 +02:00
eitd/sectionsd.cpp: add mutex to protect update demux
Origin commit data
------------------
Commit: d8d42b26a0
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2012-07-24 (Tue, 24 Jul 2012)
This commit is contained in:
@@ -251,6 +251,7 @@ class CCNThread : public CEventsThread
|
|||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
/* CN-specific */
|
/* CN-specific */
|
||||||
|
OpenThreads::Mutex update_mutex;
|
||||||
bool updating;
|
bool updating;
|
||||||
cDemux * eitDmx;
|
cDemux * eitDmx;
|
||||||
|
|
||||||
|
@@ -1672,8 +1672,6 @@ void CCNThread::beforeWait()
|
|||||||
if (updating || eit_version == 0xff)
|
if (updating || eit_version == 0xff)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
updating = true;
|
|
||||||
|
|
||||||
unsigned char filter[DMX_FILTER_SIZE];
|
unsigned char filter[DMX_FILTER_SIZE];
|
||||||
unsigned char mask[DMX_FILTER_SIZE];
|
unsigned char mask[DMX_FILTER_SIZE];
|
||||||
unsigned char mode[DMX_FILTER_SIZE];
|
unsigned char mode[DMX_FILTER_SIZE];
|
||||||
@@ -1693,17 +1691,22 @@ void CCNThread::beforeWait()
|
|||||||
mask[3] = (0x1F << 1) | 0x01;
|
mask[3] = (0x1F << 1) | 0x01;
|
||||||
mode[3] = 0x1F << 1;
|
mode[3] = 0x1F << 1;
|
||||||
|
|
||||||
|
update_mutex.lock();
|
||||||
eitDmx->Open(DMX_PSI_CHANNEL);
|
eitDmx->Open(DMX_PSI_CHANNEL);
|
||||||
eitDmx->sectionFilter(0x12, filter, mask, 4, 0 /*timeout*/, mode);
|
eitDmx->sectionFilter(0x12, filter, mask, 4, 0 /*timeout*/, mode);
|
||||||
|
updating = true;
|
||||||
|
update_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCNThread::afterWait()
|
void CCNThread::afterWait()
|
||||||
{
|
{
|
||||||
xprintf("%s: stop eit update filter (%s)\n", name.c_str(), updating ? "active" : "not active");
|
xprintf("%s: stop eit update filter (%s)\n", name.c_str(), updating ? "active" : "not active");
|
||||||
|
update_mutex.lock();
|
||||||
if (updating) {
|
if (updating) {
|
||||||
updating = false;
|
updating = false;
|
||||||
eitDmx->Close();
|
eitDmx->Close();
|
||||||
}
|
}
|
||||||
|
update_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCNThread::beforeSleep()
|
void CCNThread::beforeSleep()
|
||||||
@@ -1743,11 +1746,16 @@ void CCNThread::processSection()
|
|||||||
/* CN specific functions */
|
/* CN specific functions */
|
||||||
bool CCNThread::checkUpdate()
|
bool CCNThread::checkUpdate()
|
||||||
{
|
{
|
||||||
if (!updating)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
unsigned char buf[MAX_SECTION_LENGTH];
|
unsigned char buf[MAX_SECTION_LENGTH];
|
||||||
|
|
||||||
|
update_mutex.lock();
|
||||||
|
if (!updating) {
|
||||||
|
update_mutex.unlock();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int ret = eitDmx->Read(buf, MAX_SECTION_LENGTH, 10);
|
int ret = eitDmx->Read(buf, MAX_SECTION_LENGTH, 10);
|
||||||
|
update_mutex.unlock();
|
||||||
|
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
LongSection section(buf);
|
LongSection section(buf);
|
||||||
|
Reference in New Issue
Block a user