From 00fbb189e7fe5ff8887ab66cb8a95193fc27150b Mon Sep 17 00:00:00 2001 From: AlwinEsch Date: Sat, 16 May 2015 01:25:06 +0200 Subject: [adsp] Add adsp mode processing chain settings dialog --- .../skin.confluence/720p/DialogAudioDSPManager.xml | 599 +++++++++++ project/VS2010Express/XBMC.vcxproj | 2 + project/VS2010Express/XBMC.vcxproj.filters | 5 + xbmc/cores/AudioEngine/DSPAddons/ActiveAEDSP.cpp | 12 +- xbmc/dialogs/GUIDialogContextMenu.h | 1 + xbmc/guilib/GUIWindowManager.cpp | 5 + xbmc/guilib/WindowIDs.h | 1 + xbmc/input/ButtonTranslator.cpp | 1 + xbmc/settings/dialogs/GUIDialogAudioDSPManager.cpp | 1103 ++++++++++++++++++++ xbmc/settings/dialogs/GUIDialogAudioDSPManager.h | 90 ++ xbmc/settings/dialogs/Makefile | 3 +- 11 files changed, 1820 insertions(+), 2 deletions(-) create mode 100644 addons/skin.confluence/720p/DialogAudioDSPManager.xml create mode 100644 xbmc/settings/dialogs/GUIDialogAudioDSPManager.cpp create mode 100644 xbmc/settings/dialogs/GUIDialogAudioDSPManager.h diff --git a/addons/skin.confluence/720p/DialogAudioDSPManager.xml b/addons/skin.confluence/720p/DialogAudioDSPManager.xml new file mode 100644 index 0000000000..70446276bb --- /dev/null +++ b/addons/skin.confluence/720p/DialogAudioDSPManager.xml @@ -0,0 +1,599 @@ + + + 1 + 9000 + dialogeffect + no + + 40 + 40 + + + BehindDialogFadeOut + + 0 + 0 + 1200 + 640 + $VAR[SelectBack] + dialogheader.png + + + 0 + 0 + 1200 + 40 + + dialog close button + 1120 + 15 + 64 + 32 + + - + PreviousMenu + DialogCloseButton-focus.png + DialogCloseButton.png + system.getbool(input.enablemouse) + VisibleFadeEffect + + + dialog header image + 600 + 16 + 1140 + 40 + dialogheader.png + + + window header label + 0 + 20 + 1200 + 30 + font13_title + + center + center + selected + black + + + + processing mode selection list + 30 + 70 + 1140 + 40 + 9001 + 200 + 9000 + 9000 + horizontal + 200 + + + 0 + 0 + 228 + 40 + button-nofocus.png + + + 5 + 0 + 218 + 40 + grey3 + font13_title + center + center + ListItem.Label + false + 0 + + + + + 0 + 0 + 228 + 40 + button-focus2.png + conditional + + + 5 + 0 + 218 + 40 + white + font13_title + center + center + ListItem.Label + false + 0 + + + + processing mode selection list + + + $LOCALIZE[15114] + true + noop + InputResampling + + + + $LOCALIZE[15113] + true + noop + Preprocessing + + + + $LOCALIZE[15115] + true + noop + Masterprocessing + + + + $LOCALIZE[15117] + true + noop + Postprocessing + + + + $LOCALIZE[15116] + true + noop + OutputResampling + + + + + white borders and mode description + 30 + 109 + 1140 + 500 + + blue border + 0 + 0 + 1140 + 500 + button-focus3.png + 80FFFFFF + + + current mode description label + 10 + 0 + 1120 + 30 + font12 + left + center + white + selected + + + + + available- and active mode lists + 30 + 150 + 1140 + 500 + 9001 + 9000 + + available modes group + 0 + 0 + 570 + 360 + + blue available modes + 25 + 2 + 550 + 30 + font12_title + + center + center + blue + black + + + available modes list border + 25 + 30 + 538 + 350 + button-nofocus.png + + + scrollbar for available modes list + 5 + 30 + 25 + 350 + ScrollBarV.png + ScrollBarV_bar.png + ScrollBarV_bar_focus.png + ScrollBarNib.png + ScrollBarNib.png + 61 + 20 + false + vertical + + + available modes list + 30 + 35 + 528 + 345 + 9000 + 9001 + 60 + 21 + 60 + 200 + + + 0 + 3 + 528 + 40 + button-nofocus.png + + + 15 + 8 + 30 + 30 + $INFO[ListItem.Property(Icon)] + keep + !StringCompare(ListItem.Property(Icon),"") + + + 15 + 8 + 30 + 30 + DefaultAudioDSP.png + keep + StringCompare(ListItem.Property(Icon),"") + + + active addon name and mode name + 80 + 3 + 435 + 40 + font12 + left + center + white + false + selected + + + + + + 0 + 3 + 528 + 60 + button-focus2.png + conditional + + + 5 + 8 + 50 + 50 + $INFO[ListItem.Property(Icon)] + keep + !StringCompare(ListItem.Property(Icon),"") + + + 5 + 8 + 50 + 50 + DefaultAudioDSP.png + keep + StringCompare(ListItem.Property(Icon),"") + + + addon name and mode name on focus + 80 + 3 + 435 + 40 + font12 + left + center + white + false + selected + + + + ADSP-Mode description on focus + 80 + 33 + 435 + 30 + font12 + left + center + grey2 + false + selected + + !Control.HasFocus(20) + + + ADSP-Mode description on focus + 80 + 33 + 435 + 30 + font12 + left + center + grey2 + true + > < + selected + + Control.HasFocus(20) + + + + + + 568 + 0 + 570 + 360 + + blue active modes + 10 + 2 + 550 + 30 + font12_title + + center + center + blue + black + + + active modes list border + 10 + 30 + 538 + 350 + button-nofocus.png + + + scrollbar for active modes list + 542 + 30 + 25 + 350 + ScrollBarV.png + ScrollBarV_bar.png + ScrollBarV_bar_focus.png + ScrollBarNib.png + ScrollBarNib.png + 21 + 60 + false + vertical + + + active modes list + 15 + 35 + 538 + 345 + 9000 + 9001 + 20 + 61 + 61 + 200 + + + 0 + 3 + 528 + 40 + button-nofocus.png + + + 15 + 8 + 30 + 30 + $INFO[ListItem.Property(Icon)] + keep + !StringCompare(ListItem.Property(Icon),"") + + + 15 + 8 + 30 + 30 + DefaultAudioDSP.png + keep + StringCompare(ListItem.Property(Icon),"") + + + active addon name and mode name + 80 + 3 + 435 + 40 + font12 + left + center + white + false + selected + + + + + + 0 + 3 + 528 + 60 + button-focus2.png + conditional + + + 5 + 8 + 50 + 50 + $INFO[ListItem.Property(Icon)] + keep + !StringCompare(ListItem.Property(Icon),"") + + + 5 + 8 + 50 + 50 + DefaultAudioDSP.png + keep + StringCompare(ListItem.Property(Icon),"") + + + addon name and mode name on focus + 80 + 3 + 435 + 40 + font12 + left + center + white + false + selected + + true + + + ADSP-Mode description on focus + 80 + 33 + 435 + 30 + font12 + left + center + grey2 + false + selected + + !Control.HasFocus(21) + + + ADSP-Mode description on focus + 80 + 33 + 435 + 30 + font12 + left + center + grey2 + true + > < + selected + + Control.HasFocus(21) + + + + + + + 55 + 528 + 1090 + + Default RadioButton + 0 + 15 + 40 + 280 + 200 + 9000 + 24 + 23 + 252 + font13 + grey2 + white + button-focus2.png + button-nofocus.png + + ButtonCommonValues + + + Apply changes button + 288 + 15 + 40 + 250 + 200 + 9000 + 22 + 24 + font13 + 15FFFFFF + grey3 + white + button-focus2.png + + center + + + Clear active modes button + 841 + 15 + 40 + 250 + 200 + 9000 + 23 + 22 + font13 + 30FFFFFF + grey3 + white + button-focus2.png + + center + + + + diff --git a/project/VS2010Express/XBMC.vcxproj b/project/VS2010Express/XBMC.vcxproj index 179cfc69bc..f4465991ce 100644 --- a/project/VS2010Express/XBMC.vcxproj +++ b/project/VS2010Express/XBMC.vcxproj @@ -787,6 +787,7 @@ + @@ -1034,6 +1035,7 @@ + diff --git a/project/VS2010Express/XBMC.vcxproj.filters b/project/VS2010Express/XBMC.vcxproj.filters index 2bc94026fa..ba51b16613 100644 --- a/project/VS2010Express/XBMC.vcxproj.filters +++ b/project/VS2010Express/XBMC.vcxproj.filters @@ -3098,6 +3098,9 @@ music + + settings\dialogs + test @@ -6049,6 +6052,8 @@ network\dacp + + settings\dialogs addons diff --git a/xbmc/cores/AudioEngine/DSPAddons/ActiveAEDSP.cpp b/xbmc/cores/AudioEngine/DSPAddons/ActiveAEDSP.cpp index 0f9fef4598..f36ff99d9c 100644 --- a/xbmc/cores/AudioEngine/DSPAddons/ActiveAEDSP.cpp +++ b/xbmc/cores/AudioEngine/DSPAddons/ActiveAEDSP.cpp @@ -45,6 +45,7 @@ extern "C" { #include "settings/MediaSettings.h" #include "settings/MediaSourceSettings.h" #include "settings/Settings.h" +#include "settings/dialogs/GUIDialogAudioDSPManager.h" #include "utils/StringUtils.h" #include "utils/JobManager.h" @@ -282,7 +283,16 @@ void CActiveAEDSP::OnSettingAction(const CSetting *setting) return; const std::string &settingId = setting->GetId(); - if (settingId == "audiooutput.dspresetdb") + if (settingId == "audiooutput.dspsettings") + { + if (IsActivated()) + { + CGUIDialogAudioDSPManager *dialog = (CGUIDialogAudioDSPManager *)g_windowManager.GetWindow(WINDOW_DIALOG_AUDIO_DSP_MANAGER); + if (dialog) + dialog->Open(); + } + } + else if (settingId == "audiooutput.dspresetdb") { if (CGUIDialogYesNo::ShowAndGetInput(19098, 36440, 750, 0)) { diff --git a/xbmc/dialogs/GUIDialogContextMenu.h b/xbmc/dialogs/GUIDialogContextMenu.h index 1cf08e2f24..19d65e959e 100644 --- a/xbmc/dialogs/GUIDialogContextMenu.h +++ b/xbmc/dialogs/GUIDialogContextMenu.h @@ -132,6 +132,7 @@ enum CONTEXT_BUTTON { CONTEXT_BUTTON_CANCELLED = 0, CONTEXT_BUTTON_EDIT_SORTTITLE, CONTEXT_BUTTON_UNDELETE, CONTEXT_BUTTON_DELETE_ALL, + CONTEXT_BUTTON_HELP, CONTEXT_BUTTON_USER1, CONTEXT_BUTTON_USER2, CONTEXT_BUTTON_USER3, diff --git a/xbmc/guilib/GUIWindowManager.cpp b/xbmc/guilib/GUIWindowManager.cpp index 6587e2f7c8..45e8a839e8 100644 --- a/xbmc/guilib/GUIWindowManager.cpp +++ b/xbmc/guilib/GUIWindowManager.cpp @@ -136,6 +136,7 @@ #include "dialogs/GUIDialogPlayEject.h" #include "dialogs/GUIDialogMediaFilter.h" #include "video/dialogs/GUIDialogSubtitles.h" +#include "settings/dialogs/GUIDialogAudioDSPManager.h" #ifdef HAS_KARAOKE #include "music/karaoke/GUIDialogKaraokeSongSelector.h" @@ -276,6 +277,8 @@ void CGUIWindowManager::CreateWindows() Add(new CGUIDialogPVRChannelsOSD); Add(new CGUIDialogPVRGuideOSD); + Add(new ActiveAE::CGUIDialogAudioDSPManager); + Add(new CGUIDialogSelect); Add(new CGUIDialogMusicInfo); Add(new CGUIDialogOK); @@ -372,6 +375,8 @@ bool CGUIWindowManager::DestroyWindows() Delete(WINDOW_DIALOG_PVR_OSD_GUIDE); Delete(WINDOW_DIALOG_OSD_TELETEXT); + Delete(WINDOW_DIALOG_AUDIO_DSP_MANAGER); + Delete(WINDOW_DIALOG_TEXT_VIEWER); Delete(WINDOW_DIALOG_PLAY_EJECT); Delete(WINDOW_STARTUP_ANIM); diff --git a/xbmc/guilib/WindowIDs.h b/xbmc/guilib/WindowIDs.h index 2548e2b32b..5d663aaf3a 100644 --- a/xbmc/guilib/WindowIDs.h +++ b/xbmc/guilib/WindowIDs.h @@ -104,6 +104,7 @@ #define WINDOW_DIALOG_EXT_PROGRESS 10151 #define WINDOW_DIALOG_MEDIA_FILTER 10152 #define WINDOW_DIALOG_SUBTITLES 10153 +#define WINDOW_DIALOG_AUDIO_DSP_MANAGER 10154 #define WINDOW_MUSIC_PLAYLIST 10500 #define WINDOW_MUSIC_FILES 10501 diff --git a/xbmc/input/ButtonTranslator.cpp b/xbmc/input/ButtonTranslator.cpp index 7c3ab02555..3200586303 100644 --- a/xbmc/input/ButtonTranslator.cpp +++ b/xbmc/input/ButtonTranslator.cpp @@ -353,6 +353,7 @@ static const ActionMapping windows[] = {"visualisationpresetlist" , WINDOW_DIALOG_VIS_PRESET_LIST}, {"osdvideosettings" , WINDOW_DIALOG_VIDEO_OSD_SETTINGS}, {"osdaudiosettings" , WINDOW_DIALOG_AUDIO_OSD_SETTINGS}, + {"audiodspmanager" , WINDOW_DIALOG_AUDIO_DSP_MANAGER}, {"videobookmarks" , WINDOW_DIALOG_VIDEO_BOOKMARKS}, {"filebrowser" , WINDOW_DIALOG_FILE_BROWSER}, {"networksetup" , WINDOW_DIALOG_NETWORK_SETUP}, diff --git a/xbmc/settings/dialogs/GUIDialogAudioDSPManager.cpp b/xbmc/settings/dialogs/GUIDialogAudioDSPManager.cpp new file mode 100644 index 0000000000..5ec7da844c --- /dev/null +++ b/xbmc/settings/dialogs/GUIDialogAudioDSPManager.cpp @@ -0,0 +1,1103 @@ +/* + * Copyright (C) 2012-2015 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "GUIDialogAudioDSPManager.h" + +#include "FileItem.h" +#include "cores/AudioEngine/DSPAddons/ActiveAEDSP.h" +#include "dialogs/GUIDialogTextViewer.h" +#include "dialogs/GUIDialogOK.h" +#include "dialogs/GUIDialogBusy.h" +#include "dialogs/GUIDialogYesNo.h" +#include "guilib/GUIWindowManager.h" +#include "guilib/LocalizeStrings.h" +#include "guilib/GUIListContainer.h" +#include "guilib/GUIRadioButtonControl.h" +#include "input/Key.h" +#include "utils/StringUtils.h" + +#define CONTROL_LIST_AVAILABLE 20 +#define CONTROL_LIST_ACTIVE 21 +#define CONTROL_RADIO_BUTTON_CONTINOUS_SAVING 22 +#define CONTROL_BUTTON_APPLY_CHANGES 23 +#define CONTROL_BUTTON_CLEAR_ACTIVE_MODES 24 +#define CONTROL_LIST_MODE_SELECTION 9000 + +#define LIST_AVAILABLE 0 +#define LIST_ACTIVE 1 + +#define LIST_INPUT_RESAMPLE 0 +#define LIST_PRE_PROCESS 1 +#define LIST_MASTER_PROCESS 2 +#define LIST_POST_PROCESS 3 +#define LIST_OUTPUT_RESAMPLE 4 + +using namespace std; +using namespace ActiveAE; + +typedef struct +{ + const char* sModeType; + int iModeType; +} DSP_MODE_TYPES; + +static const DSP_MODE_TYPES dsp_mode_types[] = { + { "preprocessing", AE_DSP_MODE_TYPE_PRE_PROCESS }, + { "inputresampling", AE_DSP_MODE_TYPE_INPUT_RESAMPLE }, + { "masterprocessing", AE_DSP_MODE_TYPE_MASTER_PROCESS }, + { "outputresampling", AE_DSP_MODE_TYPE_OUTPUT_RESAMPLE }, + { "postprocessing", AE_DSP_MODE_TYPE_POST_PROCESS }, + { "undefined", AE_DSP_MODE_TYPE_UNDEFINED } +}; + +CGUIDialogAudioDSPManager::CGUIDialogAudioDSPManager(void) + : CGUIDialog(WINDOW_DIALOG_AUDIO_DSP_MANAGER, "DialogAudioDSPManager.xml") +{ + m_bMovingMode = false; + m_bContainsChanges = false; + m_bContinousSaving = true; + m_iSelected[LIST_AVAILABLE] = 0; + m_iSelected[LIST_ACTIVE] = 0; + + for (int ii = 0; ii < AE_DSP_MODE_TYPE_MAX; ii++) + { + m_activeItems[ii] = new CFileItemList; + m_availableItems[ii] = new CFileItemList; + } + + m_iCurrentType = AE_DSP_MODE_TYPE_MASTER_PROCESS; +} + +CGUIDialogAudioDSPManager::~CGUIDialogAudioDSPManager(void) +{ + for (int ii = 0; ii < AE_DSP_MODE_TYPE_MAX; ii++) + { + delete m_activeItems[ii]; + delete m_availableItems[ii]; + } +} + +bool CGUIDialogAudioDSPManager::OnActionMove(const CAction &action) +{ + bool bReturn(false); + int iActionId = action.GetID(); + + if (GetFocusedControlID() == CONTROL_LIST_ACTIVE) + { + if (iActionId == ACTION_MOUSE_MOVE) + { + int iSelected = m_activeViewControl.GetSelectedItem(); + if (m_iSelected[LIST_ACTIVE] < iSelected) + { + iActionId = ACTION_MOVE_DOWN; + } + else if (m_iSelected[LIST_ACTIVE] > iSelected) + { + iActionId = ACTION_MOVE_UP; + } + else + { + return bReturn; + } + } + + if (iActionId == ACTION_MOVE_DOWN || iActionId == ACTION_MOVE_UP || + iActionId == ACTION_PAGE_DOWN || iActionId == ACTION_PAGE_UP) + { + bReturn = true; + CGUIDialog::OnAction(action); + + int iSelected = m_activeViewControl.GetSelectedItem(); + if (!m_bMovingMode) + { + if (iSelected != m_iSelected[LIST_ACTIVE]) + { + m_iSelected[LIST_ACTIVE] = iSelected; + } + } + else + { + bool bMoveUp = iActionId == ACTION_PAGE_UP || iActionId == ACTION_MOVE_UP; + unsigned int iLines = bMoveUp ? abs(m_iSelected[LIST_ACTIVE] - iSelected) : 1; + bool bOutOfBounds = bMoveUp ? m_iSelected[LIST_ACTIVE] <= 0 : m_iSelected[LIST_ACTIVE] >= m_activeItems[m_iCurrentType]->Size() - 1; + if (bOutOfBounds) + { + bMoveUp = !bMoveUp; + iLines = m_activeItems[m_iCurrentType]->Size() - 1; + } + + string strNumber; + for (unsigned int iLine = 0; iLine < iLines; iLine++) + { + unsigned int iNewSelect = bMoveUp ? m_iSelected[LIST_ACTIVE] - 1 : m_iSelected[LIST_ACTIVE] + 1; + if (m_activeItems[m_iCurrentType]->Get(iNewSelect)->GetProperty("Number").asString() != "-") + { + strNumber = StringUtils::Format("%i", m_iSelected[LIST_ACTIVE]+1); + m_activeItems[m_iCurrentType]->Get(iNewSelect)->SetProperty("Number", strNumber); + strNumber = StringUtils::Format("%i", iNewSelect+1); + m_activeItems[m_iCurrentType]->Get(m_iSelected[LIST_ACTIVE])->SetProperty("Number", strNumber); + } + m_activeItems[m_iCurrentType]->Swap(iNewSelect, m_iSelected[LIST_ACTIVE]); + m_iSelected[LIST_ACTIVE] = iNewSelect; + } + + SET_CONTROL_FOCUS(CONTROL_LIST_ACTIVE, 0); + + m_activeViewControl.SetItems(*m_activeItems[m_iCurrentType]); + m_activeViewControl.SetSelectedItem(m_iSelected[LIST_ACTIVE]); + } + } + } + + return bReturn; +} + +bool CGUIDialogAudioDSPManager::OnAction(const CAction& action) +{ + return OnActionMove(action) || + CGUIDialog::OnAction(action); +} + +void CGUIDialogAudioDSPManager::OnInitWindow() +{ + CGUIDialog::OnInitWindow(); + + m_iSelected[LIST_AVAILABLE] = 0; + m_iSelected[LIST_ACTIVE] = 0; + m_bMovingMode = false; + m_bContainsChanges = false; + + CGUIRadioButtonControl *radioButton = dynamic_cast(GetControl(CONTROL_RADIO_BUTTON_CONTINOUS_SAVING)); + CGUIButtonControl *applyButton = dynamic_cast(GetControl(CONTROL_BUTTON_APPLY_CHANGES)); + if (!radioButton || !applyButton) + { + helper_LogError(__FUNCTION__); + return; + } + + SET_CONTROL_SELECTED(GetID(), CONTROL_RADIO_BUTTON_CONTINOUS_SAVING, m_bContinousSaving); + applyButton->SetEnabled(!m_bContinousSaving); + + Update(); + SetSelectedModeType(); +} + +void CGUIDialogAudioDSPManager::OnDeinitWindow(int nextWindowID) +{ + if (m_bContainsChanges) + { + if (m_bContinousSaving) + { + SaveList(); + } + else + { + bool canceled; + if (CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(19098), g_localizeStrings.Get(15079), canceled, "", "")) +// if (CGUIDialogYesNo::ShowAndGetInput(19098, 15079, -1, -1)) + { + SaveList(); + } + else + { + m_bContinousSaving = false; + } + } + } + + Clear(); + + CGUIDialog::OnDeinitWindow(nextWindowID); +} + +bool CGUIDialogAudioDSPManager::OnClickListAvailable(CGUIMessage &message) +{ + int iAction = message.GetParam1(); + int iItem = m_availableViewControl.GetSelectedItem(); + + /* Check file item is in list range and get his pointer */ + if (iItem < 0 || iItem >= (int)m_availableItems[m_iCurrentType]->Size()) return true; + + /* Process actions */ + if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_CONTEXT_MENU || iAction == ACTION_MOUSE_LEFT_CLICK || iAction == ACTION_MOUSE_RIGHT_CLICK) + { + /* Show Contextmenu */ + OnPopupMenu(iItem, LIST_AVAILABLE); + + return true; + } + + return false; +} + +bool CGUIDialogAudioDSPManager::OnClickListActive(CGUIMessage &message) +{ + if (!m_bMovingMode) + { + int iAction = message.GetParam1(); + int iItem = m_activeViewControl.GetSelectedItem(); + + /* Check file item is in list range and get his pointer */ + if (iItem < 0 || iItem >= (int)m_activeItems[m_iCurrentType]->Size()) return true; + + /* Process actions */ + if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_CONTEXT_MENU || iAction == ACTION_MOUSE_LEFT_CLICK || iAction == ACTION_MOUSE_RIGHT_CLICK) + { + /* Show Contextmenu */ + OnPopupMenu(iItem, LIST_ACTIVE); + + return true; + } + } + else + { + CFileItemPtr pItem = m_activeItems[m_iCurrentType]->Get(m_iSelected[LIST_ACTIVE]); + if (pItem) + { + pItem->Select(false); + pItem->SetProperty("Changed", true); + m_bMovingMode = false; + m_bContainsChanges = true; + + if (m_bContinousSaving) + { + SaveList(); + } + + CGUIListContainer *modeList = dynamic_cast(GetControl(CONTROL_LIST_MODE_SELECTION)); + CGUIButtonControl *applyButton = dynamic_cast(GetControl(CONTROL_BUTTON_APPLY_CHANGES)); + CGUIButtonControl *clearActiveModesButton = dynamic_cast(GetControl(CONTROL_BUTTON_CLEAR_ACTIVE_MODES)); + if (!modeList || !applyButton || !clearActiveModesButton) + { + helper_LogError(__FUNCTION__); + return false; + } + + // reenable all buttons and mode selection list + modeList->SetEnabled(true); + clearActiveModesButton->SetEnabled(true); + if (!m_bContinousSaving) + { + applyButton->SetEnabled(true); + } + + return true; + } + } + + return false; +} + +bool CGUIDialogAudioDSPManager::OnClickRadioContinousSaving(CGUIMessage &message) +{ + CGUIRadioButtonControl *radioButton = dynamic_cast(GetControl(CONTROL_RADIO_BUTTON_CONTINOUS_SAVING)); + CGUIButtonControl *applyChangesButton = dynamic_cast(GetControl(CONTROL_BUTTON_APPLY_CHANGES)); + + if (!radioButton || !applyChangesButton) + { + helper_LogError(__FUNCTION__); + return false; + } + + if (!radioButton->IsSelected()) + { + applyChangesButton->SetEnabled(true); + m_bContinousSaving = false; + } + else + { + m_bContinousSaving = true; + applyChangesButton->SetEnabled(false); + } + + return true; +} + +bool CGUIDialogAudioDSPManager::OnClickApplyChanges(CGUIMessage &message) +{ + SaveList(); + return true; +} + +bool CGUIDialogAudioDSPManager::OnClickClearActiveModes(CGUIMessage &message) +{ + if (m_activeItems[m_iCurrentType]->Size() > 0) + { + for (int iItem = 0; iItem < m_activeItems[m_iCurrentType]->Size(); iItem++) + { + CFileItemPtr pItem = m_activeItems[m_iCurrentType]->Get(iItem); + if (pItem) + { + // remove mode from active mode list and add it to available mode list + CFileItemPtr newItem(dynamic_cast(pItem->Clone())); + newItem->SetProperty("ActiveMode", false); + newItem->SetProperty("Changed", true); + m_availableItems[m_iCurrentType]->Add(newItem); + } + } + m_activeItems[m_iCurrentType]->Clear(); + + // reorder available mode list, so that the mode order is always consistent + m_availableItems[m_iCurrentType]->ClearSortState(); + m_availableItems[m_iCurrentType]->Sort(SortByLabel, SortOrderAscending); + + // update active and available mode list + m_availableViewControl.SetItems(*m_availableItems[m_iCurrentType]); + m_activeViewControl.SetItems(*m_activeItems[m_iCurrentType]); + + m_bContainsChanges = true; + if (m_bContinousSaving) + { + SaveList(); + } + } + + return true; +} + +bool CGUIDialogAudioDSPManager::OnMessageClick(CGUIMessage &message) +{ + int iControl = message.GetSenderId(); + switch(iControl) + { + case CONTROL_LIST_AVAILABLE: + return OnClickListAvailable(message); + case CONTROL_LIST_ACTIVE: + return OnClickListActive(message); + case CONTROL_RADIO_BUTTON_CONTINOUS_SAVING: + return OnClickRadioContinousSaving(message); + case CONTROL_BUTTON_CLEAR_ACTIVE_MODES: + return OnClickClearActiveModes(message); + case CONTROL_BUTTON_APPLY_CHANGES: + return OnClickApplyChanges(message); + default: + return false; + } +} + +bool CGUIDialogAudioDSPManager::OnMessage(CGUIMessage& message) +{ + unsigned int iMessage = message.GetMessage(); + + switch (iMessage) + { + case GUI_MSG_CLICKED: + return OnMessageClick(message); + + case GUI_MSG_ITEM_SELECT: + { + int focusedControl = GetFocusedControlID(); + if (focusedControl == CONTROL_LIST_MODE_SELECTION) + { + CGUIListContainer *modeListPtr = dynamic_cast(GetControl(CONTROL_LIST_MODE_SELECTION)); + + if (modeListPtr) + { + CGUIListItemPtr modeListItem = modeListPtr->GetListItem(0); // get current selected list item + if (modeListItem) + { + string currentModeString = modeListItem->GetProperty("currentMode").asString(); + int newModeType = helper_TranslateModeType(currentModeString); + + if (m_iCurrentType != newModeType) + { + m_iCurrentType = newModeType; + SetSelectedModeType(); + } + } + } + } + } + } + + return CGUIDialog::OnMessage(message); +} + +void CGUIDialogAudioDSPManager::OnWindowLoaded(void) +{ + g_graphicsContext.Lock(); + + m_availableViewControl.Reset(); + m_availableViewControl.SetParentWindow(GetID()); + m_availableViewControl.AddView(GetControl(CONTROL_LIST_AVAILABLE)); + + m_activeViewControl.Reset(); + m_activeViewControl.SetParentWindow(GetID()); + m_activeViewControl.AddView(GetControl(CONTROL_LIST_ACTIVE)); + + g_graphicsContext.Unlock(); + + CGUIDialog::OnWindowLoaded(); +} + +void CGUIDialogAudioDSPManager::OnWindowUnload(void) +{ + CGUIDialog::OnWindowUnload(); + + m_availableViewControl.Reset(); + m_activeViewControl.Reset(); +} + +bool CGUIDialogAudioDSPManager::OnPopupMenu(int iItem, int listType) +{ + // popup the context menu + // grab our context menu + CContextButtons buttons; + int listSize = 0; + CFileItemPtr pItem; + + if (listType == LIST_ACTIVE) + { + listSize = m_activeItems[m_iCurrentType]->Size(); + pItem = m_activeItems[m_iCurrentType]->Get(iItem); + } + else if (listType == LIST_AVAILABLE) + { + listSize = m_availableItems[m_iCurrentType]->Size(); + pItem = m_availableItems[m_iCurrentType]->Get(iItem); + } + + if (!pItem) + { + return false; + } + + // mark the item + if (iItem >= 0 && iItem < listSize) + { + pItem->Select(true); + } + else + { + return false; + } + + if (listType == LIST_ACTIVE) + { + if (listSize > 1) + { + buttons.Add(CONTEXT_BUTTON_MOVE, 116); /* Move mode up or down */ + } + buttons.Add(CONTEXT_BUTTON_ACTIVATE, 24021); /* Used to deactivate addon process type */ + } + else if (listType == LIST_AVAILABLE) + { + if (m_activeItems[m_iCurrentType]->Size() > 0 && (m_iCurrentType == AE_DSP_MODE_TYPE_INPUT_RESAMPLE || m_iCurrentType == AE_DSP_MODE_TYPE_OUTPUT_RESAMPLE)) + { + buttons.Add(CONTEXT_BUTTON_ACTIVATE, 15080); /* Used to swap addon resampling process type */ + } + else + { + buttons.Add(CONTEXT_BUTTON_ACTIVATE, 24022); /* Used to activate addon process type */ + } + } + + if (pItem->GetProperty("SettingsDialog").asInteger() != 0) + { + buttons.Add(CONTEXT_BUTTON_SETTINGS, 15078); /* Used to activate addon process type help description*/ + } + + if (pItem->GetProperty("Help").asInteger() > 0) + { + buttons.Add(CONTEXT_BUTTON_HELP, 15062); /* Used to activate addon process type help description*/ + } + + int choice = CGUIDialogContextMenu::ShowAndGetChoice(buttons); + + // deselect our item + if (iItem >= 0 && iItem < listSize) + { + pItem->Select(false); + } + + if (choice < 0) + { + return false; + } + + return OnContextButton(iItem, (CONTEXT_BUTTON)choice, listType); +} + +bool CGUIDialogAudioDSPManager::OnContextButton(int itemNumber, CONTEXT_BUTTON button, int listType) +{ + CFileItemPtr pItem; + int listSize = 0; + if (listType == LIST_ACTIVE) + { + pItem = m_activeItems[m_iCurrentType]->Get(itemNumber); + listSize = m_activeItems[m_iCurrentType]->Size(); + } + else if (listType == LIST_AVAILABLE) + { + pItem = m_availableItems[m_iCurrentType]->Get(itemNumber); + listSize = m_availableItems[m_iCurrentType]->Size(); + } + + /* Check file item is in list range and get his pointer */ + if (!pItem || itemNumber < 0 || itemNumber >= listSize) + { + return false; + } + + if (button == CONTEXT_BUTTON_HELP) + { + /*! + * Open audio dsp addon mode help text dialog + */ + AE_DSP_ADDON addon; + if (CActiveAEDSP::Get().GetAudioDSPAddon((int)pItem->GetProperty("AddonId").asInteger(), addon)) + { + CGUIDialogTextViewer* pDlgInfo = (CGUIDialogTextViewer*)g_windowManager.GetWindow(WINDOW_DIALOG_TEXT_VIEWER); + pDlgInfo->SetHeading(g_localizeStrings.Get(15062) + " - " + pItem->GetProperty("Name").asString()); + pDlgInfo->SetText(addon->GetString((uint32_t)pItem->GetProperty("Help").asInteger())); + pDlgInfo->DoModal(); + } + } + else if (button == CONTEXT_BUTTON_ACTIVATE) + { + /*! + * Deactivate selected processing mode + */ + if (pItem->GetProperty("ActiveMode").asBoolean()) + { + // remove mode from active mode list and add it to available mode list + CFileItemPtr newItem(dynamic_cast(pItem->Clone())); + newItem->SetProperty("ActiveMode", false); + newItem->SetProperty("Changed", true); + m_activeItems[m_iCurrentType]->Remove(itemNumber); + m_availableItems[m_iCurrentType]->Add(newItem); + } + else + { + /*! + * Activate selected processing mode + */ + if ((m_iCurrentType == AE_DSP_MODE_TYPE_INPUT_RESAMPLE || m_iCurrentType == AE_DSP_MODE_TYPE_OUTPUT_RESAMPLE) && m_activeItems[m_iCurrentType]->Size() > 0) + { // if there is already an active resampler, now we remove it + CFileItemPtr activeResampler = m_activeItems[m_iCurrentType]->Get(0); + if (activeResampler) + { + CFileItemPtr newItem(dynamic_cast(activeResampler->Clone())); + newItem->SetProperty("ActiveMode", false); + newItem->SetProperty("Changed", true); + + m_availableItems[m_iCurrentType]->Add(newItem); + // clear active list, because only one active resampling mode is supported by ActiveAEDSP + m_activeItems[m_iCurrentType]->Clear(); + } + } + + // remove mode from available mode list and add it to active mode list + CFileItemPtr newItem(dynamic_cast(pItem->Clone())); + + newItem->SetProperty("Number", (int)m_activeItems[m_iCurrentType]->Size() +1); + newItem->SetProperty("Changed", true); + newItem->SetProperty("ActiveMode", true); + + m_availableItems[m_iCurrentType]->Remove(itemNumber); + m_activeItems[m_iCurrentType]->Add(newItem); + } + + m_bContainsChanges = true; + if (m_bContinousSaving) + { + SaveList(); + } + + // reorder available mode list, so that the mode order is always consistent + m_availableItems[m_iCurrentType]->ClearSortState(); + m_availableItems[m_iCurrentType]->Sort(SortByLabel, SortOrderAscending); + + // update active and available mode list + Renumber(); + m_availableViewControl.SetItems(*m_availableItems[m_iCurrentType]); + m_activeViewControl.SetItems(*m_activeItems[m_iCurrentType]); + } + else if (button == CONTEXT_BUTTON_MOVE) + { + m_bMovingMode = true; + pItem->Select(true); + + CGUIListContainer *modeList = dynamic_cast(GetControl(CONTROL_LIST_MODE_SELECTION)); + CGUIButtonControl *applyButton = dynamic_cast(GetControl(CONTROL_BUTTON_APPLY_CHANGES)); + CGUIButtonControl *clearActiveModesButton = dynamic_cast(GetControl(CONTROL_BUTTON_CLEAR_ACTIVE_MODES)); + if (!modeList || !applyButton || !clearActiveModesButton) + { + helper_LogError(__FUNCTION__); + return false; + } + + // if we are in MovingMode all buttons and mode selection list will be disabled! + modeList->SetEnabled(false); + clearActiveModesButton->SetEnabled(false); + if (!m_bContinousSaving) + { + applyButton->SetEnabled(false); + } + } + else if (button == CONTEXT_BUTTON_SETTINGS) + { + int hookId = (int)pItem->GetProperty("SettingsDialog").asInteger(); + if (hookId > 0) + { + AE_DSP_ADDON addon; + if (CActiveAEDSP::Get().GetAudioDSPAddon((int)pItem->GetProperty("AddonId").asInteger(), addon)) + { + AE_DSP_MENUHOOK hook; + AE_DSP_MENUHOOK_DATA hookData; + + hook.category = AE_DSP_MENUHOOK_ALL; + hook.iHookId = hookId; + hook.iRelevantModeId = (unsigned int)pItem->GetProperty("AddonModeNumber").asInteger(); + hookData.category = AE_DSP_MENUHOOK_ALL; + hookData.data.iStreamId = -1; + + /*! + * @note the addon dialog becomes always opened on the back of Kodi ones for this reason a + * "Conditional" + * on skin is needed to hide dialog. + */ + addon->CallMenuHook(hook, hookData); + } + } + else + { + CGUIDialogOK::ShowAndGetInput(19033, 0, 15040, 0); + } + } + + return true; +} + +void CGUIDialogAudioDSPManager::Update() +{ + CGUIDialogBusy* pDlgBusy = (CGUIDialogBusy*)g_windowManager.GetWindow(WINDOW_DIALOG_BUSY); + if (!pDlgBusy) + { + helper_LogError(__FUNCTION__); + return; + } + pDlgBusy->Show(); + + Clear(); + + AE_DSP_MODELIST modes; + CActiveAEDSPDatabase db; + if (!db.Open()) + { + pDlgBusy->Close(); + CLog::Log(LOGERROR, "DSP Manager - %s - Could not open DSP database for update!", __FUNCTION__); + return; + } + + for (int iModeType = 0; iModeType < AE_DSP_MODE_TYPE_MAX; iModeType++) + { + modes.clear(); + db.GetModes(modes, iModeType); + + // No modes available, nothing to do. + if (!modes.empty()) + { + AE_DSP_MENUHOOK_CAT menuHook = helper_GetMenuHookCategory(iModeType); + int continuesNo = 1; + for (unsigned int iModePtr = 0; iModePtr < modes.size(); iModePtr++) + { + CFileItem *listItem = helper_CreateModeListItem(modes[iModePtr].first, menuHook, &continuesNo); + if (listItem) + { + CFileItemPtr pItem(listItem); + + if (pItem->GetProperty("ActiveMode").asBoolean()) + { + m_activeItems[iModeType]->Add(pItem); + } + else + { + m_availableItems[iModeType]->Add(pItem); + } + } + g_windowManager.ProcessRenderLoop(false); + } + + m_availableItems[iModeType]->Sort(SortByLabel, SortOrderAscending); + if (iModeType == AE_DSP_MODE_TYPE_MASTER_PROCESS) + { + m_activeItems[iModeType]->Sort(SortByLabel, SortOrderAscending); + } + + } + } + + db.Close(); + + pDlgBusy->Close(); +} + +void CGUIDialogAudioDSPManager::SetSelectedModeType(void) +{ + /* lock our display, as this window is rendered from the player thread */ + g_graphicsContext.Lock(); + if (m_iCurrentType > AE_DSP_MODE_TYPE_UNDEFINED && m_iCurrentType < AE_DSP_MODE_TYPE_MAX && !m_bMovingMode) + { + m_availableViewControl.SetCurrentView(CONTROL_LIST_AVAILABLE); + m_activeViewControl.SetCurrentView(CONTROL_LIST_ACTIVE); + + m_availableViewControl.SetItems(*m_availableItems[m_iCurrentType]); + m_activeViewControl.SetItems(*m_activeItems[m_iCurrentType]); + } + + g_graphicsContext.Unlock(); +} + +void CGUIDialogAudioDSPManager::Clear(void) +{ + m_availableViewControl.Clear(); + m_activeViewControl.Clear(); + + for (int ii = 0; ii < AE_DSP_MODE_TYPE_MAX; ii++) + { + m_activeItems[ii]->Clear(); + m_availableItems[ii]->Clear(); + } +} + +void CGUIDialogAudioDSPManager::SaveList(void) +{ + if (!m_bContainsChanges) + return; + + /* display the progress dialog */ + CGUIDialogBusy* pDlgBusy = (CGUIDialogBusy*)g_windowManager.GetWindow(WINDOW_DIALOG_BUSY); + if (!pDlgBusy) + { + helper_LogError(__FUNCTION__); + return; + } + pDlgBusy->Show(); + + /* persist all modes */ + if (UpdateDatabase(pDlgBusy)) + { + CActiveAEDSP::Get().TriggerModeUpdate(); + + m_bContainsChanges = false; + SetItemsUnchanged(); + } + + pDlgBusy->Close(); +} + +bool CGUIDialogAudioDSPManager::UpdateDatabase(CGUIDialogBusy* pDlgBusy) +{ + CActiveAEDSPDatabase db; + if (!db.Open()) + { + CLog::Log(LOGERROR, "DSP Manager - %s - Could not open DSP database for update!", __FUNCTION__); + return false; + } + + // calculate available items + int maxItems = 0; + for (int i = 0; i < AE_DSP_MODE_TYPE_MAX; i++) + { + maxItems += m_activeItems[i]->Size() + m_availableItems[i]->Size(); + } + + int processedItems = 0; + for (int i = 0; i < AE_DSP_MODE_TYPE_MAX; i++) + { + for (int iListPtr = 0; iListPtr < m_activeItems[i]->Size(); iListPtr++) + { + CFileItemPtr pItem = m_activeItems[i]->Get(iListPtr); + if (pItem->GetProperty("Changed").asBoolean()) + { + bool success = db.UpdateMode( i, + pItem->GetProperty("ActiveMode").asBoolean(), + (int)pItem->GetProperty("AddonId").asInteger(), + (int)pItem->GetProperty("AddonModeNumber").asInteger(), + (int)pItem->GetProperty("Number").asInteger()); + + if (!success) + { + CLog::Log(LOGERROR, "DSP Manager - Could not update DSP database for active mode %i - %s!", + (int)pItem->GetProperty("AddonModeNumber").asInteger(), + pItem->GetProperty("Name").asString().c_str()); + } + } + + processedItems++; + if (pDlgBusy) + { + pDlgBusy->SetProgress((float)(processedItems * 100 / maxItems)); + + if (pDlgBusy->IsCanceled()) + { + return false; + } + } + + g_windowManager.ProcessRenderLoop(false); + } + + for (int iListPtr = 0; iListPtr < m_availableItems[i]->Size(); iListPtr++) + { + CFileItemPtr pItem = m_availableItems[i]->Get(iListPtr); + if (pItem && pItem->GetProperty("Changed").asBoolean()) + { + bool success = db.UpdateMode( i, + pItem->GetProperty("ActiveMode").asBoolean(), + (int)pItem->GetProperty("AddonId").asInteger(), + (int)pItem->GetProperty("AddonModeNumber").asInteger(), + (int)pItem->GetProperty("Number").asInteger()); + + if (!success) + { + CLog::Log(LOGERROR, "DSP Manager - Could not update DSP database for available mode %i - %s!", + (int)pItem->GetProperty("AddonModeNumber").asInteger(), + pItem->GetProperty("Name").asString().c_str()); + } + } + + processedItems++; + if (pDlgBusy) + { + pDlgBusy->SetProgress((float)(processedItems * 100 / maxItems)); + + if (pDlgBusy->IsCanceled()) + { + return false; + } + } + + g_windowManager.ProcessRenderLoop(false); + } + } + db.Close(); + return true; +} + +void CGUIDialogAudioDSPManager::SetItemsUnchanged() +{ + for (int i = 0; i < AE_DSP_MODE_TYPE_MAX; i++) + { + for (int iItemPtr = 0; iItemPtr < m_activeItems[i]->Size(); iItemPtr++) + { + CFileItemPtr pItem = m_activeItems[i]->Get(iItemPtr); + if (pItem) + pItem->SetProperty("Changed", false); + } + + for (int iItemPtr = 0; iItemPtr < m_availableItems[i]->Size(); iItemPtr++) + { + CFileItemPtr pItem = m_availableItems[i]->Get(iItemPtr); + if (pItem) + pItem->SetProperty("Changed", false); + } + } +} + +void CGUIDialogAudioDSPManager::Renumber(void) +{ + int iNextModeNumber(0); + string strNumber; + CFileItemPtr pItem; + + for (int iModePtr = 0; iModePtr < m_activeItems[m_iCurrentType]->Size(); iModePtr++) + { + pItem = m_activeItems[m_iCurrentType]->Get(iModePtr); + strNumber = StringUtils::Format("%i", ++iNextModeNumber); + pItem->SetProperty("Number", strNumber); + } +} + + +//! ---- Helper functions ---- + +void CGUIDialogAudioDSPManager::helper_LogError(const char *function) +{ + CLog::Log(LOGERROR, "DSP Manager - %s - GUI value error", function); +} + +int CGUIDialogAudioDSPManager::helper_TranslateModeType(string ModeString) +{ + int iType = AE_DSP_MODE_TYPE_UNDEFINED; + for (unsigned int ii = 0; ii < ARRAY_SIZE(dsp_mode_types) && iType == AE_DSP_MODE_TYPE_UNDEFINED; ii++) + { + if (StringUtils::EqualsNoCase(ModeString, dsp_mode_types[ii].sModeType)) + { + iType = dsp_mode_types[ii].iModeType; + } + } + + return iType; +} + +CFileItem *CGUIDialogAudioDSPManager::helper_CreateModeListItem(CActiveAEDSPModePtr &ModePointer, AE_DSP_MENUHOOK_CAT &MenuHook, int *ContinuesNo) +{ + CFileItem *pItem = NULL; + + if (!ContinuesNo) + { + return pItem; + } + + // start to get Addon and Mode properties + const int AddonID = ModePointer->AddonID(); + + string addonName; + if (!CActiveAEDSP::Get().GetAudioDSPAddonName(AddonID, addonName)) + { + return pItem; + } + + AE_DSP_ADDON addon; + if (!CActiveAEDSP::Get().GetAudioDSPAddon(AddonID, addon)) + { + return pItem; + } + + string modeName = addon->GetString(ModePointer->ModeName()); + + string description; + if (ModePointer->ModeDescription() > -1) + { + description = addon->GetString(ModePointer->ModeDescription()); + } + else + { + description = g_localizeStrings.Get(15063); + } + + bool isActive = ModePointer->IsEnabled(); + int number = ModePointer->ModePosition(); + int dialogId = helper_GetDialogId(ModePointer, MenuHook, addon, addonName); + // end to get Addon and Mode properties + + if (isActive) + { + if (number <= 0) + { + number = *ContinuesNo; + (*ContinuesNo)++; + } + + string str = StringUtils::Format("%i:%i:%i:%s", + number, + AddonID, + ModePointer->AddonModeNumber(), + ModePointer->AddonModeName().c_str()); + + pItem = new CFileItem(str); + } + else + { + pItem = new CFileItem(modeName); + } + + // set list item properties + pItem->SetProperty("ActiveMode", isActive); + pItem->SetProperty("Number", number); + pItem->SetProperty("Name", modeName); + pItem->SetProperty("Description", description); + pItem->SetProperty("Help", ModePointer->ModeHelp()); + pItem->SetProperty("Icon", ModePointer->IconOwnModePath()); + pItem->SetProperty("SettingsDialog", dialogId); + pItem->SetProperty("AddonId", AddonID); + pItem->SetProperty("AddonModeNumber", ModePointer->AddonModeNumber()); + pItem->SetProperty("AddonName", addonName); + pItem->SetProperty("Changed", false); + + return pItem; +} + +int CGUIDialogAudioDSPManager::helper_GetDialogId(CActiveAEDSPModePtr &ModePointer, AE_DSP_MENUHOOK_CAT &MenuHook, AE_DSP_ADDON &Addon, string AddonName) +{ + int dialogId = 0; + + if (ModePointer->HasSettingsDialog()) + { + AE_DSP_MENUHOOKS hooks; + + // Find first general settings dialog about mode + if (CActiveAEDSP::Get().GetMenuHooks(ModePointer->AddonID(), AE_DSP_MENUHOOK_SETTING, hooks)) + { + for (unsigned int i = 0; i < hooks.size() && dialogId == 0; i++) + { + if (hooks[i].iRelevantModeId == ModePointer->AddonModeNumber()) + { + dialogId = hooks[i].iHookId; + } + } + } + + // If nothing was present, check for playback settings + if (dialogId == 0 && CActiveAEDSP::Get().GetMenuHooks(ModePointer->AddonID(), MenuHook, hooks)) + { + for (unsigned int i = 0; i < hooks.size() && (dialogId == 0 || dialogId != -1); i++) + { + if (hooks[i].iRelevantModeId == ModePointer->AddonModeNumber()) + { + if (!hooks[i].bNeedPlayback) + { + dialogId = hooks[i].iHookId; + } + else + { + dialogId = -1; + } + } + } + } + + if (dialogId == 0) + CLog::Log(LOGERROR, "DSP Dialog Manager - %s - Present marked settings dialog of mode %s on addon %s not found", + __FUNCTION__, + Addon->GetString(ModePointer->ModeName()).c_str(), + AddonName.c_str()); + } + + return dialogId; +} + +AE_DSP_MENUHOOK_CAT CGUIDialogAudioDSPManager::helper_GetMenuHookCategory(int CurrentType) +{ + AE_DSP_MENUHOOK_CAT menuHook = AE_DSP_MENUHOOK_ALL; + switch (CurrentType) + { + case AE_DSP_MODE_TYPE_PRE_PROCESS: + menuHook = AE_DSP_MENUHOOK_PRE_PROCESS; + break; + case AE_DSP_MODE_TYPE_MASTER_PROCESS: + menuHook = AE_DSP_MENUHOOK_MASTER_PROCESS; + break; + case AE_DSP_MODE_TYPE_POST_PROCESS: + menuHook = AE_DSP_MENUHOOK_POST_PROCESS; + break; + case AE_DSP_MODE_TYPE_INPUT_RESAMPLE: + case AE_DSP_MODE_TYPE_OUTPUT_RESAMPLE: + menuHook = AE_DSP_MENUHOOK_RESAMPLE; + break; + default: + menuHook = AE_DSP_MENUHOOK_ALL; + break; + }; + + return menuHook; +} diff --git a/xbmc/settings/dialogs/GUIDialogAudioDSPManager.h b/xbmc/settings/dialogs/GUIDialogAudioDSPManager.h new file mode 100644 index 0000000000..df024d23c0 --- /dev/null +++ b/xbmc/settings/dialogs/GUIDialogAudioDSPManager.h @@ -0,0 +1,90 @@ +#pragma once +/* + * Copyright (C) 2012-2015 Team KODI + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with KODI; see the file COPYING. If not, see + * . + * + */ + +#include "addons/include/kodi_adsp_types.h" +#include "cores/AudioEngine/DSPAddons/ActiveAEDSPMode.h" +#include "dialogs/GUIDialogContextMenu.h" +#include "guilib/GUIDialog.h" +#include "view/GUIViewControl.h" + +class CGUIDialogBusy; + +namespace ActiveAE +{ + class CGUIDialogAudioDSPManager : public CGUIDialog + { + public: + CGUIDialogAudioDSPManager(void); + virtual ~CGUIDialogAudioDSPManager(void); + virtual bool OnMessage(CGUIMessage& message); + virtual bool OnAction(const CAction& action); + virtual void OnWindowLoaded(void); + virtual void OnWindowUnload(void); + virtual bool HasListItems() const { return true; }; + + protected: + virtual void OnInitWindow(); + virtual void OnDeinitWindow(int nextWindowID); + + virtual bool OnPopupMenu(int iItem, int listType); + virtual bool OnContextButton(int itemNumber, CONTEXT_BUTTON button, int listType); + + virtual bool OnActionMove(const CAction &action); + + virtual bool OnMessageClick(CGUIMessage &message); + + bool OnClickListAvailable(CGUIMessage &message); + bool OnClickListActive(CGUIMessage &message); + bool OnClickRadioContinousSaving(CGUIMessage &message); + bool OnClickApplyChanges(CGUIMessage &message); + bool OnClickClearActiveModes(CGUIMessage &message); + + void SetItemsUnchanged(void); + + private: + void Clear(void); + void Update(void); + void SaveList(void); + void Renumber(void); + bool UpdateDatabase(CGUIDialogBusy* pDlgBusy); + void SetSelectedModeType(void); + + //! helper function prototypes + static void helper_LogError(const char *function); + static int helper_TranslateModeType(std::string ModeString); + static CFileItem *helper_CreateModeListItem(CActiveAEDSPModePtr &ModePointer, AE_DSP_MENUHOOK_CAT &MenuHook, int *ContinuesNo); + static int helper_GetDialogId(CActiveAEDSPModePtr &ModePointer, AE_DSP_MENUHOOK_CAT &MenuHook, AE_DSP_ADDON &Addon, std::string AddonName); + static AE_DSP_MENUHOOK_CAT helper_GetMenuHookCategory(int CurrentType); + + bool m_bMovingMode; + bool m_bContainsChanges; + bool m_bContinousSaving; // if true, all settings are directly saved + + int m_iCurrentType; + int m_iSelected[AE_DSP_MODE_TYPE_MAX]; + + CFileItemList* m_activeItems[AE_DSP_MODE_TYPE_MAX]; + CFileItemList* m_availableItems[AE_DSP_MODE_TYPE_MAX]; + + CGUIViewControl m_availableViewControl; + CGUIViewControl m_activeViewControl; + }; +} diff --git a/xbmc/settings/dialogs/Makefile b/xbmc/settings/dialogs/Makefile index 4f382e1648..0e4c899e35 100644 --- a/xbmc/settings/dialogs/Makefile +++ b/xbmc/settings/dialogs/Makefile @@ -1,4 +1,5 @@ -SRCS=GUIDialogContentSettings.cpp \ +SRCS=GUIDialogAudioDSPManager.cpp \ + GUIDialogContentSettings.cpp \ GUIDialogSettingsBase.cpp \ GUIDialogSettingsManagerBase.cpp \ GUIDialogSettingsManualBase.cpp \ -- cgit v1.2.3