neutrino: various fixes and ports from the original

* avoid ambiguities in new and delete by always allocating char[]
* get rid of unused next_program_timer
* reduce code differences to original, known good neutrino code
This commit is contained in:
Stefan Seyfried
2012-03-24 20:10:30 +01:00
parent 3189f7fdc4
commit 38eb03547b
5 changed files with 66 additions and 71 deletions

View File

@@ -106,7 +106,7 @@ CRemoteControl::CRemoteControl()
selected_subchannel = -1; selected_subchannel = -1;
needs_nvods = false; needs_nvods = false;
director_mode = 0; director_mode = 0;
current_programm_timer = 0; // current_programm_timer = 0;
is_video_started = true; is_video_started = true;
} }
@@ -194,19 +194,19 @@ int CRemoteControl::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data
} }
} }
if ( msg == NeutrinoMessages::EVT_CURRENTEPG ) { if ( msg == NeutrinoMessages::EVT_CURRENTEPG )
CSectionsdClient::CurrentNextInfo* info_CN = (CSectionsdClient::CurrentNextInfo*) data; {
if ((*(t_channel_id *)data) != (current_channel_id & 0xFFFFFFFFFFFFULL) &&
(*(t_channel_id *)data) != (current_sub_channel_id & 0xFFFFFFFFFFFFULL))
return messages_return::handled;
//printf("[neutrino] got EVT_CURRENTEPG, uniqueKey %llx chid %llx flags %x\n", info_CN->current_uniqueKey, current_channel_id, info_CN->flags); const CSectionsdClient::CurrentNextInfo info_CN = g_InfoViewer->getCurrentNextInfo();
//printf("[neutrino] comparing: uniqueKey %llx chid %llx\n", info_CN->current_uniqueKey >> 16, current_channel_id & 0xFFFFFFFFFFFFULL); if ((info_CN.current_uniqueKey >> 16) == (current_channel_id & 0xFFFFFFFFFFFFULL) || (info_CN.current_uniqueKey >> 16) == (current_sub_channel_id & 0xFFFFFFFFFFFFULL))
if ( ( info_CN->current_uniqueKey >> 16) == (current_channel_id&0xFFFFFFFFFFFFULL))
{ {
//printf("[neutrino] channel match\n"); //CURRENT-EPG for current channel arrived!;
//CURRENT-EPG f<>r den aktuellen Kanal bekommen!; CVFD::getInstance()->setEPGTitle(info_CN.current_name);
CVFD::getInstance()->setEPGTitle(info_CN->current_name); if (info_CN.current_uniqueKey != current_EPGid)
if ( info_CN->current_uniqueKey != current_EPGid )
{ {
//printf("[neutrino] info_CN->current_uniqueKey != current_EPGid\n");
if ( current_EPGid != 0 ) if ( current_EPGid != 0 )
{ {
// ist nur ein neues Programm, kein neuer Kanal // ist nur ein neues Programm, kein neuer Kanal
@@ -218,58 +218,45 @@ int CRemoteControl::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data
g_InfoViewer->showEpgInfo(); g_InfoViewer->showEpgInfo();
} }
current_EPGid= info_CN->current_uniqueKey; current_EPGid = info_CN.current_uniqueKey;
if ( has_unresolved_ctags ) if ( has_unresolved_ctags )
processAPIDnames(); processAPIDnames();
if ( info_CN->flags & CSectionsdClient::epgflags::current_has_linkagedescriptors ) { if (selected_subchannel <= 0 && info_CN.flags & CSectionsdClient::epgflags::current_has_linkagedescriptors)
//printf("[neutrino] info_CN->flags have current_has_linkaged\n"); {
subChannels.clear(); subChannels.clear();
getSubChannels(); getSubChannels();
} }
if ( needs_nvods ) if ( needs_nvods )
getNVODs(); getNVODs();
g_RCInput->killTimer( current_programm_timer );
time_t end_program= info_CN->current_zeit.startzeit+ info_CN->current_zeit.dauer;
current_programm_timer = g_RCInput->addTimer( &end_program );
} }
// is_video_started is only false if channel is locked // is_video_started is only false if channel is locked
if ((!is_video_started) && if ((!is_video_started) &&
(info_CN->current_fsk == 0 || g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_CHANGETOLOCKED)) (info_CN.current_fsk == 0 || g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_CHANGETOLOCKED))
g_RCInput->postMsg(NeutrinoMessages::EVT_PROGRAMLOCKSTATUS, 0x100, false); g_RCInput->postMsg(NeutrinoMessages::EVT_PROGRAMLOCKSTATUS, 0x100, false);
else else
g_RCInput->postMsg(NeutrinoMessages::EVT_PROGRAMLOCKSTATUS, info_CN->current_fsk, false); g_RCInput->postMsg(NeutrinoMessages::EVT_PROGRAMLOCKSTATUS, info_CN.current_fsk, false);
} }
return messages_return::handled; return messages_return::handled;
} }
else if ( msg == NeutrinoMessages::EVT_NEXTEPG ) else if ( msg == NeutrinoMessages::EVT_NEXTEPG )
{ {
CSectionsdClient::CurrentNextInfo* info_CN = (CSectionsdClient::CurrentNextInfo*) data; if ((*(t_channel_id *)data) != current_channel_id)
return messages_return::handled;
if ( ( info_CN->next_uniqueKey >> 16) == (current_channel_id&0xFFFFFFFFFFFFULL) ) const CSectionsdClient::CurrentNextInfo info_CN = g_InfoViewer->getCurrentNextInfo();
if ((info_CN.next_uniqueKey >> 16) == (current_channel_id&0xFFFFFFFFFFFFULL) )
{ {
// next-EPG f<EFBFBD>r den aktuellen Kanal bekommen, current ist leider net da?!; // next-EPG for current channel arrived. no current-EPG?!
if ( info_CN->next_uniqueKey != next_EPGid ) if (info_CN.next_uniqueKey != next_EPGid)
{ next_EPGid = info_CN.next_uniqueKey;
next_EPGid= info_CN->next_uniqueKey;
// timer setzen
g_RCInput->killTimer( current_programm_timer );
time_t end_program= info_CN->next_zeit.startzeit;
current_programm_timer = g_RCInput->addTimer( &end_program );
}
} }
if ( !is_video_started ) if ( !is_video_started )
g_RCInput->postMsg( NeutrinoMessages::EVT_PROGRAMLOCKSTATUS, 0x100, false ); g_RCInput->postMsg( NeutrinoMessages::EVT_PROGRAMLOCKSTATUS, 0x100, false );
return messages_return::handled;
return messages_return::handled;
} }
else if (msg == NeutrinoMessages::EVT_NOEPG_YET) else if (msg == NeutrinoMessages::EVT_NOEPG_YET)
{ {
@@ -298,8 +285,8 @@ int CRemoteControl::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data
tuxtxt_start(current_PIDs.PIDs.vtxtpid); tuxtxt_start(current_PIDs.PIDs.vtxtpid);
} }
#endif #endif
t_channel_id * p = new t_channel_id; char *p = new char[sizeof(t_channel_id)];
*p = current_channel_id; memcpy(p, &current_channel_id, sizeof(t_channel_id));
g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOTPIDS, (const neutrino_msg_data_t)p, false); g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOTPIDS, (const neutrino_msg_data_t)p, false);
processAPIDnames(); processAPIDnames();
@@ -330,6 +317,7 @@ int CRemoteControl::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data
} }
return messages_return::handled; return messages_return::handled;
} }
#if 0
else if ( ( msg == NeutrinoMessages::EVT_TIMER ) && ( data == current_programm_timer ) ) else if ( ( msg == NeutrinoMessages::EVT_TIMER ) && ( data == current_programm_timer ) )
{ {
//printf("new program !\n"); //printf("new program !\n");
@@ -340,6 +328,7 @@ int CRemoteControl::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data
return messages_return::handled; return messages_return::handled;
} }
#endif
//else if (msg == NeutrinoMessages::EVT_ZAP_FAILED || msg == NeutrinoMessages::EVT_ZAP_SUB_FAILED) //else if (msg == NeutrinoMessages::EVT_ZAP_FAILED || msg == NeutrinoMessages::EVT_ZAP_SUB_FAILED)
//return messages_return::handled; //return messages_return::handled;
else else
@@ -372,8 +361,8 @@ void CRemoteControl::getSubChannels()
} }
copySubChannelsToZapit(); copySubChannelsToZapit();
t_channel_id * p = new t_channel_id; char *p = new char[sizeof(t_channel_id)];
*p = current_channel_id; memcpy(p, &current_channel_id, sizeof(t_channel_id));
g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOT_SUBSERVICES, (const neutrino_msg_data_t)p, false); // data is pointer to allocated memory g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOT_SUBSERVICES, (const neutrino_msg_data_t)p, false); // data is pointer to allocated memory
} }
} }
@@ -415,8 +404,8 @@ void CRemoteControl::getNVODs()
copySubChannelsToZapit(); copySubChannelsToZapit();
t_channel_id * p = new t_channel_id; char *p = new char[sizeof(t_channel_id)];
*p = current_channel_id; memcpy(p, &current_channel_id, sizeof(t_channel_id));
g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOT_SUBSERVICES, (const neutrino_msg_data_t)p, false); // data is pointer to allocated memory g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOT_SUBSERVICES, (const neutrino_msg_data_t)p, false); // data is pointer to allocated memory
if ( selected_subchannel == -1 ) if ( selected_subchannel == -1 )
@@ -562,8 +551,8 @@ void CRemoteControl::processAPIDnames()
setAPID( 0 ); setAPID( 0 );
} }
t_channel_id * p = new t_channel_id; char *p = new char[sizeof(t_channel_id)];
*p = current_channel_id; memcpy(p, &current_channel_id, sizeof(t_channel_id));
g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOTAPIDS, (const neutrino_msg_data_t)p, false); // data is pointer to allocated memory g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_GOTAPIDS, (const neutrino_msg_data_t)p, false); // data is pointer to allocated memory
} }
@@ -689,7 +678,7 @@ void CRemoteControl::zapTo_ChannelID(const t_channel_id channel_id, const std::s
g_Sectionsd->setServiceChanged( current_channel_id&0xFFFFFFFFFFFFULL, false ); g_Sectionsd->setServiceChanged( current_channel_id&0xFFFFFFFFFFFFULL, false );
zap_completion_timeout = now + 2 * (int64_t) 1000000; zap_completion_timeout = now + 2 * (int64_t) 1000000;
g_RCInput->killTimer( current_programm_timer ); // g_RCInput->killTimer( current_programm_timer );
} }
} }

