diff --git a/data/locale/english.locale b/data/locale/english.locale index 879f7b341..e39f9908d 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -129,7 +129,7 @@ audiomenu.analog_mode Analog mode audiomenu.analog_out Analog output audiomenu.avs avs audiomenu.avs_control Volume Control avs/ost -audiomenu.dolbydigital Dolby Digital +audiomenu.dolbydigital Prefer Dolby Digital audiomenu.head Audio Settings audiomenu.lirc lirc audiomenu.monoleft mono left @@ -140,6 +140,9 @@ 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.pref_lang_head Audio/EPG language preferences +audiomenu.pref_lang Prefered language audioplayer.add Add audioplayer.artist_title Artist, Title audioplayer.building_search_index building search index diff --git a/src/daemonc/remotecontrol.cpp b/src/daemonc/remotecontrol.cpp index fb8fc1190..ec083673a 100644 --- a/src/daemonc/remotecontrol.cpp +++ b/src/daemonc/remotecontrol.cpp @@ -421,10 +421,43 @@ void CRemoteControl::getNVODs() void CRemoteControl::processAPIDnames() { has_unresolved_ctags= false; - has_ac3 = false; + has_ac3 = false; //FIXME what this variable suppoused to do ?? seems unused + int pref_found = -1; + int pref_ac3_found = -1; + int pref_idx = -1; + int pref_ac3_idx = -1; + int ac3_found = -1; + + if(g_settings.auto_lang) { + /* first we check prefs to find pid according to pref index */ + for(int i = 0; i < 3; i++) { + for(int j = 0; j < (int) current_PIDs.APIDs.size(); j++) { + /* processAPIDnames called 2 times, TODO find better way to detect second call */ + if (strlen( current_PIDs.APIDs[j].desc ) != 3) + continue; + + if(strcasecmp(current_PIDs.APIDs[j].desc, g_settings.pref_lang[i].c_str()) == 0) { + /* remember first pref found index and pid*/ + if(pref_found < 0) { + pref_found = j; + pref_idx = i; + } + if(current_PIDs.APIDs[j].is_ac3 && g_settings.audio_DolbyDigital && (pref_ac3_found < 0)) { + pref_ac3_found = j; + pref_ac3_idx = i; + } + } + } /* for all pids */ + } /*for all prefs*/ + + /* reset pref ac3, if it have lower priority */ + if((pref_idx >= 0) && (pref_idx < pref_ac3_idx)) + pref_ac3_found = -1; + } for(unsigned int count=0; count< current_PIDs.APIDs.size(); count++) { + printf("Neutrino: apid name= %s (%s) pid= %X\n", current_PIDs.APIDs[count].desc, getISO639Description( current_PIDs.APIDs[count].desc ), current_PIDs.APIDs[count].pid); if ( current_PIDs.APIDs[count].component_tag != 0xFF ) { has_unresolved_ctags= true; @@ -439,8 +472,9 @@ void CRemoteControl::processAPIDnames() { strncat(current_PIDs.APIDs[count].desc, " (AC3)", 25); has_ac3 = true; + if(g_settings.audio_DolbyDigital && (ac3_found < 0)) + ac3_found = count; } -//printf("Neutrino: have apid name= %s pid= %X english= %d\n", current_PIDs.APIDs[count].desc, current_PIDs.APIDs[count].pid, g_settings.audio_english); } if ( has_unresolved_ctags ) @@ -472,18 +506,18 @@ void CRemoteControl::processAPIDnames() } } } - +#if 0 // old CZapitClient::APIDList::iterator e = current_PIDs.APIDs.begin(); while ( e != current_PIDs.APIDs.end() ) { if ( e->is_ac3 ) { - has_ac3 = true; + has_ac3 = true; } e++; } - if ( ( g_settings.audio_english == 0) && (g_settings.audio_DolbyDigital == 1)) + if ( /*( g_settings.audio_english == 0) &&*/ (g_settings.audio_DolbyDigital == 1)) { for (unsigned int j=0; j< current_PIDs.APIDs.size(); j++) if ( current_PIDs.APIDs[j].is_ac3 ) @@ -494,22 +528,27 @@ void CRemoteControl::processAPIDnames() } if ( current_PIDs.PIDs.selected_apid >= current_PIDs.APIDs.size() ) { - setAPID( 0 ); + setAPID( 0 ); } +#endif } } } - if ( (g_settings.audio_english == 1) && (current_PIDs.APIDs.size() > 1) ) + printf("Neutrino: pref_found %d pref_ac3_found %d ac3_found %d\n", pref_found, pref_ac3_found, ac3_found); + if(pref_ac3_found >= 0) { + printf("Neutrino: set apid name= %s pid= %X\n", current_PIDs.APIDs[pref_ac3_found].desc, current_PIDs.APIDs[pref_ac3_found].pid); + setAPID(pref_ac3_found); + } else if(pref_found >= 0) { + printf("Neutrino: set apid name= %s pid= %X\n", current_PIDs.APIDs[pref_found].desc, current_PIDs.APIDs[pref_found].pid); + setAPID(pref_found); + } + else if(ac3_found >= 0) { + printf("Neutrino: set apid name= %s pid= %X\n", current_PIDs.APIDs[ac3_found].desc, current_PIDs.APIDs[ac3_found].pid); + setAPID(ac3_found); + } + else if ( current_PIDs.PIDs.selected_apid >= current_PIDs.APIDs.size() ) { - for (unsigned int j=0; j< current_PIDs.APIDs.size(); j++) - { - if ( strstr(current_PIDs.APIDs[j].desc, "eng") || strstr(current_PIDs.APIDs[j].desc, "Tonoption 2") || strstr(current_PIDs.APIDs[j].desc, "Eng") || strstr(current_PIDs.APIDs[j].desc, "ENG")) - { - printf("Neutrino: set apid name= %s pid= %X\n", current_PIDs.APIDs[j].desc, current_PIDs.APIDs[j].pid); - setAPID( j ); - break; - } - } + setAPID( 0 ); } t_channel_id * p = new t_channel_id; diff --git a/src/gui/infoviewer.cpp b/src/gui/infoviewer.cpp index 314a134da..b3aed8643 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -847,7 +847,7 @@ void CInfoViewer::showSubchan () lframeBuffer->paintBackgroundBoxRel (x + dx, y, borderwidth, dy); lframeBuffer->paintBoxRel (x, y, dx, dy, COL_MENUCONTENT_PLUS_0); - g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO]->RenderString (x + 10, y + 30, dx - 20, text, COL_MENUCONTENT); + g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO]->RenderString (x + 10, y + 30, dx - 20, text, COL_MENUCONTENT, 0, true); if (g_RemoteControl->director_mode) { lframeBuffer->paintIcon (NEUTRINO_ICON_BUTTON_YELLOW, x + 8, y + dy - 20); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index f7e5709f9..3f1ee08df 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -799,7 +799,11 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.audio_DolbyDigital = configfile.getBool("audio_DolbyDigital" , false); g_settings.audio_avs_Control = false; - g_settings.audio_english = configfile.getInt32( "audio_english", 0 ); + g_settings.auto_lang = configfile.getInt32( "auto_lang", 0 ); + for(int i = 0; i < 3; i++) { + sprintf(cfg_key, "pref_lang_%d", i); + g_settings.pref_lang[i] = configfile.getString(cfg_key, ""); + } g_settings.zap_cycle = configfile.getInt32( "zap_cycle", 1 ); g_settings.sms_channel = configfile.getInt32( "sms_channel", 0 ); strcpy( g_settings.audio_PCMOffset, configfile.getString( "audio_PCMOffset", "0" ).c_str() ); @@ -1301,7 +1305,11 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setInt32( "audio_AnalogMode", g_settings.audio_AnalogMode ); configfile.setBool("audio_DolbyDigital" , g_settings.audio_DolbyDigital ); configfile.setInt32( "audio_avs_Control", g_settings.audio_avs_Control ); - configfile.setInt32( "audio_english", g_settings.audio_english ); + configfile.setInt32( "auto_lang", g_settings.auto_lang ); + for(int i = 0; i < 3; i++) { + sprintf(cfg_key, "pref_lang_%d", i); + configfile.setString(cfg_key, g_settings.pref_lang[i]); + } configfile.setString( "audio_PCMOffset", g_settings.audio_PCMOffset ); //vcr @@ -2284,6 +2292,9 @@ int CNeutrinoApp::run(int argc, char **argv) int loadSettingsErg = loadSetup(NEUTRINO_SETTINGS_FILE); bool display_language_selection; + + initialize_iso639_map(); + CLocaleManager::loadLocale_ret_t loadLocale_ret = g_Locale->loadLocale(g_settings.language); if (loadLocale_ret == CLocaleManager::NO_SUCH_LOCALE) { @@ -2756,7 +2767,7 @@ printf("[neutrino] timeshift try, recordingstatus %d, rec dir %s, timeshift dir printf("[neutrino] direct record\n"); if(recordingstatus) { if(ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECODING_QUERY, - CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes) + CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes) g_Timerd->stopTimerEvent(recording_id); } else if(msg != CRCInput::RC_stop ) { recordingstatus = 1; diff --git a/src/neutrino_menue.cpp b/src/neutrino_menue.cpp index bc56e22b4..4fe57b1d8 100644 --- a/src/neutrino_menue.cpp +++ b/src/neutrino_menue.cpp @@ -1630,13 +1630,78 @@ const CMenuOptionChooser::keyval AUDIOMENU_CLOCKREC_OPTIONS[AUDIOMENU_CLOCKREC_O { 1, LOCALE_OPTIONS_ON }, }; +void sectionsd_set_languages(const std::vector& newLanguages); + +class CLangSelectHandler : public CMenuTarget +{ +public: + void setLanguages(void); + int exec(CMenuTarget* parent, const std::string &actionkey); +}; + +int CLangSelectHandler::exec(CMenuTarget* parent, const std::string &actionkey) +{ + std::map::const_iterator tI; + int i; + char cnt[5]; + int select = -1; + int num = atoi(actionkey.c_str()); + + if (parent) + parent->hide(); + + CMenuWidget* menu = new CMenuWidget(LOCALE_AUDIOMENU_PREF_LANG, NEUTRINO_ICON_SETTINGS); + CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); + i = 0; + for (tI = iso639.begin(); tI != iso639.end(); tI++) { + sprintf(cnt, "%d", i); + menu->addItem(new CMenuForwarderNonLocalized(tI->second.c_str(), true, NULL, selector, cnt), g_settings.pref_lang[num] == tI->first); + i++; + } + if (i == 0) { + char text[255]; + sprintf(text, "No languages found !\n"); + ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, text, 450, 2); + return menu_return::RETURN_REPAINT; + } + int retval = menu->exec(NULL, ""); + delete menu; + delete selector; + if (select >= 0) { + tI = iso639.begin(); + for(i = 0; i < select; i++) + tI++; + + printf("CLangSelectHandler: selected %d: %s (%s)\n", i, tI->first.c_str(), tI->second.c_str()); + g_settings.pref_lang[num] = tI->first.c_str(); + setLanguages(); + } + if (retval == menu_return::RETURN_EXIT_ALL) + return menu_return::RETURN_EXIT_ALL; + + return menu_return::RETURN_REPAINT; +} + +void CLangSelectHandler::setLanguages(void) +{ + std::vector languages; + bool found = false; + + for(int i = 0; i < 3; i++) { + if(g_settings.pref_lang[i].size()) { + languages.push_back(g_settings.pref_lang[i]); + found = true; + } + } + if(found) + sectionsd_set_languages(languages); +} + void CNeutrinoApp::InitAudioSettings(CMenuWidget &audioSettings, CAudioSetupNotifier* audioSetupNotifier) { addMenueIntroItems(audioSettings); audioSettings.addItem(new CMenuOptionChooser(LOCALE_AUDIOMENU_ANALOG_MODE, &g_settings.audio_AnalogMode, AUDIOMENU_ANALOGOUT_OPTIONS, AUDIOMENU_ANALOGOUT_OPTION_COUNT, true, audioSetupNotifier)); - 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_EXTRA_ENGLISH, &g_settings.audio_english, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, audioSetupNotifier)); audioSettings.addItem(new CMenuOptionChooser(LOCALE_AUDIOMENU_HDMI_DD, &g_settings.hdmi_dd, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, audioSetupNotifier)); audioSettings.addItem(new CMenuOptionChooser(LOCALE_AUDIOMENU_SPDIF_DD, &g_settings.spdif_dd, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, audioSetupNotifier)); audioSettings.addItem(new CMenuOptionChooser(LOCALE_AUDIOMENU_AVSYNC, &g_settings.avsync, AUDIOMENU_AVSYNC_OPTIONS, AUDIOMENU_AVSYNC_OPTION_COUNT, true, audioSetupNotifier)); @@ -1649,6 +1714,17 @@ void CNeutrinoApp::InitAudioSettings(CMenuWidget &audioSettings, CAudioSetupNoti audioSettings.addItem(new CMenuOptionChooser(LOCALE_SRS_NMGR, &g_settings.srs_nmgr_enable, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, audioSetupNotifier)); audioSettings.addItem(new CMenuOptionNumberChooser(LOCALE_SRS_VOLUME, &g_settings.srs_ref_volume, true, 1, 100, audioSetupNotifier)); + audioSettings.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_AUDIOMENU_PREF_LANG_HEAD)); + + CLangSelectHandler * langSelect = new CLangSelectHandler(); + 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 CMenuForwarder(LOCALE_AUDIOMENU_PREF_LANG, true, NULL, langSelect, "0")); + audioSettings.addItem(new CMenuForwarder(LOCALE_AUDIOMENU_PREF_LANG, true, NULL, langSelect, "1")); + audioSettings.addItem(new CMenuForwarder(LOCALE_AUDIOMENU_PREF_LANG, true, NULL, langSelect, "2")); + + langSelect->setLanguages(); + #if 0 CStringInput * audio_PCMOffset = new CStringInput(LOCALE_AUDIOMENU_PCMOFFSET, g_settings.audio_PCMOffset, 2, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789 ", audioSetupNotifier); CMenuForwarder *mf = new CMenuForwarder(LOCALE_AUDIOMENU_PCMOFFSET, true, g_settings.audio_PCMOffset, audio_PCMOffset ); @@ -1656,8 +1732,6 @@ void CNeutrinoApp::InitAudioSettings(CMenuWidget &audioSettings, CAudioSetupNoti #endif } - - #if 1 #define PARENTALLOCK_PROMPT_OPTION_COUNT 3 #else diff --git a/src/sectionsd/sectionsd.cpp b/src/sectionsd/sectionsd.cpp index ee5964e33..8d6d59d61 100644 --- a/src/sectionsd/sectionsd.cpp +++ b/src/sectionsd/sectionsd.cpp @@ -9340,3 +9340,8 @@ void sectionsd_setPrivatePid(unsigned short /*pid*/) } #endif } + +void sectionsd_set_languages(const std::vector& newLanguages) +{ + SIlanguage::setLanguages(newLanguages); +} diff --git a/src/system/localize.cpp b/src/system/localize.cpp index 1b50dec36..03d9252a6 100644 --- a/src/system/localize.cpp +++ b/src/system/localize.cpp @@ -40,11 +40,14 @@ #include #include #include +#include +#include +#include //static const char * iso639filename = "/usr/share/iso-codes/iso-639.tab"; static const char * iso639filename = "/share/iso-codes/iso-639.tab"; -#if 1 +#if 0 #include #include @@ -129,10 +132,8 @@ const char * getISO639Description(const char * const iso) return ((iso639_t *)value)->name; } #else -#include -#include -static std::map iso639; +std::map iso639; void initialize_iso639_map(void) { @@ -175,7 +176,7 @@ CLocaleManager::~CLocaleManager() { for (unsigned j = 0; j < (sizeof(locale_real_names)/sizeof(const char *)); j++) if (localeData[j] != locale_real_names[j]) - free(localeData[j]); + ::free(localeData[j]); delete localeData; } @@ -187,7 +188,7 @@ CLocaleManager::loadLocale_ret_t CLocaleManager::loadLocale(const char * const l unsigned int i; FILE * fd; - initialize_iso639_map(); + //initialize_iso639_map(); for (i = 0; i < 2; i++) { diff --git a/src/system/localize.h b/src/system/localize.h index 1a4098f7e..61108ce3c 100644 --- a/src/system/localize.h +++ b/src/system/localize.h @@ -36,8 +36,12 @@ #include #include_next #include +#include +#include +void initialize_iso639_map(void); const char * getISO639Description(const char * const iso); +extern std::map iso639; #define ARE_LOCALES_EQUAL(a,b) (a == b) diff --git a/src/system/locals.h b/src/system/locals.h index 00982271b..9a498e339 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -147,6 +147,9 @@ typedef enum { LOCALE_AUDIOMENU_AVSYNC, LOCALE_AUDIOMENU_AVSYNC_AM, LOCALE_AUDIOMENU_CLOCKREC, + LOCALE_AUDIOMENU_AUTO_LANG, + LOCALE_AUDIOMENU_PREF_LANG_HEAD, + LOCALE_AUDIOMENU_PREF_LANG, LOCALE_AUDIOPLAYER_ADD, LOCALE_AUDIOPLAYER_ADD_IC, LOCALE_AUDIOPLAYER_ADD_LOC, @@ -1176,7 +1179,6 @@ typedef enum { LOCALE_ZAPIT_SCANTYPE_TV, LOCALE_ZAPIT_SCANTYPE_TVRADIO, LOCALE_ZAPTOTIMER_ANNOUNCE, - LOCALE_EXTRA_ENGLISH, LOCALE_DBOXINFO, LOCALE_EXTRA_SCANMODE, LOCALE_EXTRA_STARTSTANDBY, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 6a096dae7..5ec1d183a 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -147,6 +147,9 @@ const char *locale_real_names[] = { "audiomenu.avsync", "audiomenu.avsync_am", "audiomenu.clockrec", + "audiomenu.auto_lang", + "audiomenu.pref_lang_head", + "audiomenu.pref_lang", "audioplayer.add", "audioplayer.add_ic", "audioplayer.add_loc", @@ -1176,7 +1179,6 @@ const char *locale_real_names[] = { "zapit.scantype.tv", "zapit.scantype.tvradio", "zaptotimer.announce", - "extra.english", "extra.dboxinfo", "extra.scan_mode", "extra.start_tostandby", @@ -1364,4 +1366,5 @@ const char *locale_real_names[] = { "cpu.freq_standby", "cpu.freq_default" }; + #endif diff --git a/src/system/settings.h b/src/system/settings.h index f52f8ff87..df4cb64b9 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -70,7 +70,7 @@ struct SNeutrinoSettings int audio_AnalogMode; int audio_DolbyDigital; int audio_avs_Control; - int audio_english; + int auto_lang; char audio_PCMOffset[3]; int srs_enable; int srs_algo; @@ -95,6 +95,8 @@ struct SNeutrinoSettings char language[25]; char timezone[150]; + std::string pref_lang[3]; + // EPG int epg_save; std::string epg_cache;