Merge branch 'dvbsi++' of coolstreamtech.de:cst-private-neutrino into neutrino-apollo

Conflicts:
	src/neutrino.cpp
This commit is contained in:
[CST] Bas
2012-11-13 12:51:18 +08:00
151 changed files with 3208 additions and 1867 deletions

View File

@@ -56,6 +56,7 @@
#include <driver/record.h>
#include <driver/screenshot.h>
#include <driver/volume.h>
#include <driver/streamts.h>
#include "gui/audioplayer.h"
#include "gui/bouquetlist.h"
@@ -133,10 +134,6 @@ t_channel_id standby_channel_id;
static pthread_t timer_thread;
void * timerd_main_thread(void *data);
extern int streamts_stop;
void * streamts_main_thread(void *data);
static pthread_t stream_thread ;
void * nhttpd_main_thread(void *data);
static pthread_t nhttpd_thread ;
@@ -188,27 +185,6 @@ extern const char * locale_real_names[]; /* #include <system/locals_intern.h> */
// USERMENU
const char* usermenu_button_def[SNeutrinoSettings::BUTTON_MAX]={"red","green","yellow","blue"};
static void initGlobals(void)
{
g_fontRenderer = NULL;
g_RCInput = NULL;
g_Timerd = NULL;
g_RemoteControl = NULL;
g_EpgData = NULL;
g_InfoViewer = NULL;
g_EventList = NULL;
g_videoSettings = NULL;
g_Locale = new CLocaleManager;
g_PluginList = NULL;
InfoClock = NULL;
g_CamHandler = NULL;
g_Radiotext = NULL;
g_volume = NULL;
}
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ CNeutrinoApp - Constructor, initialize g_fontRenderer +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
@@ -227,6 +203,7 @@ CNeutrinoApp::CNeutrinoApp()
TVchannelList = NULL;
RADIOchannelList = NULL;
skipShutdownTimer = false;
skipSleepTimer = false;
current_muted = 0;
recordingstatus = 0;
g_channel_list_changed = 0;
@@ -567,7 +544,9 @@ int CNeutrinoApp::loadSetup(const char * fname)
std::string filename = e->d_name;
if ((filename.find("_temp.ts") == filename.size() - 8) || (filename.find("_temp.xml") == filename.size() - 9))
{
remove(filename.c_str());
std::string timeshiftDir_filename= timeshiftDir;
timeshiftDir_filename+= "/" + filename;
remove(timeshiftDir_filename.c_str());
}
}
closedir(d);
@@ -582,14 +561,15 @@ int CNeutrinoApp::loadSetup(const char * fname)
g_settings.recording_stopsectionsd = configfile.getBool("recording_stopsectionsd" , false );
g_settings.recording_audio_pids_default = configfile.getInt32("recording_audio_pids_default", TIMERD_APIDS_STD | TIMERD_APIDS_AC3);
g_settings.recording_zap_on_announce = configfile.getBool("recording_zap_on_announce" , false);
g_settings.shutdown_timer_record_type = configfile.getBool("shutdown_timer_record_type" , false);
g_settings.shutdown_timer_record_type = configfile.getBool("shutdown_timer_record_type" , false);
g_settings.recording_stream_vtxt_pid = configfile.getBool("recordingmenu.stream_vtxt_pid" , false);
g_settings.recording_stream_pmt_pid = configfile.getBool("recordingmenu.stream_pmt_pid" , false);
g_settings.recording_choose_direct_rec_dir = configfile.getInt32( "recording_choose_direct_rec_dir", 0 );
g_settings.recording_epg_for_filename = configfile.getBool("recording_epg_for_filename" , true);
g_settings.recording_epg_for_end = configfile.getBool("recording_epg_for_end" , false);
g_settings.recording_save_in_channeldir = configfile.getBool("recording_save_in_channeldir" , false);
g_settings.recording_save_in_channeldir = configfile.getBool("recording_save_in_channeldir" , false);
g_settings.recording_slow_warning = configfile.getBool("recording_slow_warning" , true);
// default plugin for movieplayer
g_settings.movieplayer_plugin = configfile.getString( "movieplayer_plugin", "Teletext" );
@@ -1004,6 +984,7 @@ void CNeutrinoApp::saveSetup(const char * fname)
configfile.setBool ("recording_epg_for_filename" , g_settings.recording_epg_for_filename );
configfile.setBool ("recording_epg_for_end" , g_settings.recording_epg_for_end );
configfile.setBool ("recording_save_in_channeldir" , g_settings.recording_save_in_channeldir );
configfile.setBool ("recording_slow_warning" , g_settings.recording_slow_warning );
// default plugin for movieplayer
configfile.setString ( "movieplayer_plugin", g_settings.movieplayer_plugin );
@@ -1261,16 +1242,6 @@ void CNeutrinoApp::channelsInit(bool bOnly)
}
}
printf("[neutrino] created %s bouquet with %d TV and %d RADIO channels\n", sit->second.name.c_str(), tvi, ri);
#if 0
if(tvi)
tmp1->channelList->SortAlpha();
else
TVsatList->deleteBouquet(tmp1);
if(ri)
tmp2->channelList->SortAlpha();
else
RADIOsatList->deleteBouquet(tmp2);
#endif
if(!tvi)
TVsatList->deleteBouquet(tmp1);
if(!ri)
@@ -1618,13 +1589,10 @@ void CNeutrinoApp::InitZapper()
channelsInit();
if(tvmode)
{
tvMode(true);
} else {
g_RCInput->killTimer(g_InfoViewer->lcdUpdateTimer);
g_InfoViewer->lcdUpdateTimer = g_RCInput->addTimer( LCD_UPDATE_TIME_RADIO_MODE, false );
else
radioMode(true);
}
if(g_settings.cacheTXT)
tuxtxt_init();
@@ -1677,11 +1645,6 @@ void CNeutrinoApp::InitZapitClient()
CZapitClient::EVT_ZAP_SUB_COMPLETE,
CZapitClient::EVT_ZAP_SUB_FAILED,
CZapitClient::EVT_ZAP_MOTOR,
#if 0
CZapitClient::EVT_ZAP_CA_CLEAR,
CZapitClient::EVT_ZAP_CA_LOCK,
CZapitClient::EVT_ZAP_CA_FTA,
#endif
CZapitClient::EVT_ZAP_CA_ID,
CZapitClient::EVT_RECORDMODE_ACTIVATED,
CZapitClient::EVT_RECORDMODE_DEACTIVATED,
@@ -1697,9 +1660,6 @@ void CNeutrinoApp::InitZapitClient()
CZapitClient::EVT_BOUQUETS_CHANGED,
CZapitClient::EVT_SERVICES_CHANGED,
CZapitClient::EVT_SCAN_SERVICENAME,
#if 0
CZapitClient::EVT_SCAN_FOUND_A_CHAN,
#endif
CZapitClient::EVT_SCAN_FOUND_TV_CHAN,
CZapitClient::EVT_SCAN_FOUND_RADIO_CHAN,
CZapitClient::EVT_SCAN_FOUND_DATA_CHAN,
@@ -1747,10 +1707,9 @@ void wake_up( bool &wakeup)
}
printf("[timerd] wakeup from standby: %s\n", wakeup ? "yes" : "no");
if(!wakeup){
const char *neutrino_leave_deepstandby_script = CONFIGDIR "/deepstandby.off";
printf("[%s] executing %s\n",__FILE__ ,neutrino_leave_deepstandby_script);
if (my_system(neutrino_leave_deepstandby_script) != 0)
perror( neutrino_leave_deepstandby_script );
puts("[neutrino.cpp] executing " NEUTRINO_LEAVE_DEEPSTANDBY_SCRIPT ".");
if (my_system(NEUTRINO_LEAVE_DEEPSTANDBY_SCRIPT) != 0)
perror(NEUTRINO_LEAVE_DEEPSTANDBY_SCRIPT " failed");
}
#endif
@@ -1764,6 +1723,8 @@ TIMER_START();
cs_api_init();
cs_register_messenger(CSSendMessage);
g_Locale = new CLocaleManager;
int loadSettingsErg = loadSetup(NEUTRINO_SETTINGS_FILE);
initialize_iso639_map();
@@ -1780,8 +1741,7 @@ TIMER_START();
SetupFonts();
SetupTiming();
g_PicViewer = new CPictureViewer();
colorSetupNotifier = new CColorSetupNotifier;
colorSetupNotifier->changeNotify(NONEXISTANT_LOCALE, NULL);
CColorSetupNotifier::setPalette();
CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_NEUTRINO_STARTING));
hintBox->paint();
@@ -1853,17 +1813,14 @@ TIMER_START();
#endif
dprintf(DEBUG_NORMAL, "g_info.has_fan: %d\n", g_info.has_fan);
//fan speed
if (g_info.has_fan) {
CFanControlNotifier * funNotifier= new CFanControlNotifier();
funNotifier->changeNotify(NONEXISTANT_LOCALE, (void*) &g_settings.fan_speed);
delete funNotifier;
}
if (g_info.has_fan)
CFanControlNotifier::setSpeed(g_settings.fan_speed);
dvbsub_init();
pthread_create (&nhttpd_thread, NULL, nhttpd_main_thread, (void *) NULL);
pthread_create (&stream_thread, NULL, streamts_main_thread, (void *) NULL);
CStreamManager::getInstance()->Start();
#ifndef DISABLE_SECTIONSD
CSectionsdClient::epg_config config;
@@ -1884,9 +1841,6 @@ TIMER_START();
g_InfoViewer = new CInfoViewer;
g_EventList = new CNeutrinoEventList;
int dx, dy;
frameBuffer->getIconSize(NEUTRINO_ICON_VOLUME, &dx, &dy);
g_CamHandler = new CCAMMenuHandler();
g_CamHandler->init();
@@ -1965,14 +1919,8 @@ void CNeutrinoApp::quickZap(int msg)
int res;
StopSubtitles();
#if 0
CRecordManager::getInstance()->StopAutoRecord();
if(CRecordManager::getInstance()->RecordingStatus())
#else
//if(recordingstatus && !autoshift)
printf("CNeutrinoApp::quickZap haveFreeFrontend %d\n", CFEManager::getInstance()->haveFreeFrontend());
if(!CFEManager::getInstance()->haveFreeFrontend())
#endif
{
res = channelList->numericZap(g_settings.key_zaphistory);
StartSubtitles(res < 0);
@@ -2166,6 +2114,33 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu)
else
ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10);
}
else if ((msg == CRCInput::RC_audio) && !g_settings.audio_run_player)
{
StopSubtitles();
usermenu.showUserMenu(SNeutrinoSettings::BUTTON_GREEN);
StartSubtitles();
}
else if( msg == CRCInput::RC_green)
{
if (g_settings.personalize[SNeutrinoSettings::P_MAIN_GREEN_BUTTON] == CPersonalizeGui::PERSONALIZE_ACTIVE_MODE_ENABLED)
{
StopSubtitles();
usermenu.showUserMenu(SNeutrinoSettings::BUTTON_GREEN);
StartSubtitles();
}
else
ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10);
}
else if( msg == CRCInput::RC_yellow ) { // NVODs
if (g_settings.personalize[SNeutrinoSettings::P_MAIN_YELLOW_BUTTON] == CPersonalizeGui::PERSONALIZE_ACTIVE_MODE_ENABLED)
{
StopSubtitles();
usermenu.showUserMenu(SNeutrinoSettings::BUTTON_YELLOW);
StartSubtitles();
}
else
ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10);
}
else if( (msg == CRCInput::RC_green) || ((msg == CRCInput::RC_audio) && !g_settings.audio_run_player) )
{
StopSubtitles();
@@ -2255,13 +2230,6 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
if(g_settings.audio_AnalogMode < 0 || g_settings.audio_AnalogMode > 2)
g_settings.audio_AnalogMode = 0;
#if 0 // per-channel auto volume save/restore
unsigned int volume;
g_Zapit->getVolume(&volume, &volume);
current_volume = 100 - volume*100/63;
printf("zapit volume %d new current %d mode %d\n", volume, current_volume, g_settings.audio_AnalogMode);
g_volume->setvol(current_volume);
#endif
g_RCInput->killTimer(scrambled_timer);
scrambled_timer = g_RCInput->addTimer(10*1000*1000, true);
@@ -2289,7 +2257,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
if( res != messages_return::unhandled ) {
if( ( msg>= CRCInput::RC_WithData ) && ( msg< CRCInput::RC_WithData+ 0x10000000 ) )
delete (unsigned char*) data;
delete[] (unsigned char*) data;
return( res & ( 0xFFFFFFFF - messages_return::unhandled ) );
}
@@ -2345,7 +2313,7 @@ _repeat:
SetChannelMode(old_mode);
bouquetList->activateBouquet(old_b, false);
if(!bouquetList->Bouquets.empty())
bouquetList->Bouquets[old_b]->channelList->setSelected(old_num);
bouquetList->Bouquets[bouquetList->getActiveBouquetNumber()]->channelList->setSelected(old_num);
StartSubtitles(mode == mode_tv);
}
else if(nNewChannel == -3) { // list mode changed
@@ -2537,12 +2505,7 @@ _repeat:
}
#endif
else if( msg == NeutrinoMessages::EVT_MUTECHANGED ) {
#if 0
CControldMsg::commandMute* cmd = (CControldMsg::commandMute*) data;
if(cmd->type == (CControld::volume_type)g_settings.audio_avs_Control)
g_volume->AudioMute(cmd->mute, true );
delete[] (unsigned char*) data;
#endif
//FIXME unused ?
return messages_return::handled;
}
else if( msg == NeutrinoMessages::EVT_SERVICESCHANGED ) {
@@ -2605,11 +2568,8 @@ _repeat:
CTimerd::RecordingStopInfo* recinfo = (CTimerd::RecordingStopInfo*)data;
printf("NeutrinoMessages::RECORD_STOP: eventID %d channel_id %llx\n", recinfo->eventID, recinfo->channel_id);
CRecordManager::getInstance()->Stop(recinfo);
#if 0 // done when EVT_RECORDMODE received ?
if((mode == mode_standby) && !CRecordManager::getInstance()->RecordingStatus())
cpuFreq->SetCpuFreq(g_settings.standby_cpufreq * 1000 * 1000);
#endif
autoshift = CRecordManager::getInstance()->TimeshiftOnly();
delete[] (unsigned char*) data;
return messages_return::handled;
}
@@ -2617,29 +2577,26 @@ _repeat:
res = messages_return::handled;
t_channel_id channel_id = *(t_channel_id*) data;
CRecordManager::getInstance()->Update(channel_id);
#if 0 //TODO ?
/* if new vpid */
if(CMoviePlayerGui::getInstance().timeshift)
res |= messages_return::cancel_all;
}
#endif
return res;
}
else if( msg == NeutrinoMessages::ZAPTO) {
CTimerd::EventInfo * eventinfo;
eventinfo = (CTimerd::EventInfo *) data;
if(recordingstatus==0) {
bool isTVMode = CServiceManager::getInstance()->IsChannelTVChannel(eventinfo->channel_id);
CTimerd::EventInfo * eventinfo = (CTimerd::EventInfo *) data;
if (eventinfo->channel_id != CZapit::getInstance()->GetCurrentChannelID()){
if( (recordingstatus == 0) || (recordingstatus && CRecordManager::getInstance()->TimeshiftOnly()) || (recordingstatus && CFEManager::getInstance()->haveFreeFrontend()) ||
(recordingstatus && channelList->SameTP(eventinfo->channel_id)) ) {
bool isTVMode = CServiceManager::getInstance()->IsChannelTVChannel(eventinfo->channel_id);
dvbsub_stop();
dvbsub_stop();
if ((!isTVMode) && (mode != mode_radio)) {
radioMode(false);
if ((!isTVMode) && (mode != mode_radio)) {
radioMode(false);
}
else if (isTVMode && (mode != mode_tv)) {
tvMode(false);
}
channelList->zapTo_ChannelID(eventinfo->channel_id);
}
else if (isTVMode && (mode != mode_tv)) {
tvMode(false);
}
channelList->zapTo_ChannelID(eventinfo->channel_id);
}
delete[] (unsigned char*) data;
return messages_return::handled;
@@ -2649,52 +2606,19 @@ _repeat:
standbyMode( false );
}
if( mode != mode_scart ) {
CTimerd::RecordingInfo * eventinfo = (CTimerd::RecordingInfo *) data;
std::string name = g_Locale->getText(LOCALE_ZAPTOTIMER_ANNOUNCE);
CTimerd::TimerList tmpTimerList;
CTimerdClient tmpTimerdClient;
tmpTimerList.clear();
tmpTimerdClient.getTimerList( tmpTimerList );
if( !tmpTimerList.empty() ) {
sort( tmpTimerList.begin(), tmpTimerList.end() );
CTimerd::responseGetTimer &timer = tmpTimerList[0];
name += "\n";
std::string zAddData = CServiceManager::getInstance()->GetServiceName(timer.channel_id);
if( zAddData.empty()) {
zAddData = g_Locale->getText(LOCALE_TIMERLIST_PROGRAM_UNKNOWN);
}
if(timer.epgID!=0) {
CEPGData epgdata;
zAddData += " :\n";
if (CEitManager::getInstance()->getEPGid(timer.epgID, timer.epg_starttime, &epgdata)) {
zAddData += epgdata.title;
}
else if(strlen(timer.epgTitle)!=0) {
zAddData += timer.epgTitle;
}
}
else if(strlen(timer.epgTitle)!=0) {
zAddData += timer.epgTitle;
}
name += zAddData;
}
getAnnounceEpgName( eventinfo, name);
ShowHintUTF( LOCALE_MESSAGEBOX_INFO, name.c_str() );
}
delete [] (unsigned char*) data;
return messages_return::handled;
}
else if( msg == NeutrinoMessages::ANNOUNCE_RECORD) {
my_system(NEUTRINO_RECORDING_TIMER_SCRIPT);
CTimerd::RecordingInfo * eventinfo = (CTimerd::RecordingInfo *) data;
if (g_settings.recording_type == RECORDING_FILE) {
char * recordingDir = ((CTimerd::RecordingInfo*)data)->recordingDir;
char * recordingDir = eventinfo->recordingDir;
for(int i=0 ; i < NETWORK_NFS_NR_OF_ENTRIES ; i++) {
if (strcmp(g_settings.network_nfs_local_dir[i],recordingDir) == 0) {
printf("[neutrino] waking up %s (%s)\n",g_settings.network_nfs_ip[i].c_str(),recordingDir);
@@ -2707,43 +2631,39 @@ _repeat:
wakeup_hdd(g_settings.network_nfs_recordingdir);
}
}
if( g_settings.recording_zap_on_announce ) {
//TODO check transponder ?
if( g_settings.recording_zap_on_announce && (mode != mode_standby) && (eventinfo->channel_id != CZapit::getInstance()->GetCurrentChannelID())) {
CRecordManager::getInstance()->StopAutoRecord();
if(!CRecordManager::getInstance()->RecordingStatus()) {
dvbsub_stop(); //FIXME if same channel ?
t_channel_id channel_id=((CTimerd::RecordingInfo*)data)->channel_id;
bool recordingStatus = CRecordManager::getInstance()->RecordingStatus();
if ( !recordingStatus || (recordingStatus && CRecordManager::getInstance()->TimeshiftOnly()) || (recordingStatus && CFEManager::getInstance()->haveFreeFrontend()) ||
(recordingStatus && channelList->SameTP(eventinfo->channel_id)) ){
dvbsub_stop();
t_channel_id channel_id=eventinfo->channel_id;
g_Zapit->zapTo_serviceID_NOWAIT(channel_id);
}
}
if(( mode != mode_scart ) && ( mode != mode_standby )){
std::string name = g_Locale->getText(LOCALE_RECORDTIMER_ANNOUNCE);
getAnnounceEpgName(eventinfo, name);
ShowHintUTF(LOCALE_MESSAGEBOX_INFO, name.c_str());
}
delete[] (unsigned char*) data;
if( mode != mode_scart )
ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_RECORDTIMER_ANNOUNCE));
return messages_return::handled;
}
else if( msg == NeutrinoMessages::ANNOUNCE_SLEEPTIMER) {
if( mode != mode_scart )
ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_SLEEPTIMERBOX_ANNOUNCE));
if( mode != mode_scart && mode != mode_standby)
skipSleepTimer = (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_SLEEPTIMERBOX_ANNOUNCE,CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes);
return messages_return::handled;
}
else if( msg == NeutrinoMessages::SLEEPTIMER) {
if(data) {
skipShutdownTimer =
(ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWNTIMER_ANNOUNCE,
CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes);//FIXME
if(skipShutdownTimer) {
printf("NeutrinoMessages::SLEEPTIMER: skiping\n");
skipShutdownTimer = false;
return messages_return::handled;
}
else {
printf("NeutrinoMessages::SLEEPTIMER: shutdown\n");
ExitRun(true, (cs_get_revision() > 7));
}
if(skipSleepTimer) {
printf("NeutrinoMessages::SLEEPTIMER: skiping\n");
skipSleepTimer = false;
return messages_return::handled;
}
if(g_settings.shutdown_real)
ExitRun(true, (cs_get_revision() > 7));
else
else if(mode != mode_standby)
standbyMode( true );
return messages_return::handled;
}
@@ -2810,7 +2730,7 @@ _repeat:
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, text, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO, 0, atoi(timeout.c_str()));
}
delete (unsigned char*) data;
delete[] (unsigned char*) data;
return messages_return::handled;
}
else if (msg == NeutrinoMessages::EVT_RECORDING_ENDED) {
@@ -2948,10 +2868,9 @@ void CNeutrinoApp::ExitRun(const bool /*write_si*/, int retcode)
saveSetup(NEUTRINO_SETTINGS_FILE);
if(retcode) {
const char *neutrino_enter_deepstandby_script = CONFIGDIR "/deepstandby.on";
printf("[%s] executing %s\n",__FILE__ ,neutrino_enter_deepstandby_script);
if (my_system(neutrino_enter_deepstandby_script) != 0)
perror(neutrino_enter_deepstandby_script );
puts("[neutrino.cpp] executing " NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT ".");
if (my_system(NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT) != 0)
perror(NEUTRINO_ENTER_DEEPSTANDBY_SCRIPT " failed");
printf("entering off state\n");
mode = mode_off;
@@ -3016,51 +2935,11 @@ void CNeutrinoApp::ExitRun(const bool /*write_si*/, int retcode)
}
}
}
#if 0
neutrino_msg_t msg;
neutrino_msg_data_t data;
cpuFreq->SetCpuFreq(g_settings.standby_cpufreq * 1000 * 1000);
powerManager->SetStandby(true, true);
if (g_info.delivery_system == DVB_S && (cs_get_revision() < 8)) {
int fspeed = 0;
CFanControlNotifier * funNotifier= new CFanControlNotifier();
funNotifier->changeNotify(NONEXISTANT_LOCALE, (void *) &fspeed);
delete funNotifier;
}
if (powerManager) {
powerManager->Close();
delete powerManager;
}
delete &CMoviePlayerGui::getInstance();
shutdown_cs_api();
my_system("/etc/init.d/rcK");
CVFD::getInstance()->ShowIcon(FP_ICON_CAM1, true);
InfoClock->StopClock();
g_RCInput->clearRCMsg();
while( true ) {
g_RCInput->getMsg(&msg, &data, 10000);
if( msg == CRCInput::RC_standby ) {
printf("Power key, going to reboot...\n");
sleep(2);
reboot(LINUX_REBOOT_CMD_RESTART);
} else if( ( msg == NeutrinoMessages::ANNOUNCE_RECORD) || ( msg == NeutrinoMessages::ANNOUNCE_ZAPTO) ) {
printf("Zap/record timer, going to reboot...\n");
sleep(2);
reboot(LINUX_REBOOT_CMD_RESTART);
}
}
#endif
} else {
delete g_RCInput;
//fan speed
if (g_info.has_fan) {
int fspeed = 0;
CFanControlNotifier funNotifier;
funNotifier.changeNotify(NONEXISTANT_LOCALE, (void *) &fspeed);
CFanControlNotifier::setSpeed(0);
}
//CVFD::getInstance()->ShowText(g_Locale->getText(LOCALE_MAINMENU_REBOOT));
stop_video();
@@ -3075,6 +2954,16 @@ void CNeutrinoApp::saveEpg(bool cvfd_mode)
{
struct stat my_stat;
if(stat(g_settings.epg_dir.c_str(), &my_stat) == 0){
if(!cvfd_mode){//skip saveepg in standby mode, if last saveepg time < 15 Min.
std::string index_xml = g_settings.epg_dir.c_str();
index_xml += "/index.xml";
time_t t=0;
if(stat(index_xml.c_str(), &my_stat) == 0){
if(difftime(time(&t), my_stat.st_ctime) < 900){
return;
}
}
}
printf("[neutrino] Saving EPG to %s...\n", g_settings.epg_dir.c_str());
CVFD::getInstance()->Clear();
@@ -3092,8 +2981,10 @@ void CNeutrinoApp::saveEpg(bool cvfd_mode)
CVFD::getInstance()->Clear();
CVFD::getInstance()->setMode(cvfd_mode ? CVFD::MODE_SHUTDOWN : CVFD::MODE_STANDBY);// true CVFD::MODE_SHUTDOWN , false CVFD::MODE_STANDBY
break;
} else if (!cvfd_mode)
} else if (!cvfd_mode){
printf("wait for epg saving, Msg %x \n", (int) msg);
handleMsg(msg, data);
}
}
}
}
@@ -3101,18 +2992,17 @@ void CNeutrinoApp::saveEpg(bool cvfd_mode)
void CNeutrinoApp::tvMode( bool rezap )
{
INFO("rezap %d current mode %d", rezap, mode);
if(mode==mode_radio ) {
if (mode == mode_radio) {
if (g_settings.radiotext_enable && g_Radiotext) {
delete g_Radiotext;
g_Radiotext = NULL;
}
videoDecoder->StopPicture();
g_RCInput->killTimer(g_InfoViewer->lcdUpdateTimer);
g_InfoViewer->lcdUpdateTimer = g_RCInput->addTimer( LCD_UPDATE_TIME_TV_MODE, false );
CVFD::getInstance()->ShowIcon(FP_ICON_RADIO, false);
StartSubtitles(!rezap);
}
g_InfoViewer->setUpdateTimer(LCD_UPDATE_TIME_TV_MODE);
g_volume->Init();
@@ -3185,11 +3075,12 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby )
{
//static bool wasshift = false;
INFO("%s", bOnOff ? "ON" : "OFF" );
if( bOnOff ) {
if( mode == mode_scart ) {
//g_Controld->setScartMode( 0 );
}
g_InfoViewer->setUpdateTimer(0); // delete timer
StopSubtitles();
if(SDTreloadChannels && !CRecordManager::getInstance()->RecordingStatus()){
SDT_ReloadChannels();
@@ -3200,7 +3091,12 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby )
/* wasshift = */ CRecordManager::getInstance()->StopAutoRecord();
if(!CRecordManager::getInstance()->RecordingStatus()) {
if(mode == mode_radio && g_Radiotext)
g_Radiotext->radiotext_stop();
bool stream_status = CStreamManager::getInstance()->StreamStatus();
if(!fromDeepStandby && !CRecordManager::getInstance()->RecordingStatus() && !stream_status) {
g_Zapit->setStandby(true);
} else {
g_Zapit->stopPlayBack();
@@ -3208,9 +3104,12 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby )
videoDecoder->Standby(true);
g_Sectionsd->setPauseScanning(true);
g_Sectionsd->setPauseScanning(!fromDeepStandby);
g_Sectionsd->setServiceChanged(0, false);
lastMode = mode;
mode = mode_standby;
if(!CRecordManager::getInstance()->RecordingStatus() ) {
//only save epg when not recording
if(g_settings.epg_save && !fromDeepStandby) {
@@ -3218,8 +3117,10 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby )
}
}
CVFD::getInstance()->Clear();
CVFD::getInstance()->setMode(CVFD::MODE_STANDBY);
if(CVFD::getInstance()->getMode() != CVFD::MODE_STANDBY){
CVFD::getInstance()->Clear();
CVFD::getInstance()->setMode(CVFD::MODE_STANDBY);
}
if(g_settings.mode_clock) {
InfoClock->StopClock();
@@ -3235,15 +3136,10 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby )
if(!CRecordManager::getInstance()->RecordingStatus())
cpuFreq->SetCpuFreq(g_settings.standby_cpufreq * 1000 * 1000);
lastMode = mode;
mode = mode_standby;
//fan speed
if (g_info.has_fan) {
int fspeed = 1;
CFanControlNotifier * funNotifier= new CFanControlNotifier();
funNotifier->changeNotify(NONEXISTANT_LOCALE, (void *) &fspeed);
delete funNotifier;
}
if (g_info.has_fan)
CFanControlNotifier::setSpeed(1);
frameBuffer->setActive(false);
// Active standby on
powerManager->SetStandby(true, false);
@@ -3266,11 +3162,8 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby )
}
frameBuffer->setActive(true);
//fan speed
if (g_info.has_fan) {
CFanControlNotifier * funNotifier= new CFanControlNotifier();
funNotifier->changeNotify(NONEXISTANT_LOCALE, (void*) &g_settings.fan_speed);
delete funNotifier;
}
if (g_info.has_fan)
CFanControlNotifier::setSpeed(g_settings.fan_speed);
puts("[neutrino.cpp] executing " NEUTRINO_LEAVE_STANDBY_SCRIPT ".");
if (my_system(NEUTRINO_LEAVE_STANDBY_SCRIPT) != 0)
@@ -3310,15 +3203,6 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby )
InfoClock->StartClock();
g_volume->AudioMute(current_muted, true);
#if 0
/* auto-record will be started when zap is complete
* FIXME is it needed to restart manual timeshift here ? */
if((mode == mode_tv) && wasshift) {
//startAutoRecord();
CRecordManager::getInstance()->StartAutoRecord();
}
wasshift = false;
#endif
StartSubtitles();
}
}
@@ -3327,12 +3211,11 @@ void CNeutrinoApp::radioMode( bool rezap)
{
//printf("radioMode: rezap %s\n", rezap ? "yes" : "no");
INFO("rezap %d current mode %d", rezap, mode);
if(mode==mode_tv ) {
g_RCInput->killTimer(g_InfoViewer->lcdUpdateTimer);
g_InfoViewer->lcdUpdateTimer = g_RCInput->addTimer( LCD_UPDATE_TIME_RADIO_MODE, false );
if (mode == mode_tv) {
CVFD::getInstance()->ShowIcon(FP_ICON_TV, false);
StopSubtitles();
}
g_InfoViewer->setUpdateTimer(LCD_UPDATE_TIME_RADIO_MODE);
CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
CVFD::getInstance()->ShowIcon(FP_ICON_RADIO, true);
@@ -3346,6 +3229,10 @@ void CNeutrinoApp::radioMode( bool rezap)
g_RemoteControl->radioMode();
SetChannelMode(g_settings.channel_mode_radio);
if (g_settings.radiotext_enable && !g_Radiotext)
g_Radiotext = new CRadioText;
if( rezap ) {
t_channel_id last_chid = CZapit::getInstance()->GetLastRADIOChannel();
channelList->setSelected(0xfffffff); /* make sure that zapTo_ChannelID will zap */
@@ -3355,10 +3242,6 @@ void CNeutrinoApp::radioMode( bool rezap)
channelList->zapTo(0);
}
videoDecoder->ShowPicture(DATADIR "/neutrino/icons/radiomode.jpg");
if (g_settings.radiotext_enable) {
g_Radiotext = new CRadioText;
}
}
//switching from current mode to tv or radio mode or to optional parameter prev_mode
@@ -3523,12 +3406,6 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey)
MoviePluginSelector.exec(NULL, "");
return menu_return::RETURN_REPAINT;
}
#if 0 // commented in menu, needed ?
else if(actionKey == "autolink") {
CRecordManager::getInstance()->LinkTimeshift();
returnval = menu_return::RETURN_EXIT_ALL;
}
#endif
else if(actionKey == "clearSectionsd")
{
g_Sectionsd->freeMemory();
@@ -3555,16 +3432,19 @@ bool CNeutrinoApp::changeNotify(const neutrino_locale_t OptionName, void * /*dat
**************************************************************************************/
void stop_daemons(bool stopall)
{
streamts_stop = 1;
dvbsub_close();
tuxtxt_stop();
tuxtxt_close();
if (g_Radiotext) {
delete g_Radiotext;
g_Radiotext = NULL;
}
printf("httpd shutdown\n");
pthread_cancel(nhttpd_thread);
pthread_join(nhttpd_thread, NULL);
printf("httpd shutdown done\n");
pthread_join(stream_thread, NULL);
CStreamManager::getInstance()->Stop();
if(stopall) {
printf("timerd shutdown\n");
g_Timerd->shutdown();
@@ -3638,12 +3518,8 @@ int main(int argc, char **argv)
signal(SIGHUP, SIG_IGN); // process are unspecified (signal(2))
/* don't die in streamts.cpp from a SIGPIPE if client disconnects */
signal(SIGPIPE, SIG_IGN);
#if 0
for(int i = 3; i < 256; i++)
close(i);
#endif
tzset();
initGlobals();
return CNeutrinoApp::getInstance()->run(argc, argv);
}
@@ -3799,10 +3675,6 @@ void CNeutrinoApp::StartSubtitles(bool show)
void CNeutrinoApp::SelectSubtitles()
{
#if 0
int curnum = channelList->getActiveChannelNumber();
CZapitChannel * cc = channelList->getChannel(curnum);
#endif
/* called on NeutrinoMessages::EVT_ZAP_COMPLETE, should be safe to use zapit current channel */
CZapitChannel * cc = CZapit::getInstance()->GetCurrentChannel();
@@ -3863,6 +3735,34 @@ void CNeutrinoApp::SDT_ReloadChannels()
}
}
void CNeutrinoApp::getAnnounceEpgName(CTimerd::RecordingInfo * eventinfo, std::string &name)
{
name += "\n";
std::string zAddData = CServiceManager::getInstance()->GetServiceName(eventinfo->channel_id);
if( zAddData.empty()) {
zAddData = g_Locale->getText(LOCALE_TIMERLIST_PROGRAM_UNKNOWN);
}
if(eventinfo->epgID!=0) {
CEPGData epgdata;
zAddData += " :\n";
if (CEitManager::getInstance()->getEPGid(eventinfo->epgID, eventinfo->epg_starttime, &epgdata)) {
zAddData += epgdata.title;
}
else if(strlen(eventinfo->epgTitle)!=0) {
zAddData += eventinfo->epgTitle;
}
}
else if(strlen(eventinfo->epgTitle)!=0) {
zAddData += " :\n";
zAddData += eventinfo->epgTitle;
}
name += zAddData;
}
void CNeutrinoApp::Cleanup()
{
#ifdef EXIT_CLEANUP
@@ -3895,7 +3795,6 @@ void CNeutrinoApp::Cleanup()
delete g_Radiotext; g_Radiotext = NULL;
printf("cleanup 13\n");fflush(stdout);
delete colorSetupNotifier; colorSetupNotifier = NULL;
delete audioSetupNotifier; audioSetupNotifier = NULL;
delete MoviePluginChanger; MoviePluginChanger = NULL;
printf("cleanup 14\n");fflush(stdout);