View File

@@ -71,7 +71,7 @@ typedef std::vector<CSubService> CSubServiceListSorted;
class CRemoteControl class CRemoteControl
{ {
unsigned int current_programm_timer; // unsigned int current_programm_timer;
uint64_t zap_completion_timeout; uint64_t zap_completion_timeout;
std::string current_channel_name; std::string current_channel_name;
t_channel_id current_sub_channel_id; t_channel_id current_sub_channel_id;

View File

@@ -4,6 +4,9 @@
Copyright (C) 2001 Steffen Hehn 'McClean' Copyright (C) 2001 Steffen Hehn 'McClean'
Homepage: http://dbox.cyberphoria.org/ Homepage: http://dbox.cyberphoria.org/
Bugfixes/cleanups (C) 2007-2012 Stefan Seyfried
(C) 2008 Novell, Inc. Author: Stefan Seyfried
Kommentar: Kommentar:
Diese GUI wurde von Grund auf neu programmiert und sollte nun vom Diese GUI wurde von Grund auf neu programmiert und sollte nun vom
@@ -1501,43 +1504,45 @@ void CInfoViewer::showButton_SubServices ()
} }
} }
CSectionsdClient::CurrentNextInfo CInfoViewer::getEPG (const t_channel_id for_channel_id, CSectionsdClient::CurrentNextInfo &info) void CInfoViewer::getEPG(const t_channel_id for_channel_id, CSectionsdClient::CurrentNextInfo &info)
{ {
static CSectionsdClient::CurrentNextInfo oldinfo; static CSectionsdClient::CurrentNextInfo oldinfo;
//g_Sectionsd->getCurrentNextServiceKey (for_channel_id & 0xFFFFFFFFFFFFULL, info); /* to clear the oldinfo for channels without epg, call getEPG() with for_channel_id = 0 */
sectionsd_getCurrentNextServiceKey(for_channel_id & 0xFFFFFFFFFFFFULL, info); if (for_channel_id == 0)
{
oldinfo.current_uniqueKey = 0;
return;
}
//printf("CInfoViewer::getEPG: old uniqueKey %llx new %llx\n", oldinfo.current_uniqueKey, info.current_uniqueKey); sectionsd_getCurrentNextServiceKey(for_channel_id & 0xFFFFFFFFFFFFULL, info);
/* of there is no EPG, send an event so that parental lock can work */ /* of there is no EPG, send an event so that parental lock can work */
if (info.current_uniqueKey == 0 && info.next_uniqueKey == 0) { if (info.current_uniqueKey == 0 && info.next_uniqueKey == 0) {
oldinfo = info; memcpy(&oldinfo, &info, sizeof(CSectionsdClient::CurrentNextInfo));
t_channel_id *p = new t_channel_id; char *p = new char[sizeof(t_channel_id)];
*p = for_channel_id; memcpy(p, &for_channel_id, sizeof(t_channel_id));
g_RCInput->postMsg (NeutrinoMessages::EVT_NOEPG_YET, (const neutrino_msg_data_t) p, false); g_RCInput->postMsg (NeutrinoMessages::EVT_NOEPG_YET, (const neutrino_msg_data_t) p, false);
return info; return;
} }
if (info.current_uniqueKey != oldinfo.current_uniqueKey || info.next_uniqueKey != oldinfo.next_uniqueKey) { if (info.current_uniqueKey != oldinfo.current_uniqueKey || info.next_uniqueKey != oldinfo.next_uniqueKey)
if (info.flags & (CSectionsdClient::epgflags::has_current | CSectionsdClient::epgflags::has_next)) { {
CSectionsdClient::CurrentNextInfo * _info = new CSectionsdClient::CurrentNextInfo; char *p = new char[sizeof(t_channel_id)];
*_info = info; memcpy(p, &for_channel_id, sizeof(t_channel_id));
neutrino_msg_t msg; neutrino_msg_t msg;
if (info.flags & (CSectionsdClient::epgflags::has_current | CSectionsdClient::epgflags::has_next))
{
if (info.flags & CSectionsdClient::epgflags::has_current) if (info.flags & CSectionsdClient::epgflags::has_current)
msg = NeutrinoMessages::EVT_CURRENTEPG; msg = NeutrinoMessages::EVT_CURRENTEPG;
else else
msg = NeutrinoMessages::EVT_NEXTEPG; msg = NeutrinoMessages::EVT_NEXTEPG;
g_RCInput->postMsg(msg, (unsigned) _info, false );
} else {
t_channel_id *p = new t_channel_id;
*p = for_channel_id;
g_RCInput->postMsg (NeutrinoMessages::EVT_NOEPG_YET, (const neutrino_msg_data_t) p, false); // data is pointer to allocated memory
} }
oldinfo = info; else
msg = NeutrinoMessages::EVT_NOEPG_YET;
g_RCInput->postMsg(msg, (const neutrino_msg_data_t)p, false); // data is pointer to allocated memory
memcpy(&oldinfo, &info, sizeof(CSectionsdClient::CurrentNextInfo));
} }
return info;
} }
void CInfoViewer::showSNR () void CInfoViewer::showSNR ()

