From 236dae898823ae709c7a231df98539849abc763a Mon Sep 17 00:00:00 2001 From: Alwin Esch Date: Sun, 18 Jun 2017 07:35:39 +0200 Subject: [PATCH] Change to new C++ addon interface system --- CMakeLists.txt | 14 ++- adsp.freesurround/addon.xml.in | 2 +- src/ChannelMaps.h | 2 +- src/DSPProcessFreeSurround.cpp | 4 +- src/DSPProcessFreeSurround.h | 5 +- src/FreeSurroundSettings.cpp | 16 +-- src/GUIDialogFreeSurround.cpp | 133 ++++++---------------- src/GUIDialogFreeSurround.h | 48 ++++---- src/addon.cpp | 199 +++++++++------------------------ src/addon.h | 12 +- 10 files changed, 136 insertions(+), 299 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3eb0712..9f61633 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ find_package(p8-platform REQUIRED) include_directories(${kodiplatform_INCLUDE_DIRS} ${p8-platform_INCLUDE_DIRS} - ${KODI_INCLUDE_DIR}) + ${KODI_INCLUDE_DIR}/..) # Hack way with "/..", need bigger Kodi cmake rework to match right include ways (becomes done in future) set(FREESURROUND_SOURCES src/addon.cpp src/GUIDialogFreeSurround.cpp @@ -23,6 +23,18 @@ set(FREESURROUND_SOURCES src/addon.cpp src/ChannelMaps.cpp src/FreeSurroundDecoder.cpp) +set(FREESURROUND_HEADERS src/addon.h + src/ChannelMaps.h + src/DSPProcessFreeSurround.h + src/FreeSurroundDecoder.h + src/FreeSurroundSettings.h + src/GUIDialogFreeSurround.h + src/kissfft/_kiss_fft_guts.h + src/kissfft/kiss_fft.h + src/kissfft/kiss_fftnd.h + src/kissfft/kiss_fftndr.h + src/kissfft/kiss_fftr.h) + set(DEPLIBS ${kodiplatform_LIBRARIES} ${p8-platform_LIBRARIES}) diff --git a/adsp.freesurround/addon.xml.in b/adsp.freesurround/addon.xml.in index eee2c96..a5f78bf 100644 --- a/adsp.freesurround/addon.xml.in +++ b/adsp.freesurround/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@ diff --git a/src/ChannelMaps.h b/src/ChannelMaps.h index 4dc5207..1e72d82 100644 --- a/src/ChannelMaps.h +++ b/src/ChannelMaps.h @@ -28,7 +28,7 @@ #include #include -#include "kodi_adsp_types.h" +#include /* * Identifier translation from FreeSurround to KODI ADSP diff --git a/src/DSPProcessFreeSurround.cpp b/src/DSPProcessFreeSurround.cpp index 3ef4c7d..c7e910d 100644 --- a/src/DSPProcessFreeSurround.cpp +++ b/src/DSPProcessFreeSurround.cpp @@ -22,8 +22,6 @@ #include #include -#include "libXBMC_addon.h" -#include "libKODI_adsp.h" #include "p8-platform/util/StdString.h" #include "addon.h" @@ -168,7 +166,7 @@ float CDSPProcess_FreeSurround::StreamGetDelay() return delay; } -unsigned int CDSPProcess_FreeSurround::StreamProcess(float **array_in, float **array_out, unsigned int samples) +unsigned int CDSPProcess_FreeSurround::StreamProcess(const float **array_in, float **array_out, unsigned int samples) { if (!m_Decoder) return samples; diff --git a/src/DSPProcessFreeSurround.h b/src/DSPProcessFreeSurround.h index cbdf567..39279cc 100644 --- a/src/DSPProcessFreeSurround.h +++ b/src/DSPProcessFreeSurround.h @@ -22,10 +22,11 @@ #include #include -#include "kodi_adsp_types.h" #include "FreeSurroundDecoder.h" #include "FreeSurroundSettings.h" +#include + #define SURROUND_BUFSIZE 8192 class CDSPProcess_FreeSurround @@ -56,7 +57,7 @@ class CDSPProcess_FreeSurround AE_DSP_ERROR StreamInitialize(const AE_DSP_SETTINGS *settings); AE_DSP_ERROR StreamIsModeSupported(AE_DSP_MODE_TYPE type, unsigned int mode_id, int unique_db_mode_id); - unsigned int StreamProcess(float **array_in, float **array_out, unsigned int samples); + unsigned int StreamProcess(const float **array_in, float **array_out, unsigned int samples); int StreamGetOutChannels(unsigned long &out_channel_present_flags); float StreamGetDelay(); diff --git a/src/FreeSurroundSettings.cpp b/src/FreeSurroundSettings.cpp index fa9bd67..d26747d 100644 --- a/src/FreeSurroundSettings.cpp +++ b/src/FreeSurroundSettings.cpp @@ -17,9 +17,7 @@ * */ -#include "libXBMC_addon.h" -#include "libKODI_adsp.h" -#include "libKODI_guilib.h" +#include #include "util/XMLUtils.h" #include "p8-platform/util/util.h" @@ -27,11 +25,9 @@ #include "FreeSurroundSettings.h" -using namespace ADDON; - std::string GetSettingsFile() { - std::string settingFile = g_strUserPath; + std::string settingFile = kodi::GetBaseUserPath(); if (settingFile.at(settingFile.size() - 1) == '\\' || settingFile.at(settingFile.size() - 1) == '/') settingFile.append("ADSPFreeSurrAddonSettings.xml"); @@ -70,13 +66,13 @@ bool CDSPSettings::LoadSettingsData(bool initial /* = false */) { if (!SaveSettingsData()) { - KODI->Log(LOG_ERROR, "failed to create initial settings data file at '%s')", strSettingsFile.c_str()); + kodi::Log(ADDON_LOG_ERROR, "failed to create initial settings data file at '%s')", strSettingsFile.c_str()); return false; } return true; } else - KODI->Log(LOG_ERROR, "invalid settings data (no/invalid data file found at '%s')", strSettingsFile.c_str()); + kodi::Log(ADDON_LOG_ERROR, "invalid settings data (no/invalid data file found at '%s')", strSettingsFile.c_str()); return false; } @@ -84,7 +80,7 @@ bool CDSPSettings::LoadSettingsData(bool initial /* = false */) if (strcmp(pRootElement->Value(), "freesurround") != 0) { if (!initial) - KODI->Log(LOG_ERROR, "invalid settings data (no tag found)"); + kodi::Log(ADDON_LOG_ERROR, "invalid settings data (no tag found)"); return false; } @@ -143,7 +139,7 @@ bool CDSPSettings::SaveSettingsData() if (!xmlDoc.SaveFile(GetSettingsFile())) { - KODI->Log(LOG_ERROR, "failed to write circle surround 2 settings data"); + kodi::Log(ADDON_LOG_ERROR, "failed to write circle surround 2 settings data"); return false; } diff --git a/src/GUIDialogFreeSurround.cpp b/src/GUIDialogFreeSurround.cpp index 87e9fce..d7bf270 100644 --- a/src/GUIDialogFreeSurround.cpp +++ b/src/GUIDialogFreeSurround.cpp @@ -17,17 +17,13 @@ * */ -#include "libXBMC_addon.h" -#include "libKODI_adsp.h" -#include "libKODI_guilib.h" - #include "util/XMLUtils.h" #include "p8-platform/util/util.h" #include "GUIDialogFreeSurround.h" #include "DSPProcessFreeSurround.h" -using namespace ADDON; +#include #define BUTTON_OK 1 #define BUTTON_CANCEL 2 @@ -44,119 +40,76 @@ using namespace ADDON; #define DSP_SETTING_FREESURROUND_LFE_LOW_CUTOFF 49 #define DSP_SETTING_FREESURROUND_LFE_HIGH_CUTOFF 50 -#define ACTION_NAV_BACK 92 - CGUIDialogFreeSurround::CGUIDialogFreeSurround(unsigned int streamId) - : m_StreamId(streamId), - m_CircularWrap(NULL), - m_Shift(NULL), - m_Depth(NULL), - m_Focus(NULL), - m_CenterImage(NULL), - m_FrontSeparation(NULL), - m_RearSeparation(NULL), - m_LFE(NULL), - m_LFE_LowCutoff(NULL), - m_LFE_HighCutoff(NULL), - m_window(NULL) + : CWindow("DialogMasterModeFreeSurround.xml", "skin.estuary", true), + m_StreamId(streamId), + m_CircularWrap(nullptr), + m_Shift(nullptr), + m_Depth(nullptr), + m_Focus(nullptr), + m_CenterImage(nullptr), + m_FrontSeparation(nullptr), + m_RearSeparation(nullptr), + m_LFE(nullptr), + m_LFE_LowCutoff(nullptr), + m_LFE_HighCutoff(nullptr) { - m_window = GUI->Window_create("DialogMasterModeFreeSurround.xml", "skin.estuary", false, true); - m_window->m_cbhdl = this; - m_window->CBOnInit = OnInitCB; - m_window->CBOnFocus = OnFocusCB; - m_window->CBOnClick = OnClickCB; - m_window->CBOnAction = OnActionCB; } CGUIDialogFreeSurround::~CGUIDialogFreeSurround() { - GUI->Window_destroy(m_window); -} - -bool CGUIDialogFreeSurround::OnInitCB(GUIHANDLE cbhdl) -{ - CGUIDialogFreeSurround* dialog = static_cast(cbhdl); - return dialog->OnInit(); -} - -bool CGUIDialogFreeSurround::OnClickCB(GUIHANDLE cbhdl, int controlId) -{ - CGUIDialogFreeSurround* dialog = static_cast(cbhdl); - return dialog->OnClick(controlId); -} - -bool CGUIDialogFreeSurround::OnFocusCB(GUIHANDLE cbhdl, int controlId) -{ - CGUIDialogFreeSurround* dialog = static_cast(cbhdl); - return dialog->OnFocus(controlId); -} - -bool CGUIDialogFreeSurround::OnActionCB(GUIHANDLE cbhdl, int actionId) -{ - CGUIDialogFreeSurround* dialog = static_cast(cbhdl); - return dialog->OnAction(actionId); -} - -bool CGUIDialogFreeSurround::Show() -{ - if (m_window) - return m_window->Show(); - - return false; -} - -void CGUIDialogFreeSurround::Close() -{ - if (m_window) - m_window->Close(); -} - -void CGUIDialogFreeSurround::DoModal() -{ - if (m_window) - m_window->DoModal(); + delete m_CircularWrap; + delete m_Shift; + delete m_Depth; + delete m_Focus; + delete m_CenterImage; + delete m_FrontSeparation; + delete m_RearSeparation; + delete m_LFE; + delete m_LFE_LowCutoff; + delete m_LFE_HighCutoff; } bool CGUIDialogFreeSurround::OnInit() { LoadSettingsData(); - m_CircularWrap = GUI->Control_getSettingsSlider(m_window, DSP_SETTING_FREESURROUND_CIRCULAR_WRAP); + m_CircularWrap = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_CIRCULAR_WRAP); m_CircularWrap->SetIntRange(0, 360); m_CircularWrap->SetIntInterval(5); m_CircularWrap->SetIntValue((int)m_Settings.fCircularWrap); - m_Shift = GUI->Control_getSettingsSlider(m_window, DSP_SETTING_FREESURROUND_SHIFT); + m_Shift = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_SHIFT); m_Shift->SetFloatRange(-1.0, +1.0); m_Shift->SetFloatValue(m_Settings.fShift); - m_Depth = GUI->Control_getSettingsSlider(m_window, DSP_SETTING_FREESURROUND_DEPTH); + m_Depth = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_DEPTH); m_Depth->SetFloatRange(0, 4.0); m_Depth->SetFloatInterval(0.25); m_Depth->SetFloatValue(m_Settings.fDepth); - m_Focus = GUI->Control_getSettingsSlider(m_window, DSP_SETTING_FREESURROUND_FOCUS); + m_Focus = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_FOCUS); m_Focus->SetFloatRange(-1.0, +1.0); m_Focus->SetFloatValue(m_Settings.fFocus); - m_CenterImage = GUI->Control_getSettingsSlider(m_window, DSP_SETTING_FREESURROUND_CENTER_IMAGE); + m_CenterImage = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_CENTER_IMAGE); m_CenterImage->SetFloatValue(m_Settings.fCenterImage); - m_FrontSeparation = GUI->Control_getSettingsSlider(m_window, DSP_SETTING_FREESURROUND_FRONT_SEPARATION); + m_FrontSeparation = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_FRONT_SEPARATION); m_FrontSeparation->SetFloatValue(m_Settings.fFrontSeparation); - m_RearSeparation = GUI->Control_getSettingsSlider(m_window, DSP_SETTING_FREESURROUND_REAR_SEPARATION); + m_RearSeparation = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_REAR_SEPARATION); m_RearSeparation->SetFloatValue(m_Settings.fRearSeparation); - m_LFE = GUI->Control_getRadioButton(m_window, DSP_SETTING_FREESURROUND_LFE); + m_LFE = new kodi::gui::controls::CRadioButton(this, DSP_SETTING_FREESURROUND_LFE); m_LFE->SetSelected(m_Settings.bLFE); - m_LFE_LowCutoff = GUI->Control_getSettingsSlider(m_window, DSP_SETTING_FREESURROUND_LFE_LOW_CUTOFF); + m_LFE_LowCutoff = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_LFE_LOW_CUTOFF); m_LFE_LowCutoff->SetIntRange(40.0f, 400.0f); m_LFE_LowCutoff->SetIntInterval(10.0f); m_LFE_LowCutoff->SetIntValue(m_Settings.fLowCutoff); - m_LFE_HighCutoff = GUI->Control_getSettingsSlider(m_window, DSP_SETTING_FREESURROUND_LFE_HIGH_CUTOFF); + m_LFE_HighCutoff = new kodi::gui::controls::CSettingsSlider(this, DSP_SETTING_FREESURROUND_LFE_HIGH_CUTOFF); m_LFE_HighCutoff->SetIntRange(60.0f, 1000.0f); m_LFE_HighCutoff->SetIntInterval(10.0f); m_LFE_HighCutoff->SetIntValue(m_Settings.fHighCutoff); @@ -260,17 +213,7 @@ bool CGUIDialogFreeSurround::OnClick(int controlId) if (process) process->ResetSettings(); } - m_window->Close(); - GUI->Control_releaseSettingsSlider(m_CircularWrap); - GUI->Control_releaseSettingsSlider(m_Shift); - GUI->Control_releaseSettingsSlider(m_Depth); - GUI->Control_releaseSettingsSlider(m_Focus); - GUI->Control_releaseSettingsSlider(m_CenterImage); - GUI->Control_releaseSettingsSlider(m_FrontSeparation); - GUI->Control_releaseSettingsSlider(m_RearSeparation); - GUI->Control_releaseRadioButton(m_LFE); - GUI->Control_releaseSettingsSlider(m_LFE_LowCutoff); - GUI->Control_releaseSettingsSlider(m_LFE_HighCutoff); + Close(); break; } case BUTTON_DEFAULT: @@ -321,15 +264,9 @@ bool CGUIDialogFreeSurround::OnClick(int controlId) return true; } -bool CGUIDialogFreeSurround::OnFocus(int controlId) -{ - return true; -} - bool CGUIDialogFreeSurround::OnAction(int actionId) { - if (actionId == ADDON_ACTION_CLOSE_DIALOG || - actionId == ADDON_ACTION_PREVIOUS_MENU || + if (actionId == ACTION_PREVIOUS_MENU || actionId == ACTION_NAV_BACK) return OnClick(BUTTON_CANCEL); else diff --git a/src/GUIDialogFreeSurround.h b/src/GUIDialogFreeSurround.h index 2d732d6..8b669bf 100644 --- a/src/GUIDialogFreeSurround.h +++ b/src/GUIDialogFreeSurround.h @@ -22,39 +22,31 @@ #include "addon.h" #include "FreeSurroundSettings.h" -class CGUIDialogFreeSurround : private CDSPSettings +#include +#include +#include + +class CGUIDialogFreeSurround : public kodi::gui::CWindow, private CDSPSettings { public: CGUIDialogFreeSurround(unsigned int streamId); virtual ~CGUIDialogFreeSurround(); - bool Show(); - void Close(); - void DoModal(); + virtual bool OnInit() override; + virtual bool OnClick(int controlId) override; + virtual bool OnAction(int actionId) override; private: - bool OnClick(int controlId); - bool OnFocus(int controlId); - bool OnInit(); - bool OnAction(int actionId); - - static bool OnClickCB(GUIHANDLE cbhdl, int controlId); - static bool OnFocusCB(GUIHANDLE cbhdl, int controlId); - static bool OnInitCB(GUIHANDLE cbhdl); - static bool OnActionCB(GUIHANDLE cbhdl, int actionId); - - const unsigned int m_StreamId; - - CAddonGUISettingsSliderControl *m_CircularWrap; - CAddonGUISettingsSliderControl *m_Shift; - CAddonGUISettingsSliderControl *m_Depth; - CAddonGUISettingsSliderControl *m_Focus; - CAddonGUISettingsSliderControl *m_CenterImage; - CAddonGUISettingsSliderControl *m_FrontSeparation; - CAddonGUISettingsSliderControl *m_RearSeparation; - CAddonGUIRadioButton *m_LFE; - CAddonGUISettingsSliderControl *m_LFE_LowCutoff; - CAddonGUISettingsSliderControl *m_LFE_HighCutoff; - - CAddonGUIWindow *m_window; + const unsigned int m_StreamId; + + kodi::gui::controls::CSettingsSlider *m_CircularWrap; + kodi::gui::controls::CSettingsSlider *m_Shift; + kodi::gui::controls::CSettingsSlider *m_Depth; + kodi::gui::controls::CSettingsSlider *m_Focus; + kodi::gui::controls::CSettingsSlider *m_CenterImage; + kodi::gui::controls::CSettingsSlider *m_FrontSeparation; + kodi::gui::controls::CSettingsSlider *m_RearSeparation; + kodi::gui::controls::CRadioButton *m_LFE; + kodi::gui::controls::CSettingsSlider *m_LFE_LowCutoff; + kodi::gui::controls::CSettingsSlider *m_LFE_HighCutoff; }; diff --git a/src/addon.cpp b/src/addon.cpp index 4bee0d8..6a358ed 100644 --- a/src/addon.cpp +++ b/src/addon.cpp @@ -20,91 +20,54 @@ #include #include #include "addon.h" -#include "kodi_adsp_dll.h" +#include #include "p8-platform/util/util.h" #include "p8-platform/util/StdString.h" #include "GUIDialogFreeSurround.h" #include "DSPProcessFreeSurround.h" using namespace std; -using namespace ADDON; - -#ifdef TARGET_WINDOWS -#define snprintf _snprintf -#endif - -#if defined(TARGET_WINDOWS) - #undef CreateDirectory -#endif #define ID_MASTER_PROCESS_FREE_SURROUND 1300 - -/* User adjustable settings are saved here. - * Default values are defined inside addon.h - * and exported to the other source files. - */ -std::string g_strUserPath = ""; -std::string g_strAddonPath = ""; -CHelper_libXBMC_addon *KODI = NULL; -CHelper_libKODI_adsp *ADSP = NULL; -CHelper_libKODI_guilib *GUI = NULL; -ADDON_STATUS m_CurStatus = ADDON_STATUS_UNKNOWN; -AE_DSP_MENUHOOK m_MenuHook; CDSPProcess_FreeSurround *g_usedDSPs[AE_DSP_STREAM_MAX_STREAMS]; -struct AE_DSP_MODES::AE_DSP_MODE m_ModeInfoStruct; - -extern "C" { -void ADDON_ReadSettings(void) +class CFreeSurroundAddon + : public kodi::addon::CAddonBase, + public kodi::addon::CInstanceAudioDSP { -} - -ADDON_STATUS ADDON_Create(void* hdl, void* props) +public: + CFreeSurroundAddon(); + virtual ~CFreeSurroundAddon(); + + virtual ADDON_STATUS Create() override; + virtual void GetCapabilities(AE_DSP_ADDON_CAPABILITIES& capabilities) override; + virtual std::string GetDSPName() override { return "Free Surround Processor"; } + virtual std::string GetDSPVersion() override { return FREESURROUND_VERSION; }; + virtual AE_DSP_ERROR MenuHook(const AE_DSP_MENUHOOK& menuhook, const AE_DSP_MENUHOOK_DATA& item) override; + virtual AE_DSP_ERROR StreamCreate(const AE_DSP_SETTINGS& addonSettings, const AE_DSP_STREAM_PROPERTIES& properties, ADDON_HANDLE handle) override; + virtual AE_DSP_ERROR StreamDestroy(const ADDON_HANDLE handle) override; + virtual AE_DSP_ERROR StreamInitialize(const ADDON_HANDLE handle, const AE_DSP_SETTINGS& addonSettings) override; + virtual AE_DSP_ERROR StreamIsModeSupported(const ADDON_HANDLE handle, AE_DSP_MODE_TYPE type, unsigned int mode_id, int unique_db_mode_id) override; + virtual float MasterProcessGetDelay(const ADDON_HANDLE handle) override; + virtual unsigned int MasterProcess(const ADDON_HANDLE handle, const float** array_in, float** array_out, unsigned int samples) override; + virtual int MasterProcessGetOutChannels(const ADDON_HANDLE handle, unsigned long& out_channel_present_flags) override; + +private: + AE_DSP_MENUHOOK m_MenuHook; + struct AE_DSP_MODES::AE_DSP_MODE m_ModeInfoStruct; +}; + +CFreeSurroundAddon::CFreeSurroundAddon() { - if (!hdl || !props) - return ADDON_STATUS_UNKNOWN; - - AE_DSP_PROPERTIES* adspprops = (AE_DSP_PROPERTIES*)props; - - KODI = new CHelper_libXBMC_addon; - if (!KODI->RegisterMe(hdl)) - { - SAFE_DELETE(KODI); - return ADDON_STATUS_PERMANENT_FAILURE; - } - - GUI = new CHelper_libKODI_guilib; - if (!GUI->RegisterMe(hdl)) - { - SAFE_DELETE(GUI); - SAFE_DELETE(KODI); - return ADDON_STATUS_PERMANENT_FAILURE; - } - - ADSP = new CHelper_libKODI_adsp; - if (!ADSP->RegisterMe(hdl)) - { - SAFE_DELETE(ADSP); - SAFE_DELETE(GUI); - SAFE_DELETE(KODI); - return ADDON_STATUS_PERMANENT_FAILURE; - } - - KODI->Log(LOG_DEBUG, "%s - Creating the Audio DSP free surround add-on", __FUNCTION__); - - m_CurStatus = ADDON_STATUS_UNKNOWN; - g_strUserPath = adspprops->strUserPath; - g_strAddonPath = adspprops->strAddonPath; - // create addon user path - if (!KODI->DirectoryExists(g_strUserPath.c_str())) + if (!kodi::vfs::DirectoryExists(kodi::GetBaseUserPath())) { - KODI->CreateDirectory(g_strUserPath.c_str()); + kodi::vfs::CreateDirectory(kodi::GetBaseUserPath()); } for (int i = 0; i < AE_DSP_STREAM_MAX_STREAMS; ++i) - g_usedDSPs[i] = NULL; + g_usedDSPs[i] = nullptr; CDSPSettings settings; settings.LoadSettingsData(true); @@ -123,66 +86,37 @@ ADDON_STATUS ADDON_Create(void* hdl, void* props) m_ModeInfoStruct.bIsDisabled = false; strncpy(m_ModeInfoStruct.strModeName, "Free Surround", sizeof(m_ModeInfoStruct.strModeName) - 1); - imagePath = g_strAddonPath; + imagePath = kodi::GetAddonPath(); imagePath += "/resources/skins/Confluence/media/adsp-freesurround.png"; strncpy(m_ModeInfoStruct.strOwnModeImage, imagePath.c_str(), sizeof(m_ModeInfoStruct.strOwnModeImage) - 1); memset(m_ModeInfoStruct.strOverrideModeImage, 0, sizeof(m_ModeInfoStruct.strOwnModeImage)); // unused - ADSP->RegisterMode(&m_ModeInfoStruct); + RegisterMode(&m_ModeInfoStruct); m_MenuHook.iHookId = ID_MASTER_PROCESS_FREE_SURROUND; m_MenuHook.category = AE_DSP_MENUHOOK_MASTER_PROCESS; m_MenuHook.iLocalizedStringId = 30001; m_MenuHook.iRelevantModeId = ID_MASTER_PROCESS_FREE_SURROUND; m_MenuHook.bNeedPlayback = true; - ADSP->AddMenuHook(&m_MenuHook); - - m_CurStatus = ADDON_STATUS_OK; - - return m_CurStatus; + AddMenuHook(&m_MenuHook); } -ADDON_STATUS ADDON_GetStatus() -{ - return m_CurStatus; -} - -void ADDON_Destroy() +CFreeSurroundAddon::~CFreeSurroundAddon() { for (int i = 0; i < AE_DSP_STREAM_MAX_STREAMS; ++i) SAFE_DELETE(g_usedDSPs[i]); - - SAFE_DELETE(ADSP); - SAFE_DELETE(GUI); - SAFE_DELETE(KODI); - - m_CurStatus = ADDON_STATUS_UNKNOWN; -} - -AE_DSP_ERROR GetAddonCapabilities(AE_DSP_ADDON_CAPABILITIES* pCapabilities) -{ - pCapabilities->bSupportsInputProcess = false; - pCapabilities->bSupportsPreProcess = false; - pCapabilities->bSupportsInputResample = false; - pCapabilities->bSupportsMasterProcess = true; - pCapabilities->bSupportsPostProcess = false; - pCapabilities->bSupportsOutputResample = false; - - return AE_DSP_ERROR_NO_ERROR; } -const char *GetDSPName(void) +void CFreeSurroundAddon::GetCapabilities(AE_DSP_ADDON_CAPABILITIES& capabilities) { - static const char *strBackendName = "Free Surround Processor"; - return strBackendName; + capabilities.bSupportsInputProcess = false; + capabilities.bSupportsPreProcess = false; + capabilities.bSupportsInputResample = false; + capabilities.bSupportsMasterProcess = true; + capabilities.bSupportsPostProcess = false; + capabilities.bSupportsOutputResample = false; } -const char *GetDSPVersion(void) -{ - static const char *strDSPVersion = FREESURROUND_VERSION; - return strDSPVersion; -} - -AE_DSP_ERROR CallMenuHook(const AE_DSP_MENUHOOK &menuhook, const AE_DSP_MENUHOOK_DATA &item) +AE_DSP_ERROR CFreeSurroundAddon::MenuHook(const AE_DSP_MENUHOOK &menuhook, const AE_DSP_MENUHOOK_DATA &item) { if (menuhook.iHookId == ID_MASTER_PROCESS_FREE_SURROUND) { @@ -193,13 +127,13 @@ AE_DSP_ERROR CallMenuHook(const AE_DSP_MENUHOOK &menuhook, const AE_DSP_MENUHOOK return AE_DSP_ERROR_UNKNOWN; } -AE_DSP_ERROR StreamCreate(const AE_DSP_SETTINGS *addonSettings, const AE_DSP_STREAM_PROPERTIES* pProperties, ADDON_HANDLE handle) +AE_DSP_ERROR CFreeSurroundAddon::StreamCreate(const AE_DSP_SETTINGS& addonSettings, const AE_DSP_STREAM_PROPERTIES& pProperties, ADDON_HANDLE handle) { - CDSPProcess_FreeSurround *proc = new CDSPProcess_FreeSurround(addonSettings->iStreamID); - AE_DSP_ERROR err = proc->StreamCreate(addonSettings, pProperties); + CDSPProcess_FreeSurround *proc = new CDSPProcess_FreeSurround(addonSettings.iStreamID); + AE_DSP_ERROR err = proc->StreamCreate(&addonSettings, &pProperties); if (err == AE_DSP_ERROR_NO_ERROR) { - handle->dataIdentifier = addonSettings->iStreamID; + handle->dataIdentifier = addonSettings.iStreamID; handle->callerAddress = proc; g_usedDSPs[handle->dataIdentifier] = proc; //!< Still used in table to have identification on settings dialog } @@ -208,7 +142,7 @@ AE_DSP_ERROR StreamCreate(const AE_DSP_SETTINGS *addonSettings, const AE_DSP_STR return err; } -AE_DSP_ERROR StreamDestroy(const ADDON_HANDLE handle) +AE_DSP_ERROR CFreeSurroundAddon::StreamDestroy(const ADDON_HANDLE handle) { AE_DSP_ERROR err = ((CDSPProcess_FreeSurround*)handle->callerAddress)->StreamDestroy(); delete ((CDSPProcess_FreeSurround*)handle->callerAddress); @@ -216,54 +150,29 @@ AE_DSP_ERROR StreamDestroy(const ADDON_HANDLE handle) return err; } -AE_DSP_ERROR StreamInitialize(const ADDON_HANDLE handle, const AE_DSP_SETTINGS *settings) +AE_DSP_ERROR CFreeSurroundAddon::StreamInitialize(const ADDON_HANDLE handle, const AE_DSP_SETTINGS& settings) { - return ((CDSPProcess_FreeSurround*)handle->callerAddress)->StreamInitialize(settings); + return ((CDSPProcess_FreeSurround*)handle->callerAddress)->StreamInitialize(&settings); } -AE_DSP_ERROR StreamIsModeSupported(const ADDON_HANDLE handle, AE_DSP_MODE_TYPE type, unsigned int mode_id, int unique_db_mode_id) +AE_DSP_ERROR CFreeSurroundAddon::StreamIsModeSupported(const ADDON_HANDLE handle, AE_DSP_MODE_TYPE type, unsigned int mode_id, int unique_db_mode_id) { return ((CDSPProcess_FreeSurround*)handle->callerAddress)->StreamIsModeSupported(type, mode_id, unique_db_mode_id); } -float MasterProcessGetDelay(const ADDON_HANDLE handle) +float CFreeSurroundAddon::MasterProcessGetDelay(const ADDON_HANDLE handle) { return ((CDSPProcess_FreeSurround*)handle->callerAddress)->StreamGetDelay(); } -unsigned int MasterProcess(const ADDON_HANDLE handle, float **array_in, float **array_out, unsigned int samples) +unsigned int CFreeSurroundAddon::MasterProcess(const ADDON_HANDLE handle, const float **array_in, float **array_out, unsigned int samples) { return ((CDSPProcess_FreeSurround*)handle->callerAddress)->StreamProcess(array_in, array_out, samples); } -int MasterProcessGetOutChannels(const ADDON_HANDLE handle, unsigned long &out_channel_present_flags) +int CFreeSurroundAddon::MasterProcessGetOutChannels(const ADDON_HANDLE handle, unsigned long &out_channel_present_flags) { return ((CDSPProcess_FreeSurround*)handle->callerAddress)->StreamGetOutChannels(out_channel_present_flags); } -/*! - * Unused DSP addon functions - */ -ADDON_STATUS ADDON_SetSetting(const char *settingName, const void *settingValue) { return ADDON_STATUS_OK; } -void ADDON_Stop() {} -void ADDON_Announce(const char *flag, const char *sender, const char *message, const void *data) {} -bool InputProcess(const ADDON_HANDLE handle, const float **array_in, unsigned int samples) { return true; } -unsigned int InputResampleProcessNeededSamplesize(const ADDON_HANDLE handle) { return 0; } -int InputResampleSampleRate(const ADDON_HANDLE handle) { return 0; } -float InputResampleGetDelay(const ADDON_HANDLE handle) { return 0.0f; } -unsigned int InputResampleProcess(const ADDON_HANDLE handle, float **array_in, float **array_out, unsigned int samples) { return 0; } -unsigned int PreProcessNeededSamplesize(const ADDON_HANDLE handle, unsigned int mode_id) { return 0; } -float PreProcessGetDelay(const ADDON_HANDLE handle, unsigned int mode_id) { return 0.0f; } -unsigned int PreProcess(const ADDON_HANDLE handle, unsigned int mode_id, float **array_in, float **array_out, unsigned int samples) { return 0; } -AE_DSP_ERROR MasterProcessSetMode(const ADDON_HANDLE handle, AE_DSP_STREAMTYPE type, unsigned int client_mode_id, int unique_db_mode_id) { return AE_DSP_ERROR_NO_ERROR; } -unsigned int MasterProcessNeededSamplesize(const ADDON_HANDLE handle) { return 0; } -const char *MasterProcessGetStreamInfoString(const ADDON_HANDLE handle) { return ""; } -unsigned int PostProcessNeededSamplesize(const ADDON_HANDLE handle, unsigned int mode_id) { return 0; } -float PostProcessGetDelay(const ADDON_HANDLE handle, unsigned int mode_id) { return 0.0f; } -unsigned int PostProcess(const ADDON_HANDLE handle, unsigned int mode_id, float **array_in, float **array_out, unsigned int samples) { return 0; } -unsigned int OutputResampleProcessNeededSamplesize(const ADDON_HANDLE handle) { return 0; } -int OutputResampleSampleRate(const ADDON_HANDLE handle) { return 0; } -float OutputResampleGetDelay(const ADDON_HANDLE handle) { return 0.0f; } -unsigned int OutputResampleProcess(const ADDON_HANDLE handle, float **array_in, float **array_out, unsigned int samples) { return 0; } - -} +ADDONCREATOR(CFreeSurroundAddon); diff --git a/src/addon.h b/src/addon.h index c8a76e9..7f13918 100644 --- a/src/addon.h +++ b/src/addon.h @@ -18,15 +18,7 @@ * */ -#include "libXBMC_addon.h" -#include "libKODI_adsp.h" -#include "libKODI_guilib.h" +#include class CDSPProcess_FreeSurround; - -extern std::string g_strUserPath; -extern std::string g_strAddonPath; -extern CDSPProcess_FreeSurround *g_usedDSPs[AE_DSP_STREAM_MAX_STREAMS]; -extern ADDON::CHelper_libXBMC_addon *KODI; -extern CHelper_libKODI_guilib *GUI; -extern CHelper_libKODI_adsp *ADSP; +extern CDSPProcess_FreeSurround *g_usedDSPs[AE_DSP_STREAM_MAX_STREAMS];