mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
- partly revert e855ceef8e5a3719be4252aa5c5ef4be561d72d5; ...
... "copy event to prevent crash in multi-threaded mode"
This commit is contained in:
@@ -1045,35 +1045,32 @@ std::string CControlAPI::_GetBouquetActualEPGItem(CyhookHandler *hh, CZapitChann
|
|||||||
CShortEPGData epg;
|
CShortEPGData epg;
|
||||||
|
|
||||||
CSectionsdClient::responseGetCurrentNextInfoChannelID currentNextInfo;
|
CSectionsdClient::responseGetCurrentNextInfoChannelID currentNextInfo;
|
||||||
CChannelEvent event;
|
CChannelEvent *event;
|
||||||
event.eventID = 0;
|
|
||||||
NeutrinoAPI->Lock();
|
NeutrinoAPI->Lock();
|
||||||
CChannelEvent * evt = NeutrinoAPI->ChannelListEvents[channel->getChannelID()];
|
event = NeutrinoAPI->ChannelListEvents[channel->getChannelID()];
|
||||||
if (evt)
|
|
||||||
event = *evt;
|
|
||||||
NeutrinoAPI->Unlock();
|
NeutrinoAPI->Unlock();
|
||||||
|
|
||||||
bool return_epginfo = (hh->ParamList["epginfo"] != "false");
|
bool return_epginfo = (hh->ParamList["epginfo"] != "false");
|
||||||
|
|
||||||
result += hh->outPair("isActiveChannel", (channel->getChannelID() == current_channel) ? "true" : "false", false);
|
result += hh->outPair("isActiveChannel", (channel->getChannelID() == current_channel) ? "true" : "false", false);
|
||||||
|
|
||||||
if (event.eventID) {
|
if (event) {
|
||||||
int percentage = 100;
|
int percentage = 100;
|
||||||
if (event.duration > 0)
|
if (event->duration > 0)
|
||||||
percentage = 100 * (time(NULL) - event.startTime) / event.duration;
|
percentage = 100 * (time(NULL) - event->startTime) / event->duration;
|
||||||
CEitManager::getInstance()->getCurrentNextServiceKey(channel->getChannelID(), currentNextInfo);
|
CEitManager::getInstance()->getCurrentNextServiceKey(channel->getChannelID(), currentNextInfo);
|
||||||
timestr = timeString(event.startTime);
|
timestr = timeString(event->startTime);
|
||||||
|
|
||||||
firstEPG += hh->outPair("eventid", string_printf("%llu", currentNextInfo.current_uniqueKey), true);
|
firstEPG += hh->outPair("eventid", string_printf("%llu", currentNextInfo.current_uniqueKey), true);
|
||||||
firstEPG += hh->outPair("description", hh->outValue(event.description), true);
|
firstEPG += hh->outPair("description", hh->outValue(event->description), true);
|
||||||
if (return_epginfo && CEitManager::getInstance()->getEPGidShort(currentNextInfo.current_uniqueKey, &epg))
|
if (return_epginfo && CEitManager::getInstance()->getEPGidShort(currentNextInfo.current_uniqueKey, &epg))
|
||||||
{
|
{
|
||||||
firstEPG += hh->outPair("info1", hh->outValue(epg.info1), true);
|
firstEPG += hh->outPair("info1", hh->outValue(epg.info1), true);
|
||||||
firstEPG += hh->outPair("info2", hh->outValue(epg.info2), true);
|
firstEPG += hh->outPair("info2", hh->outValue(epg.info2), true);
|
||||||
}
|
}
|
||||||
firstEPG += hh->outPair("startTime", timestr, true);
|
firstEPG += hh->outPair("startTime", timestr, true);
|
||||||
firstEPG += hh->outPair("timeTotal", string_printf("%d", event.duration / 60), true);
|
firstEPG += hh->outPair("timeTotal", string_printf("%d", event->duration / 60), true);
|
||||||
firstEPG += hh->outPair("timeElapsed", string_printf("%d", (time(NULL) - event.startTime) / 60), true);
|
firstEPG += hh->outPair("timeElapsed", string_printf("%d", (time(NULL) - event->startTime) / 60), true);
|
||||||
firstEPG += hh->outPair("percentage", string_printf("%d", percentage), false);
|
firstEPG += hh->outPair("percentage", string_printf("%d", percentage), false);
|
||||||
|
|
||||||
if (currentNextInfo.flags & CSectionsdClient::epgflags::has_next) {
|
if (currentNextInfo.flags & CSectionsdClient::epgflags::has_next) {
|
||||||
@@ -1126,21 +1123,18 @@ std::string CControlAPI::_GetBouquetWriteItem(CyhookHandler *hh, CZapitChannel *
|
|||||||
result = hh->outArrayItem("channel", result, false);
|
result = hh->outArrayItem("channel", result, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CChannelEvent event;
|
CChannelEvent *event;
|
||||||
event.eventID = 0;
|
|
||||||
NeutrinoAPI->Lock();
|
NeutrinoAPI->Lock();
|
||||||
CChannelEvent * evt = NeutrinoAPI->ChannelListEvents[channel->getChannelID()];
|
event = NeutrinoAPI->ChannelListEvents[channel->getChannelID()];
|
||||||
if (evt)
|
|
||||||
event = *evt;
|
|
||||||
NeutrinoAPI->Unlock();
|
NeutrinoAPI->Unlock();
|
||||||
|
|
||||||
if (event.eventID && isEPGdetails) {
|
if (event && isEPGdetails) {
|
||||||
result += string_printf("%u "
|
result += string_printf("%u "
|
||||||
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
||||||
" %s (%s)\n",
|
" %s (%s)\n",
|
||||||
channelNr,
|
channelNr,
|
||||||
channel->getChannelID(),
|
channel->getChannelID(),
|
||||||
channel->getName().c_str(), event.description.c_str());
|
channel->getName().c_str(), event->description.c_str());
|
||||||
} else {
|
} else {
|
||||||
result += string_printf("%u "
|
result += string_printf("%u "
|
||||||
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
||||||
@@ -1847,27 +1841,24 @@ void CControlAPI::EpgCGI(CyhookHandler *hh) {
|
|||||||
else if (param_empty || hh->ParamList["1"] == "ext") {
|
else if (param_empty || hh->ParamList["1"] == "ext") {
|
||||||
hh->SetHeader(HTTP_OK, "text/plain; charset=UTF-8");
|
hh->SetHeader(HTTP_OK, "text/plain; charset=UTF-8");
|
||||||
bool isExt = (hh->ParamList["1"] == "ext");
|
bool isExt = (hh->ParamList["1"] == "ext");
|
||||||
CChannelEvent event;
|
CChannelEvent *event = NULL;
|
||||||
NeutrinoAPI->GetChannelEvents();
|
NeutrinoAPI->GetChannelEvents();
|
||||||
|
|
||||||
int mode = NeutrinoAPI->Zapit->getMode();
|
int mode = NeutrinoAPI->Zapit->getMode();
|
||||||
CBouquetManager::ChannelIterator cit = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->radioChannelsBegin() : g_bouquetManager->tvChannelsBegin();
|
CBouquetManager::ChannelIterator cit = mode == CZapitClient::MODE_RADIO ? g_bouquetManager->radioChannelsBegin() : g_bouquetManager->tvChannelsBegin();
|
||||||
for (; !(cit.EndOfChannels()); cit++) {
|
for (; !(cit.EndOfChannels()); cit++) {
|
||||||
CZapitChannel * channel = *cit;
|
CZapitChannel * channel = *cit;
|
||||||
event.eventID = 0;
|
|
||||||
NeutrinoAPI->Lock();
|
NeutrinoAPI->Lock();
|
||||||
CChannelEvent * evt = NeutrinoAPI->ChannelListEvents[channel->getChannelID()];
|
event = NeutrinoAPI->ChannelListEvents[channel->getChannelID()];
|
||||||
if (evt)
|
|
||||||
event = *evt;
|
|
||||||
NeutrinoAPI->Unlock();
|
NeutrinoAPI->Unlock();
|
||||||
if (event.eventID) {
|
if (event) {
|
||||||
if (!isExt) {
|
if (!isExt) {
|
||||||
hh->printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
hh->printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
||||||
" %llu %s\n", channel->getChannelID(), event.eventID, event.description.c_str());
|
" %llu %s\n", channel->getChannelID(), event->eventID, event->description.c_str());
|
||||||
}
|
}
|
||||||
else { // ext output
|
else { // ext output
|
||||||
hh->printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
hh->printf(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS
|
||||||
" %ld %u %llu %s\n", channel->getChannelID(), event.startTime, event.duration, event.eventID, event.description.c_str());
|
" %ld %u %llu %s\n", channel->getChannelID(), event->startTime, event->duration, event->eventID, event->description.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user