View File

@@ -177,7 +177,8 @@ class CInfoViewer
void showTitle(const int ChanNum, const std::string & Channel, const t_satellite_position satellitePosition, const t_channel_id new_channel_id = 0, const bool calledFromNumZap = false, int epgpos = 0); // Channel must be UTF-8 encoded void showTitle(const int ChanNum, const std::string & Channel, const t_satellite_position satellitePosition, const t_channel_id new_channel_id = 0, const bool calledFromNumZap = false, int epgpos = 0); // Channel must be UTF-8 encoded
void lookAheadEPG(const int ChanNum, const std::string & Channel, const t_channel_id new_channel_id = 0, const bool calledFromNumZap = false); //alpha: fix for nvod subchannel update void lookAheadEPG(const int ChanNum, const std::string & Channel, const t_channel_id new_channel_id = 0, const bool calledFromNumZap = false); //alpha: fix for nvod subchannel update
void killTitle(); void killTitle();
CSectionsdClient::CurrentNextInfo getEPG(const t_channel_id for_channel_id, CSectionsdClient::CurrentNextInfo &info); void getEPG(const t_channel_id for_channel_id, CSectionsdClient::CurrentNextInfo &info);
CSectionsdClient::CurrentNextInfo getCurrentNextInfo() const { return info_CurrentNext; }
void showSubchan(); void showSubchan();
void Set_CA_Status(int Status); void Set_CA_Status(int Status);

View File

@@ -2311,7 +2311,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
if( res != messages_return::unhandled ) { if( res != messages_return::unhandled ) {
if( ( msg>= CRCInput::RC_WithData ) && ( msg< CRCInput::RC_WithData+ 0x10000000 ) ) if( ( msg>= CRCInput::RC_WithData ) && ( msg< CRCInput::RC_WithData+ 0x10000000 ) )
delete (unsigned char*) data; delete[] (unsigned char*) data;
return( res & ( 0xFFFFFFFF - messages_return::unhandled ) ); return( res & ( 0xFFFFFFFF - messages_return::unhandled ) );
} }