diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 6a3cb1897..6c58d4911 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -128,6 +128,10 @@ audiomenu.pref_subs_head Untertitelwahl audiomenu.spdif_dd Dolby Digital über S/PDIF audiomenu.stereo stereo audiomenu.volume_adjust Lautstärke ändern, in % +audiomenu.volume_adjustment Lautstärkeanpassung pro Kanal +audiomenu.volume_adjustment_ac3 AC3-Tonspuren +audiomenu.volume_adjustment_clear Gespeicherte Werte löschen +audiomenu.volume_adjustment_pcm PCM-Tonspuren audiomenu.volume_start Einschaltlautstärke audiomenu.volume_step Lautstärke Schrittweite audioplayer.add Hinzufügen @@ -880,6 +884,9 @@ menu.cancel Abbrechen menu.hint_a_pic Konfigurieren Sie den Audioplayer und den Bildbetrachter menu.hint_aplay Audioplayer menu.hint_audio Audio-Ausgang, Dolby Digital und SRS TruVolume Optionen und mehr +menu.hint_audio_adjust_vol_ac3 Lautstärkeanpassung für AC3-Tonspuren +menu.hint_audio_adjust_vol_clear Alle gespeicherten Werte für AC3- und PCM-Tonspuren löschen +menu.hint_audio_adjust_vol_pcm Lautstärkeanpassung für PCM-Tonspuren menu.hint_audio_analog_mode Wählen Sie den Modus des Ausgangssignals für den CINCH-Anschluss menu.hint_audio_avsync Diese Funktion synchronisiert Bild und Ton menu.hint_audio_dd Ist diese Option aktiviert, wird automatisch auf Dolby Digital Ton geschalten, sobald dieser verfügbar ist diff --git a/data/locale/english.locale b/data/locale/english.locale index ee6af3bb7..dae69ce6b 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -128,6 +128,10 @@ audiomenu.pref_subs_head Subtitle language preferences audiomenu.spdif_dd Encoded DD on SPDIF audiomenu.stereo stereo audiomenu.volume_adjust Volume adjustment, in % +audiomenu.volume_adjustment Channel specific volume adjustment +audiomenu.volume_adjustment_ac3 AC3 streams +audiomenu.volume_adjustment_clear Clear saved values +audiomenu.volume_adjustment_pcm PCM streams audiomenu.volume_start Start volume audiomenu.volume_step Volume step audioplayer.add Add @@ -880,6 +884,9 @@ menu.cancel Cancel menu.hint_a_pic Configure audio player and picture viewer menu.hint_aplay Audio player menu.hint_audio Audio output, DD\nSRS True volume options +menu.hint_audio_adjust_vol_ac3 Channel specific volume adjustment for AC3 streams +menu.hint_audio_adjust_vol_clear Clear all saved values for PCM and AC3 streams +menu.hint_audio_adjust_vol_pcm Channel specific volume adjustment for PCM streams menu.hint_audio_analog_mode Select audio channel to use\nstereo, mono-left, mono-right menu.hint_audio_avsync A/V sync menu.hint_audio_dd Auto-switch to DolbyDigital audio pid,\nif available diff --git a/src/gui/audio_select.cpp b/src/gui/audio_select.cpp index 1a428540d..c95ff6b82 100644 --- a/src/gui/audio_select.cpp +++ b/src/gui/audio_select.cpp @@ -200,7 +200,7 @@ int CAudioSelectMenuHandler::doMenu () CVolume::getInstance()->SetCurrentPid(0); int percent[p_count]; for (uint i=0; i < p_count; i++) { - percent[i] = CZapit::getInstance()->GetPidVolume(0, g_RemoteControl->current_PIDs.APIDs[i].pid); + percent[i] = CZapit::getInstance()->GetPidVolume(0, g_RemoteControl->current_PIDs.APIDs[i].pid, g_RemoteControl->current_PIDs.APIDs[i].is_ac3); AudioSelector.addItem(new CMenuOptionNumberChooser(g_RemoteControl->current_PIDs.APIDs[i].desc, &percent[i], i == g_RemoteControl->current_PIDs.PIDs.selected_apid, 0, 999, CVolume::getInstance())); diff --git a/src/gui/audio_setup.cpp b/src/gui/audio_setup.cpp index 22290473a..031b9f0e3 100644 --- a/src/gui/audio_setup.cpp +++ b/src/gui/audio_setup.cpp @@ -45,6 +45,7 @@ #include #include +#include #include @@ -64,8 +65,14 @@ CAudioSetup::~CAudioSetup() } -int CAudioSetup::exec(CMenuTarget* parent, const std::string &/*actionKey*/) +int CAudioSetup::exec(CMenuTarget* parent, const std::string &actionKey) { + if (actionKey == "clear_vol_map") { + CZapit::getInstance()->ClearVolumeMap(); + CZapit::getInstance()->SetVolumePercent(g_settings.audio_volume_percent_ac3, g_settings.audio_volume_percent_pcm); + return menu_return::RETURN_NONE; + } + dprintf(DEBUG_DEBUG, "init audio setup\n"); int res = menu_return::RETURN_REPAINT; @@ -184,6 +191,23 @@ int CAudioSetup::showAudioSetup() CMenuOptionChooser * as_oj_srsonoff = new CMenuOptionChooser(LOCALE_AUDIO_SRS_IQ, &g_settings.srs_enable, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, &truevolSetupNotifier); as_oj_srsonoff->setHint("", LOCALE_MENU_HINT_AUDIO_SRS); + // ac3,pcm and clear volume adjustment + CMenuOptionNumberChooser *adj_ac3 = NULL, *adj_pcm = NULL; + CMenuForwarder *adj_clear = NULL; + if (!g_settings.easymenu) { + adj_ac3 = new CMenuOptionNumberChooser(LOCALE_AUDIOMENU_VOLUME_ADJUSTMENT_AC3, + (int *)&g_settings.audio_volume_percent_ac3, true, 0, 100, audioSetupNotifier); + adj_ac3->setNumberFormat("%d%%"); + adj_ac3->setHint("", LOCALE_MENU_HINT_AUDIO_ADJUST_VOL_AC3); + + adj_pcm = new CMenuOptionNumberChooser(LOCALE_AUDIOMENU_VOLUME_ADJUSTMENT_PCM, + (int *)&g_settings.audio_volume_percent_pcm, true, 0, 100, audioSetupNotifier); + adj_pcm->setNumberFormat("%d%%"); + adj_pcm->setHint("", LOCALE_MENU_HINT_AUDIO_ADJUST_VOL_PCM); + + adj_clear = new CMenuForwarder(LOCALE_AUDIOMENU_VOLUME_ADJUSTMENT_CLEAR, true, NULL, this, "clear_vol_map"); + adj_clear->setHint("", LOCALE_MENU_HINT_AUDIO_ADJUST_VOL_CLEAR); + } //paint items audioSettings->addIntroItems(LOCALE_MAINSETTINGS_AUDIO); //--------------------------------------------------------- @@ -212,6 +236,12 @@ int CAudioSetup::showAudioSetup() #if 0 audioSettings->addItem(mf); #endif + if (!g_settings.easymenu) { + audioSettings->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_AUDIOMENU_VOLUME_ADJUSTMENT)); + audioSettings->addItem(adj_ac3); + audioSettings->addItem(adj_pcm); + audioSettings->addItem(adj_clear); + } int res = audioSettings->exec(NULL, ""); selected = audioSettings->getSelected(); @@ -219,6 +249,9 @@ int CAudioSetup::showAudioSetup() #ifdef BOXMODEL_APOLLO delete as_oj_noise; #endif + if (!g_settings.easymenu) + CZapit::getInstance()->SetVolumePercent(g_settings.audio_volume_percent_ac3, g_settings.audio_volume_percent_pcm); + return res; } diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 0fcf9c9bb..afff882d1 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -365,6 +365,9 @@ int CNeutrinoApp::loadSetup(const char * fname) if (g_settings.start_volume >= 0) g_settings.current_volume = g_settings.start_volume; + g_settings.audio_volume_percent_ac3 = configfile.getInt32("audio_volume_percent_ac3", 100); + g_settings.audio_volume_percent_pcm = configfile.getInt32("audio_volume_percent_pcm", 100); + g_settings.channel_mode = configfile.getInt32("channel_mode", LIST_MODE_PROV); g_settings.channel_mode_radio = configfile.getInt32("channel_mode_radio", LIST_MODE_PROV); g_settings.channel_mode_initial = configfile.getInt32("channel_mode_initial", -1); @@ -908,6 +911,8 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setInt32( "current_volume", g_settings.current_volume ); configfile.setInt32( "current_volume_step", g_settings.current_volume_step ); configfile.setInt32( "start_volume", g_settings.start_volume ); + configfile.setInt32("audio_volume_percent_ac3", g_settings.audio_volume_percent_ac3); + configfile.setInt32("audio_volume_percent_pcm", g_settings.audio_volume_percent_pcm); configfile.setInt32( "channel_mode", g_settings.channel_mode ); configfile.setInt32( "channel_mode_radio", g_settings.channel_mode_radio ); configfile.setInt32( "channel_mode_initial", g_settings.channel_mode_initial ); @@ -2011,6 +2016,7 @@ TIMER_START(); g_audioMute = CAudioMute::getInstance(); g_audioMute->AudioMute(current_muted, true); + CZapit::getInstance()->SetVolumePercent(g_settings.audio_volume_percent_ac3, g_settings.audio_volume_percent_pcm); CVFD::getInstance()->showVolume(g_settings.current_volume); CVFD::getInstance()->setMuted(current_muted); diff --git a/src/system/locals.h b/src/system/locals.h index 4ba59ef14..6d9e28afd 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -155,6 +155,10 @@ typedef enum LOCALE_AUDIOMENU_SPDIF_DD, LOCALE_AUDIOMENU_STEREO, LOCALE_AUDIOMENU_VOLUME_ADJUST, + LOCALE_AUDIOMENU_VOLUME_ADJUSTMENT, + LOCALE_AUDIOMENU_VOLUME_ADJUSTMENT_AC3, + LOCALE_AUDIOMENU_VOLUME_ADJUSTMENT_CLEAR, + LOCALE_AUDIOMENU_VOLUME_ADJUSTMENT_PCM, LOCALE_AUDIOMENU_VOLUME_START, LOCALE_AUDIOMENU_VOLUME_STEP, LOCALE_AUDIOPLAYER_ADD, @@ -907,6 +911,9 @@ typedef enum LOCALE_MENU_HINT_A_PIC, LOCALE_MENU_HINT_APLAY, LOCALE_MENU_HINT_AUDIO, + LOCALE_MENU_HINT_AUDIO_ADJUST_VOL_AC3, + LOCALE_MENU_HINT_AUDIO_ADJUST_VOL_CLEAR, + LOCALE_MENU_HINT_AUDIO_ADJUST_VOL_PCM, LOCALE_MENU_HINT_AUDIO_ANALOG_MODE, LOCALE_MENU_HINT_AUDIO_AVSYNC, LOCALE_MENU_HINT_AUDIO_DD, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 76bf3d59b..18e8301a7 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -155,6 +155,10 @@ const char * locale_real_names[] = "audiomenu.spdif_dd", "audiomenu.stereo", "audiomenu.volume_adjust", + "audiomenu.volume_adjustment", + "audiomenu.volume_adjustment_ac3", + "audiomenu.volume_adjustment_clear", + "audiomenu.volume_adjustment_pcm", "audiomenu.volume_start", "audiomenu.volume_step", "audioplayer.add", @@ -907,6 +911,9 @@ const char * locale_real_names[] = "menu.hint_a_pic", "menu.hint_aplay", "menu.hint_audio", + "menu.hint_audio_adjust_vol_ac3", + "menu.hint_audio_adjust_vol_clear", + "menu.hint_audio_adjust_vol_pcm", "menu.hint_audio_analog_mode", "menu.hint_audio_avsync", "menu.hint_audio_dd", diff --git a/src/system/settings.h b/src/system/settings.h index 69da00d5b..9100c29d0 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -120,6 +120,8 @@ struct SNeutrinoSettings int video_43mode; #ifdef BOXMODEL_APOLLO int brightness; + int audio_volume_percent_ac3; + int audio_volume_percent_pcm; int contrast; int saturation; int enable_sd_osd; diff --git a/src/zapit/include/zapit/zapit.h b/src/zapit/include/zapit/zapit.h index e2c45e421..a60c79fb5 100644 --- a/src/zapit/include/zapit/zapit.h +++ b/src/zapit/include/zapit/zapit.h @@ -35,9 +35,6 @@ typedef std::multimap volume_map_t; typedef volume_map_t::iterator volume_map_iterator_t; typedef std::pair volume_map_range_t; -#define VOLUME_PERCENT_AC3 100 -#define VOLUME_PERCENT_PCM 100 - /* complete zapit start thread-parameters in a struct */ typedef struct ZAPIT_start_arg { @@ -148,6 +145,9 @@ class CZapit : public OpenThreads::Thread audio_map_t audio_map; volume_map_t vol_map; + OpenThreads::Mutex vol_map_mutex; + int volume_percent_ac3; + int volume_percent_pcm; //bool current_is_nvod; //bool standby; t_channel_id lastChannelRadio; @@ -210,6 +210,7 @@ class CZapit : public OpenThreads::Thread public: ~CZapit(); static CZapit * getInstance(); + void ClearVolumeMap(); virtual void LoadSettings(); virtual bool Start(Z_start_arg* ZapStart_arg); @@ -262,6 +263,7 @@ class CZapit : public OpenThreads::Thread void SetVolume(int vol); int GetVolume() { return current_volume; }; int SetVolumePercent(int percent); + void SetVolumePercent(int default_ac3, int default_pcm); bool StartPip(const t_channel_id channel_id); bool StopPip(); void Lock() { mutex.lock(); } diff --git a/src/zapit/src/zapit.cpp b/src/zapit/src/zapit.cpp index 03ac882e5..7effd06d5 100644 --- a/src/zapit/src/zapit.cpp +++ b/src/zapit/src/zapit.cpp @@ -71,6 +71,7 @@ #include #include +#include #include #include @@ -252,6 +253,7 @@ void CZapit::SaveAudioMap() void CZapit::LoadVolumeMap() { + OpenThreads::ScopedLock m_lock(vol_map_mutex); vol_map.clear(); FILE *volume_config_file = fopen(VOLUME_CONFIG_FILE, "r"); if (!volume_config_file) { @@ -271,6 +273,7 @@ void CZapit::LoadVolumeMap() void CZapit::SaveVolumeMap() { + OpenThreads::ScopedLock m_lock(vol_map_mutex); FILE *volume_config_file = fopen(VOLUME_CONFIG_FILE, "w"); if (!volume_config_file) { perror(VOLUME_CONFIG_FILE); @@ -283,6 +286,21 @@ void CZapit::SaveVolumeMap() fclose(volume_config_file); } +void CZapit::ClearVolumeMap() +{ + OpenThreads::ScopedLock m_lock(vol_map_mutex); + vol_map.clear(); + unlink(VOLUME_CONFIG_FILE); + if (current_channel) { + CZapitAudioChannel *currentAudioChannel = current_channel->getAudioChannel(); + if (currentAudioChannel && currentAudioChannel->audioChannelType == CZapitAudioChannel::AC3) { + SetVolumePercent(volume_percent_ac3); + return; + } + } + SetVolumePercent(volume_percent_pcm); +} + void CZapit::LoadSettings() { if (!configfile.loadConfig(CONFIGFILE)) @@ -781,7 +799,7 @@ void CZapit::SetPidVolume(t_channel_id channel_id, int pid, int percent) if (!pid && (channel_id == live_channel_id) && current_channel) pid = current_channel->getAudioPid(); - + OpenThreads::ScopedLock m_lock(vol_map_mutex); INFO("############################### channel %" PRIx64 " pid %x map size %d percent %d", channel_id, pid, (int)vol_map.size(), percent); volume_map_range_t pids = vol_map.equal_range(channel_id); for (volume_map_iterator_t it = pids.first; it != pids.second; ++it) { @@ -804,6 +822,7 @@ int CZapit::GetPidVolume(t_channel_id channel_id, int pid, bool ac3) if (!pid && (channel_id == live_channel_id) && current_channel) pid = current_channel->getAudioPid(); + OpenThreads::ScopedLock m_lock(vol_map_mutex); volume_map_range_t pids = vol_map.equal_range(channel_id); for (volume_map_iterator_t it = pids.first; it != pids.second; ++it) { if (it->second.first == pid) { @@ -812,12 +831,12 @@ int CZapit::GetPidVolume(t_channel_id channel_id, int pid, bool ac3) } } if (percent < 0) { - percent = ac3 ? VOLUME_PERCENT_AC3 : VOLUME_PERCENT_PCM; + percent = ac3 ? volume_percent_ac3 : volume_percent_pcm; if ((channel_id == live_channel_id) && current_channel) { for (int i = 0; i < current_channel->getAudioChannelCount(); i++) { if (pid == current_channel->getAudioPid(i)) { percent = current_channel->getAudioChannel(i)->audioChannelType == CZapitAudioChannel::AC3 ? - VOLUME_PERCENT_AC3 : VOLUME_PERCENT_PCM; + volume_percent_ac3 : volume_percent_pcm; break; } } @@ -852,6 +871,12 @@ int CZapit::SetVolumePercent(int percent) return ret; } +void CZapit::SetVolumePercent(int default_ac3, int default_pcm) +{ + volume_percent_ac3 = default_ac3; + volume_percent_pcm = default_pcm; +} + void CZapit::SetAudioStreamType(CZapitAudioChannel::ZapitAudioChannelType audioChannelType) { const char *audioStr = "UNKNOWN"; @@ -2351,7 +2376,8 @@ bool CZapit::Start(Z_start_arg *ZapStart_arg) videoDecoder->SetAudioHandle(audioDecoder->GetHandle()); - /* set initial volume with 100% */ + volume_percent_ac3 = 100; + volume_percent_pcm = 100; SetVolumePercent(100); #ifdef USE_VBI videoDecoder->OpenVBI(1);