diff --git a/data/locale/english.locale b/data/locale/english.locale index e39f9908d..3579b5558 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -140,7 +140,8 @@ audiomenu.hdmi_dd Encoded DD on HDMI audiomenu.spdif_dd Encoded DD on SPDIF audiomenu.avsync A/V sync audiomenu.avsync_am Audio master -audiomenu.auto_lang Use prefered languages +audiomenu.auto_lang Auto select audio +audiomenu.auto_subs Auto select subtitles audiomenu.pref_lang_head Audio/EPG language preferences audiomenu.pref_lang Prefered language audioplayer.add Add diff --git a/src/neutrino.cpp b/src/neutrino.cpp index ae6f6e8ad..ecd181e33 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -800,6 +800,7 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.audio_avs_Control = false; g_settings.auto_lang = configfile.getInt32( "auto_lang", 0 ); + g_settings.auto_subs = configfile.getInt32( "auto_subs", 0 ); for(int i = 0; i < 3; i++) { sprintf(cfg_key, "pref_lang_%d", i); strncpy(g_settings.pref_lang[i], configfile.getString(cfg_key, "").c_str(), 30); @@ -1306,6 +1307,7 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setBool("audio_DolbyDigital" , g_settings.audio_DolbyDigital ); configfile.setInt32( "audio_avs_Control", g_settings.audio_avs_Control ); configfile.setInt32( "auto_lang", g_settings.auto_lang ); + configfile.setInt32( "auto_subs", g_settings.auto_subs ); for(int i = 0; i < 3; i++) { sprintf(cfg_key, "pref_lang_%d", i); configfile.setString(cfg_key, g_settings.pref_lang[i]); @@ -2231,6 +2233,7 @@ void CNeutrinoApp::InitZapper() tuxtxt_start(g_RemoteControl->current_PIDs.PIDs.vtxtpid); g_RCInput->postMsg(NeutrinoMessages::SHOW_INFOBAR, 0); //g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_COMPLETE, (neutrino_msg_data_t) &live_channel_id); + SelectSubtitles(); StartSubtitles(); } } @@ -2933,6 +2936,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data) scrambled_timer = 0; } scrambled_timer = g_RCInput->addTimer(10*1000*1000, true); + SelectSubtitles(); if(!g_InfoViewer->is_visible) StartSubtitles(); } @@ -4834,3 +4838,51 @@ void CNeutrinoApp::StartSubtitles() dvbsub_start(0); tuxtx_pause_subtitle(false); } + +void CNeutrinoApp::SelectSubtitles() +{ + if(!g_settings.auto_subs) + return; + + int curnum = channelList->getActiveChannelNumber(); + CZapitChannel * cc = channelList->getChannel(curnum); + + for(int i = 0; i < 3; i++) { + if(strlen(g_settings.pref_lang[i]) == 0) + continue; + + std::string temp(g_settings.pref_lang[i]); + + for(int j = 0 ; j < (int)cc->getSubtitleCount() ; j++) { + CZapitAbsSub* s = cc->getChannelSub(j); + if (s->thisSubType == CZapitAbsSub::DVB) { + CZapitDVBSub* sd = reinterpret_cast(s); + std::map::const_iterator it; + for(it = iso639.begin(); it != iso639.end(); it++) { + if(temp == it->second && sd->ISO639_language_code == it->first) { + printf("CNeutrinoApp::SelectSubtitles: found DVB %s, pid %x\n", sd->ISO639_language_code.c_str(), sd->pId); + dvbsub_stop(); + dvbsub_setpid(sd->pId); + return; + } + } + } + } + for(int j = 0 ; j < (int)cc->getSubtitleCount() ; j++) { + CZapitAbsSub* s = cc->getChannelSub(j); + if (s->thisSubType == CZapitAbsSub::TTX) { + CZapitTTXSub* sd = reinterpret_cast(s); + std::map::const_iterator it; + for(it = iso639.begin(); it != iso639.end(); it++) { + if(temp == it->second && sd->ISO639_language_code == it->first) { + int page = ((sd->teletext_magazine_number & 0xFF) << 8) | sd->teletext_page_number; + printf("CNeutrinoApp::SelectSubtitles: found TTX %s, pid %x page %03X\n", sd->ISO639_language_code.c_str(), sd->pId, page); + tuxtx_stop_subtitle(); + tuxtx_set_pid(sd->pId, page); + return; + } + } + } + } + } +} diff --git a/src/neutrino.h b/src/neutrino.h index 9bb114921..e0cfe91e0 100644 --- a/src/neutrino.h +++ b/src/neutrino.h @@ -264,6 +264,7 @@ public: void quickZap(int msg); void StopSubtitles(); void StartSubtitles(); + void SelectSubtitles(); void showInfo(void); }; #endif diff --git a/src/neutrino_menue.cpp b/src/neutrino_menue.cpp index 86af95df0..aeac89b99 100644 --- a/src/neutrino_menue.cpp +++ b/src/neutrino_menue.cpp @@ -1682,7 +1682,8 @@ void CNeutrinoApp::InitAudioSettings(CMenuWidget &audioSettings, CAudioSetupNoti audioSettings.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_AUDIOMENU_PREF_LANG_HEAD)); audioSettings.addItem(new CMenuOptionChooser(LOCALE_AUDIOMENU_DOLBYDIGITAL, &g_settings.audio_DolbyDigital, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, audioSetupNotifier)); - audioSettings.addItem(new CMenuOptionChooser(LOCALE_AUDIOMENU_AUTO_LANG, &g_settings.auto_lang, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, audioSetupNotifier)); + audioSettings.addItem(new CMenuOptionChooser(LOCALE_AUDIOMENU_AUTO_LANG, &g_settings.auto_lang, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, NULL)); + audioSettings.addItem(new CMenuOptionChooser(LOCALE_AUDIOMENU_AUTO_SUBS, &g_settings.auto_subs, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, NULL)); CLangSelectNotifier * langNotifier = new CLangSelectNotifier(); for(int i = 0; i < 3; i++) { diff --git a/src/system/locals.h b/src/system/locals.h index 9a498e339..a0cbe4c1e 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -148,6 +148,7 @@ typedef enum { LOCALE_AUDIOMENU_AVSYNC_AM, LOCALE_AUDIOMENU_CLOCKREC, LOCALE_AUDIOMENU_AUTO_LANG, + LOCALE_AUDIOMENU_AUTO_SUBS, LOCALE_AUDIOMENU_PREF_LANG_HEAD, LOCALE_AUDIOMENU_PREF_LANG, LOCALE_AUDIOPLAYER_ADD, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 5ec1d183a..b7c840660 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -148,6 +148,7 @@ const char *locale_real_names[] = { "audiomenu.avsync_am", "audiomenu.clockrec", "audiomenu.auto_lang", + "audiomenu.auto_subs", "audiomenu.pref_lang_head", "audiomenu.pref_lang", "audioplayer.add", diff --git a/src/system/settings.h b/src/system/settings.h index 3c2d3639c..7997d8eac 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -71,6 +71,7 @@ struct SNeutrinoSettings int audio_DolbyDigital; int audio_avs_Control; int auto_lang; + int auto_subs; char audio_PCMOffset[3]; int srs_enable; int srs_algo;