Skip to content

Commit

Permalink
Change to new C++ addon interface system
Browse files Browse the repository at this point in the history
  • Loading branch information
AlwinEsch committed Jun 18, 2017
1 parent 79fa039 commit 236dae8
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 299 deletions.
14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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})

Expand Down
2 changes: 1 addition & 1 deletion adsp.freesurround/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="adsp.freesurround"
version="0.3.1"
version="0.4.0"
name="Free Surround Processor"
provider-name="Team KODI">
<requires>@ADDON_DEPENDS@</requires>
Expand Down
2 changes: 1 addition & 1 deletion src/ChannelMaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <vector>
#include <map>

#include "kodi_adsp_types.h"
#include <kodi/addon-instance/AudioDSP.h>

/*
* Identifier translation from FreeSurround to KODI ADSP
Expand Down
4 changes: 1 addition & 3 deletions src/DSPProcessFreeSurround.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include <stdlib.h>
#include <string.h>

#include "libXBMC_addon.h"
#include "libKODI_adsp.h"
#include "p8-platform/util/StdString.h"

#include "addon.h"
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/DSPProcessFreeSurround.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
#include <vector>
#include <map>

#include "kodi_adsp_types.h"
#include "FreeSurroundDecoder.h"
#include "FreeSurroundSettings.h"

#include <kodi/addon-instance/AudioDSP.h>

#define SURROUND_BUFSIZE 8192

class CDSPProcess_FreeSurround
Expand Down Expand Up @@ -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();

Expand Down
16 changes: 6 additions & 10 deletions src/FreeSurroundSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@
*
*/

#include "libXBMC_addon.h"
#include "libKODI_adsp.h"
#include "libKODI_guilib.h"
#include <kodi/General.h>

#include "util/XMLUtils.h"
#include "p8-platform/util/util.h"
#include "p8-platform/util/StdString.h"

#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");
Expand Down Expand Up @@ -70,21 +66,21 @@ 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;
}

TiXmlElement *pRootElement = xmlDoc.RootElement();
if (strcmp(pRootElement->Value(), "freesurround") != 0)
{
if (!initial)
KODI->Log(LOG_ERROR, "invalid settings data (no <circlesurround2> tag found)");
kodi::Log(ADDON_LOG_ERROR, "invalid settings data (no <circlesurround2> tag found)");
return false;
}

Expand Down Expand Up @@ -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;
}

Expand Down
133 changes: 35 additions & 98 deletions src/GUIDialogFreeSurround.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <kodi/ActionIDs.h>

#define BUTTON_OK 1
#define BUTTON_CANCEL 2
Expand All @@ -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<CGUIDialogFreeSurround*>(cbhdl);
return dialog->OnInit();
}

bool CGUIDialogFreeSurround::OnClickCB(GUIHANDLE cbhdl, int controlId)
{
CGUIDialogFreeSurround* dialog = static_cast<CGUIDialogFreeSurround*>(cbhdl);
return dialog->OnClick(controlId);
}

bool CGUIDialogFreeSurround::OnFocusCB(GUIHANDLE cbhdl, int controlId)
{
CGUIDialogFreeSurround* dialog = static_cast<CGUIDialogFreeSurround*>(cbhdl);
return dialog->OnFocus(controlId);
}

bool CGUIDialogFreeSurround::OnActionCB(GUIHANDLE cbhdl, int actionId)
{
CGUIDialogFreeSurround* dialog = static_cast<CGUIDialogFreeSurround*>(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);
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 236dae8

Please sign in to comment.