diff --git a/src/nhttpd/tuxboxapi/controlapi.cpp b/src/nhttpd/tuxboxapi/controlapi.cpp index b238efa63..2f2150406 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -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 diff --git a/src/nhttpd/tuxboxapi/neutrinoapi.cpp b/src/nhttpd/tuxboxapi/neutrinoapi.cpp index 8c9812a15..97f128c19 100644 --- a/src/nhttpd/tuxboxapi/neutrinoapi.cpp +++ b/src/nhttpd/tuxboxapi/neutrinoapi.cpp @@ -41,6 +41,7 @@ #include #include #include +#include extern CBouquetManager *g_bouquetManager; extern CFrontend * frontend; @@ -171,6 +172,7 @@ void CNeutrinoAPI::UpdateBouquets(void) //------------------------------------------------------------------------- void CNeutrinoAPI::ZapTo(const char * const target) { + OpenThreads::ScopedLock 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 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 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 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 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 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 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 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 ""; } - diff --git a/src/nhttpd/tuxboxapi/neutrinoapi.h b/src/nhttpd/tuxboxapi/neutrinoapi.h index 4d504eae0..6312229a1 100644 --- a/src/nhttpd/tuxboxapi/neutrinoapi.h +++ b/src/nhttpd/tuxboxapi/neutrinoapi.h @@ -15,6 +15,7 @@ #include #include "neutrinoyparser.h" #include "controlapi.h" +#include //------------------------------------------------------------------------- // No Class Helpers @@ -24,6 +25,7 @@ bool _initialize_iso639_map(void); //------------------------------------------------------------------------- class CNeutrinoAPI { + OpenThreads::Mutex mutex; // Clientlibs CSectionsdClient *Sectionsd; CZapitClient *Zapit; diff --git a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp index 9204ce4e4..5137dad85 100644 --- a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp +++ b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp @@ -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()]) ? "\"Program" : "")); + (event ? "\"Program" : "")); if (channel->getChannelID() == current_channel) yresult += string_printf("\n  \"Streaminfo\""); @@ -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); diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index 5aa76f112..b06d6e385 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -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