nhttp: re-enable threading; lock NeutrinoAPI calls

Origin commit data
------------------
Branch: ni/coolstream
Commit: 8abb547cca
Author: [CST] Focus <focus.cst@gmail.com>
Date: 2016-02-13 (Sat, 13 Feb 2016)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
[CST] Focus
2016-02-13 11:44:06 +01:00
committed by vanhofen
parent 81d121e2d5
commit d382309a5e
5 changed files with 36 additions and 11 deletions

View File

@@ -902,7 +902,9 @@ std::string CControlAPI::_GetBouquetActualEPGItem(CyhookHandler *hh, CZapitChann
CSectionsdClient::responseGetCurrentNextInfoChannelID currentNextInfo;
CChannelEvent *event;
NeutrinoAPI->mutex.lock();
event = NeutrinoAPI->ChannelListEvents[channel->getChannelID()];
NeutrinoAPI->mutex.unlock();
if (event) {
int percentage = 100;
@@ -966,7 +968,9 @@ std::string CControlAPI::_GetBouquetWriteItem(CyhookHandler *hh, CZapitChannel *
}
else {
CChannelEvent *event;
NeutrinoAPI->mutex.lock();
event = NeutrinoAPI->ChannelListEvents[channel->getChannelID()];
NeutrinoAPI->mutex.unlock();
if (event && isEPGdetails) {
result += string_printf("%u "
@@ -1599,7 +1603,9 @@ void CControlAPI::EpgCGI(CyhookHandler *hh) {
CBouquetManager::ChannelIterator cit = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->radioChannelsBegin() : g_bouquetManager->tvChannelsBegin();
for (; !(cit.EndOfChannels()); cit++) {
CZapitChannel * channel = *cit;
NeutrinoAPI->mutex.lock();
event = NeutrinoAPI->ChannelListEvents[channel->getChannelID()];
NeutrinoAPI->mutex.unlock();
if (event) {
if (!isExt) {
hh->printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS

View File

@@ -41,6 +41,7 @@
#include <zapit/bouquets.h>
#include <zapit/getservices.h>
#include <eitd/sectionsd.h>
#include <OpenThreads/ScopedLock>
extern CBouquetManager *g_bouquetManager;
extern CFrontend * frontend;
@@ -171,6 +172,7 @@ void CNeutrinoAPI::UpdateBouquets(void)
//-------------------------------------------------------------------------
void CNeutrinoAPI::ZapTo(const char * const target)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex);
t_channel_id channel_id;
sscanf(target,
@@ -182,6 +184,7 @@ void CNeutrinoAPI::ZapTo(const char * const target)
//-------------------------------------------------------------------------
void CNeutrinoAPI::ZapToChannelId(t_channel_id channel_id)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex);
if (channel_id == Zapit->getCurrentServiceID())
{
//printf("Kanal ist aktuell\n");
@@ -195,6 +198,7 @@ void CNeutrinoAPI::ZapToChannelId(t_channel_id channel_id)
void CNeutrinoAPI::ZapToSubService(const char * const target)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex);
t_channel_id channel_id;
sscanf(target,
@@ -207,6 +211,7 @@ void CNeutrinoAPI::ZapToSubService(const char * const target)
//-------------------------------------------------------------------------
t_channel_id CNeutrinoAPI::ChannelNameToChannelId(std::string search_channel_name)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex);
//FIXME depending on mode missing
//int mode = Zapit->getMode();
t_channel_id channel_id = (t_channel_id)-1;
@@ -264,6 +269,7 @@ bool CNeutrinoAPI::GetStreamInfo(int bitInfo[10])
bool CNeutrinoAPI::GetChannelEvents(void)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex);
eList.clear();
CEitManager::getInstance()->getChannelEvents(eList);
CChannelEventList::iterator eventIterator;
@@ -283,6 +289,7 @@ bool CNeutrinoAPI::GetChannelEvents(void)
std::string CNeutrinoAPI::GetServiceName(t_channel_id channel_id)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex);
return CServiceManager::getInstance()->GetServiceName(channel_id);
}
@@ -410,7 +417,8 @@ std::string CNeutrinoAPI::timerEventRepeat2Str(CTimerd::CTimerEventRepeat rep)
}
//-------------------------------------------------------------------------
std::string CNeutrinoAPI::getVideoAspectRatioAsString(void) {
std::string CNeutrinoAPI::getVideoAspectRatioAsString(void)
{
int aspectRatio = videoDecoder->getAspectRatio();
if (aspectRatio >= 0 && aspectRatio <= 4)
return videoformat_names[aspectRatio];
@@ -418,7 +426,9 @@ std::string CNeutrinoAPI::getVideoAspectRatioAsString(void) {
return "unknown";
}
//-------------------------------------------------------------------------
int CNeutrinoAPI::setVideoAspectRatioAsString(std::string newRatioString) {
int CNeutrinoAPI::setVideoAspectRatioAsString(std::string newRatioString)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex);
int newRatioInt = -1;
for(int i=0;i<(int)sizeof(videoformat_names);i++)
if( videoformat_names[i] == newRatioString){
@@ -430,7 +440,8 @@ int CNeutrinoAPI::setVideoAspectRatioAsString(std::string newRatioString) {
return newRatioInt;
}
//-------------------------------------------------------------------------
std::string CNeutrinoAPI::getVideoResolutionAsString(void) {
std::string CNeutrinoAPI::getVideoResolutionAsString(void)
{
int xres, yres, framerate;
videoDecoder->getPictureInfo(xres, yres, framerate);
std::stringstream out;
@@ -439,7 +450,8 @@ std::string CNeutrinoAPI::getVideoResolutionAsString(void) {
}
//-------------------------------------------------------------------------
std::string CNeutrinoAPI::getVideoFramerateAsString(void) {
std::string CNeutrinoAPI::getVideoFramerateAsString(void)
{
int xres, yres, framerate;
std::string sframerate="unknown";
videoDecoder->getPictureInfo(xres, yres, framerate);
@@ -453,7 +465,8 @@ std::string CNeutrinoAPI::getVideoFramerateAsString(void) {
}
//-------------------------------------------------------------------------
std::string CNeutrinoAPI::getAudioInfoAsString(void) {
std::string CNeutrinoAPI::getAudioInfoAsString(void)
{
int type, layer, freq, mode, lbitrate;
audioDecoder->getAudioInfo(type, layer, freq, lbitrate, mode);
std::stringstream out;
@@ -465,11 +478,13 @@ std::string CNeutrinoAPI::getAudioInfoAsString(void) {
}
//-------------------------------------------------------------------------
std::string CNeutrinoAPI::getCryptInfoAsString(void) {
std::string CNeutrinoAPI::getCryptInfoAsString(void)
{
std::stringstream out;
std::string casys[11]= {"Irdeto:","Betacrypt:","Seca:","Viaccess:","Nagra:","Conax: ","Cryptoworks:","Videoguard:","EBU:","XCrypt:","PowerVU:"};
int caids[] = { 0x600, 0x1700, 0x0100, 0x0500, 0x1800, 0xB00, 0xD00, 0x900, 0x2600, 0x4a00, 0x0E00 };
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(mutex);
CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel();
if(channel) {
for (unsigned short i = 0; i < 11; i++) {
@@ -485,7 +500,8 @@ std::string CNeutrinoAPI::getCryptInfoAsString(void) {
}
//-------------------------------------------------------------------------
std::string CNeutrinoAPI::getLogoFile(std::string _logoURL, t_channel_id channelId) {
std::string CNeutrinoAPI::getLogoFile(std::string _logoURL, t_channel_id channelId)
{
std::string channelIdAsString = string_printf( PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS , channelId & 0xFFFFFFFFFFFFULL);
std::string channelName = GetServiceName(channelId);
// replace(channelName, " ", "_");
@@ -505,4 +521,3 @@ std::string CNeutrinoAPI::getLogoFile(std::string _logoURL, t_channel_id channel
else
return "";
}

View File

@@ -15,6 +15,7 @@
#include <helper.h>
#include "neutrinoyparser.h"
#include "controlapi.h"
#include <OpenThreads/ScopedLock>
//-------------------------------------------------------------------------
// No Class Helpers
@@ -24,6 +25,7 @@ bool _initialize_iso639_map(void);
//-------------------------------------------------------------------------
class CNeutrinoAPI
{
OpenThreads::Mutex mutex;
// Clientlibs
CSectionsdClient *Sectionsd;
CZapitClient *Zapit;

View File

@@ -359,7 +359,9 @@ std::string CNeutrinoYParser::func_get_bouquets_with_epg(CyhookHandler *hh, std:
{
CZapitChannel * channel = channels[j];
CChannelEvent *event;
NeutrinoAPI->mutex.lock();
event = NeutrinoAPI->ChannelListEvents[channel->getChannelID()];
NeutrinoAPI->mutex.unlock();
classname = (i++ & 1) ? 'a' : 'b';
if (channel->getChannelID() == current_channel)
@@ -439,7 +441,7 @@ std::string CNeutrinoYParser::func_get_bouquets_with_epg(CyhookHandler *hh, std:
(channel->getServiceType() == ST_NVOD_REFERENCE_SERVICE) ? " (NVOD)" : "",
channel->getChannelID(),
channel->getChannelID() & 0xFFFFFFFFFFFFULL,
((NeutrinoAPI->ChannelListEvents[channel->getChannelID()]) ? "<img src=\"/images/elist.png\" alt=\"Program preview\" style=\"border: 0px\" />" : ""));
(event ? "<img src=\"/images/elist.png\" alt=\"Program preview\" style=\"border: 0px\" />" : ""));
if (channel->getChannelID() == current_channel)
yresult += string_printf("\n&nbsp;&nbsp;<a href=\"javascript:do_streaminfo()\"><img src=\"/images/streaminfo.png\" alt=\"Streaminfo\" style=\"border: 0px\" /></a>");
@@ -489,7 +491,7 @@ std::string CNeutrinoYParser::func_get_bouquets_with_epg(CyhookHandler *hh, std:
}
}
else if ((event = NeutrinoAPI->ChannelListEvents[channel->getChannelID()]))
else if (event)
{
bool has_current_next = true;
CEitManager::getInstance()->getCurrentNextServiceKey(channel->getChannelID(), currentNextInfo);

View File

@@ -62,7 +62,7 @@
//#define Y_CONFIG_FEATURE_CHROOT y // Add Feature: Use Change Root for Security
//#define Y_CONFIG_FEATURE_HTTPD_USER y // Add Feature: Set User for yhttpd-Process
#define Y_CONFIG_BUILD_AS_DAEMON y // Build as a Daemon
//#define Y_CONFIG_FEATURE_THREADING y // Build with possibility for multi threading
#define Y_CONFIG_FEATURE_THREADING y // Build with possibility for multi threading
//-----------------------------------------------------------------------------
// Define/Undefine Features forced by CONFIG_SYSTEM_xxx
// Dependencies