mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 15:32:52 +02:00
bouquets: rework logo thread handling
Origin commit data
------------------
Branch: ni/coolstream
Commit: f1ede58ba6
Author: TangoCash <eric@loxat.de>
Date: 2021-09-17 (Fri, 17 Sep 2021)
Origin message was:
------------------
- bouquets: rework logo thread handling
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -10,9 +10,12 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <list>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <OpenThreads/Thread>
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <zapit/client/zapitclient.h>
|
#include <zapit/client/zapitclient.h>
|
||||||
|
|
||||||
@@ -91,7 +94,7 @@ class CZapitBouquet
|
|||||||
|
|
||||||
typedef std::vector<CZapitBouquet *> BouquetList;
|
typedef std::vector<CZapitBouquet *> BouquetList;
|
||||||
|
|
||||||
class CBouquetManager
|
class CBouquetManager : public OpenThreads::Thread
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
CZapitBouquet * remainChannels;
|
CZapitBouquet * remainChannels;
|
||||||
@@ -113,11 +116,13 @@ class CBouquetManager
|
|||||||
void convert_E2_EPGMapping(std::string mapfile_in, std::string mapfile_out = "/tmp/epgmap.xml");
|
void convert_E2_EPGMapping(std::string mapfile_in, std::string mapfile_out = "/tmp/epgmap.xml");
|
||||||
void dump_EPGMapping(std::string mapfile_out = "/tmp/epgmap.xml");
|
void dump_EPGMapping(std::string mapfile_out = "/tmp/epgmap.xml");
|
||||||
//logo downloads
|
//logo downloads
|
||||||
static void* LogoThread(void* _logolist);
|
void run();
|
||||||
pthread_t thrLogo;
|
bool LogoStart();
|
||||||
ZapitChannelList LogoList;
|
bool LogoStop();
|
||||||
|
bool logo_running;
|
||||||
|
std::list<t_channel_id> LogoList;
|
||||||
public:
|
public:
|
||||||
CBouquetManager() { remainChannels = NULL; thrLogo = 0; };
|
CBouquetManager() { remainChannels = NULL; logo_running = false; };
|
||||||
~CBouquetManager();
|
~CBouquetManager();
|
||||||
class ChannelIterator
|
class ChannelIterator
|
||||||
{
|
{
|
||||||
|
@@ -62,7 +62,6 @@
|
|||||||
|
|
||||||
extern CBouquetManager *g_bouquetManager;
|
extern CBouquetManager *g_bouquetManager;
|
||||||
extern CPictureViewer *g_PicViewer;
|
extern CPictureViewer *g_PicViewer;
|
||||||
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
|
|
||||||
#define GET_ATTR(node, name, fmt, arg) \
|
#define GET_ATTR(node, name, fmt, arg) \
|
||||||
do { \
|
do { \
|
||||||
@@ -537,7 +536,6 @@ void CBouquetManager::loadBouquets(bool ignoreBouquetFile)
|
|||||||
CNeutrinoApp::getInstance()->g_settings_xmltv_xml_auto_clear();
|
CNeutrinoApp::getInstance()->g_settings_xmltv_xml_auto_clear();
|
||||||
loadWebtv();
|
loadWebtv();
|
||||||
loadWebradio();
|
loadWebradio();
|
||||||
loadLogos();
|
|
||||||
parseBouquetsXml(UBOUQUETS_XML, true);
|
parseBouquetsXml(UBOUQUETS_XML, true);
|
||||||
renumServices();
|
renumServices();
|
||||||
CServiceManager::getInstance()->SetCIFilter();
|
CServiceManager::getInstance()->SetCIFilter();
|
||||||
@@ -547,6 +545,7 @@ void CBouquetManager::loadBouquets(bool ignoreBouquetFile)
|
|||||||
if(!EpgXMLMapping.empty()){
|
if(!EpgXMLMapping.empty()){
|
||||||
EpgXMLMapping.clear();
|
EpgXMLMapping.clear();
|
||||||
}
|
}
|
||||||
|
LogoStart();
|
||||||
TIMER_STOP("[zapit] bouquet loading took");
|
TIMER_STOP("[zapit] bouquet loading took");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -810,6 +809,9 @@ void CBouquetManager::moveBouquet(const unsigned int oldId, const unsigned int n
|
|||||||
|
|
||||||
void CBouquetManager::clearAll(bool user)
|
void CBouquetManager::clearAll(bool user)
|
||||||
{
|
{
|
||||||
|
LogoStop();
|
||||||
|
LogoList.clear();
|
||||||
|
|
||||||
BouquetList tmplist;
|
BouquetList tmplist;
|
||||||
for (unsigned int i =0; i < Bouquets.size(); i++) {
|
for (unsigned int i =0; i < Bouquets.size(); i++) {
|
||||||
if (user || !Bouquets[i]->bUser)
|
if (user || !Bouquets[i]->bUser)
|
||||||
@@ -822,15 +824,6 @@ void CBouquetManager::clearAll(bool user)
|
|||||||
if (!user)
|
if (!user)
|
||||||
Bouquets = tmplist;
|
Bouquets = tmplist;
|
||||||
remainChannels = NULL;
|
remainChannels = NULL;
|
||||||
if(thrLogo != 0)
|
|
||||||
{
|
|
||||||
pthread_cancel(thrLogo);
|
|
||||||
pthread_join(thrLogo, NULL);
|
|
||||||
thrLogo = 0;
|
|
||||||
}
|
|
||||||
pthread_mutex_lock (&mutex);
|
|
||||||
LogoList.clear();
|
|
||||||
pthread_mutex_unlock (&mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBouquetManager::deletePosition(t_satellite_position satellitePosition)
|
void CBouquetManager::deletePosition(t_satellite_position satellitePosition)
|
||||||
@@ -994,9 +987,7 @@ void CBouquetManager::loadWebchannels(int mode)
|
|||||||
if (alogo && !g_PicViewer->GetLogoName(chid, std::string(title), helper))
|
if (alogo && !g_PicViewer->GetLogoName(chid, std::string(title), helper))
|
||||||
{
|
{
|
||||||
channel->setAlternateLogo(std::string(alogo));
|
channel->setAlternateLogo(std::string(alogo));
|
||||||
pthread_mutex_lock (&mutex);
|
LogoList.push_back(chid);
|
||||||
LogoList.push_back(channel);
|
|
||||||
pthread_mutex_unlock (&mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
channel->flags = CZapitChannel::UPDATED;
|
channel->flags = CZapitChannel::UPDATED;
|
||||||
@@ -1040,7 +1031,7 @@ void CBouquetManager::loadWebchannels(int mode)
|
|||||||
{
|
{
|
||||||
epg_url = "";
|
epg_url = "";
|
||||||
epg_url = ReadMarkerValue(strLine, M3U_START_EPG_MARKER);
|
epg_url = ReadMarkerValue(strLine, M3U_START_EPG_MARKER);
|
||||||
printf("tvg-url: %s\n", epg_url.c_str());
|
//printf("tvg-url: %s\n", epg_url.c_str());
|
||||||
if (!epg_url.empty())
|
if (!epg_url.empty())
|
||||||
{
|
{
|
||||||
if (epg_url.find_first_of(',') != std::string::npos)
|
if (epg_url.find_first_of(',') != std::string::npos)
|
||||||
@@ -1132,9 +1123,7 @@ void CBouquetManager::loadWebchannels(int mode)
|
|||||||
if (!alogo.empty() && !g_PicViewer->GetLogoName(chid, title, helper))
|
if (!alogo.empty() && !g_PicViewer->GetLogoName(chid, title, helper))
|
||||||
{
|
{
|
||||||
channel->setAlternateLogo(alogo);
|
channel->setAlternateLogo(alogo);
|
||||||
pthread_mutex_lock (&mutex);
|
LogoList.push_back(chid);
|
||||||
LogoList.push_back(channel);
|
|
||||||
pthread_mutex_unlock (&mutex);
|
|
||||||
}
|
}
|
||||||
channel->flags = CZapitChannel::UPDATED;
|
channel->flags = CZapitChannel::UPDATED;
|
||||||
if (gbouquet)
|
if (gbouquet)
|
||||||
@@ -1252,36 +1241,57 @@ void CBouquetManager::loadWebchannels(int mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBouquetManager::loadLogos()
|
bool CBouquetManager::LogoStart()
|
||||||
{
|
{
|
||||||
|
if (logo_running)
|
||||||
|
return false;
|
||||||
|
if (LogoList.size() == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
if(thrLogo != 0)
|
logo_running = true;
|
||||||
{
|
return (OpenThreads::Thread::start() == 0);
|
||||||
pthread_cancel(thrLogo);
|
|
||||||
pthread_join(thrLogo, NULL);
|
|
||||||
thrLogo = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LogoList.size() > 0)
|
bool CBouquetManager::LogoStop()
|
||||||
pthread_create(&thrLogo, NULL, LogoThread, (void*)&LogoList);
|
{
|
||||||
|
if (!logo_running)
|
||||||
|
return false;
|
||||||
|
logo_running = false;
|
||||||
|
return (OpenThreads::Thread::join() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* CBouquetManager::LogoThread(void* _logolist)
|
void CBouquetManager::run()
|
||||||
{
|
{
|
||||||
set_threadname(__func__);
|
set_threadname(__func__);
|
||||||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
|
//printf(">>>>>> LogoThread [%s] started...\n",__func__);
|
||||||
pthread_mutex_lock (&mutex);
|
CZapitChannel *cc = NULL;
|
||||||
ZapitChannelList *LogoList = (ZapitChannelList *)_logolist;
|
std::string ologo;
|
||||||
for (ZapitChannelList::iterator it = LogoList->begin(); it != LogoList->end(); ++it)
|
std::string nlogo;
|
||||||
|
t_channel_id chid = 0;
|
||||||
|
std::list<t_channel_id>::iterator it = LogoList.begin();
|
||||||
|
while (logo_running && it != LogoList.end())
|
||||||
{
|
{
|
||||||
CZapitChannel *cc = (*it);
|
chid = (*it);
|
||||||
if (cc)
|
cc = CServiceManager::getInstance()->FindChannel(chid);
|
||||||
cc->setAlternateLogo(downloadUrlToLogo(cc->getAlternateLogo(), LOGODIR_TMP, cc->getChannelID()));
|
if (logo_running && cc)
|
||||||
|
ologo = cc->getAlternateLogo();
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
cc = CServiceManager::getInstance()->FindChannel(chid);
|
||||||
|
if (logo_running && cc)
|
||||||
|
nlogo = downloadUrlToLogo(ologo, LOGODIR_TMP, chid);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
cc = CServiceManager::getInstance()->FindChannel(chid);
|
||||||
|
if (logo_running && cc)
|
||||||
|
cc->setAlternateLogo(nlogo);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
it++;
|
||||||
}
|
}
|
||||||
LogoList->clear();
|
LogoList.clear();
|
||||||
pthread_mutex_unlock(&mutex);
|
logo_running = false;
|
||||||
pthread_exit(0);
|
//printf(">>>>>>> LogoThread [%s] stopped...\n",__func__);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CBouquetManager::ChannelIterator::ChannelIterator(CBouquetManager* owner, const bool TV)
|
CBouquetManager::ChannelIterator::ChannelIterator(CBouquetManager* owner, const bool TV)
|
||||||
|
Reference in New Issue
Block a user