Browse Source

Cleanup

gh-pages
falkTX 10 years ago
parent
commit
08043aa9d8
4 changed files with 43 additions and 24 deletions
  1. +1
    -1
      distrho/DistrhoUI.hpp
  2. +4
    -1
      distrho/src/DistrhoPluginInternal.hpp
  3. +3
    -3
      distrho/src/DistrhoUI.cpp
  4. +35
    -19
      distrho/src/DistrhoUIInternal.hpp

+ 1
- 1
distrho/DistrhoUI.hpp View File

@@ -79,7 +79,7 @@ protected:
// -------------------------------------------------------------------
// Direct DSP access - DO NOT USE THIS UNLESS STRICTLY NECESSARY!!

void* d_getPluginInstancePointer();
void* d_getPluginInstancePointer() const noexcept;
#endif

// -------------------------------------------------------------------


+ 4
- 1
distrho/src/DistrhoPluginInternal.hpp View File

@@ -407,7 +407,7 @@ public:

private:
// -------------------------------------------------------------------
// private members accessed by DistrhoPlugin class
// private members accessed by DistrhoPlugin classes

Plugin* const fPlugin;
Plugin::PrivateData* const fData;
@@ -417,6 +417,9 @@ private:

static const d_string sFallbackString;
static const ParameterRanges sFallbackRanges;

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginExporter)
DISTRHO_PREVENT_HEAP_ALLOCATION
};

// -----------------------------------------------------------------------


+ 3
- 3
distrho/src/DistrhoUI.cpp View File

@@ -23,7 +23,7 @@ END_NAMESPACE_DGL
START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------
// Static data
// Static data, see DistrhoUIInternal.hpp

double d_lastUiSampleRate = 0.0;

@@ -34,7 +34,7 @@ UI::UI()
: DGL::Widget(*DGL::dgl_lastUiParent),
pData(new PrivateData())
{
assert(DGL::dgl_lastUiParent != nullptr);
DISTRHO_SAFE_ASSERT(DGL::dgl_lastUiParent != nullptr);

DGL::dgl_lastUiParent = nullptr;
}
@@ -88,7 +88,7 @@ void UI::d_uiResize(unsigned int width, unsigned int height)
// -----------------------------------------------------------------------
// Direct DSP access

void* UI::d_getPluginInstancePointer()
void* UI::d_getPluginInstancePointer() const noexcept
{
return pData->dspPtr;
}


+ 35
- 19
distrho/src/DistrhoUIInternal.hpp View File

@@ -70,7 +70,7 @@ struct UI::PrivateData {
uiResizeCallbackFunc(nullptr),
ptr(nullptr)
{
assert(sampleRate != 0.0);
DISTRHO_SAFE_ASSERT(sampleRate != 0.0);

#if defined(DISTRHO_PLUGIN_TARGET_DSSI) || defined(DISTRHO_PLUGIN_TARGET_LV2)
parameterOffset += DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS;
@@ -78,6 +78,7 @@ struct UI::PrivateData {
parameterOffset += 1;
# endif
#endif

#ifdef DISTRHO_PLUGIN_TARGET_LV2
# if (DISTRHO_PLUGIN_IS_SYNTH || DISTRHO_PLUGIN_WANT_TIMEPOS || DISTRHO_PLUGIN_WANT_STATE)
parameterOffset += 1;
@@ -126,16 +127,15 @@ class UIExporter
{
public:
UIExporter(void* const ptr, const intptr_t winId,
const editParamFunc editParamCall, const setParamFunc setParamCall, const setStateFunc setStateCall, const sendNoteFunc sendNoteCall, const uiResizeFunc uiResizeCall, void* const dspPtr = nullptr)
const editParamFunc editParamCall, const setParamFunc setParamCall, const setStateFunc setStateCall, const sendNoteFunc sendNoteCall, const uiResizeFunc uiResizeCall,
void* const dspPtr = nullptr)
: glApp(),
glWindow(glApp, winId),
fUi(createUI()),
fData((fUi != nullptr) ? fUi->pData : nullptr)
{
assert(fUi != nullptr);

if (fUi == nullptr)
return;
DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr,);
DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr,);

fData->ptr = ptr;
fData->editParamCallbackFunc = editParamCall;
@@ -164,47 +164,60 @@ public:

const char* getName() const noexcept
{
return (fUi != nullptr) ? fUi->d_getName() : "";
DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr, "");

return fUi->d_getName();
}

unsigned int getWidth() const noexcept
{
return (fUi != nullptr) ? fUi->d_getWidth() : 0;
DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr, 0);

return fUi->d_getWidth();
}

unsigned int getHeight() const noexcept
{
return (fUi != nullptr) ? fUi->d_getHeight() : 0;
DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr, 0);

return fUi->d_getHeight();
}

// -------------------------------------------------------------------

uint32_t getParameterOffset() const noexcept
{
return (fData != nullptr) ? fData->parameterOffset : 0;
DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr, 0);

return fData->parameterOffset;
}

// -------------------------------------------------------------------

void parameterChanged(const uint32_t index, const float value)
{
if (fUi != nullptr)
fUi->d_parameterChanged(index, value);
DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr,);

fUi->d_parameterChanged(index, value);
}

#if DISTRHO_PLUGIN_WANT_PROGRAMS
void programChanged(const uint32_t index)
{
if (fUi != nullptr)
fUi->d_programChanged(index);
DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr,);

fUi->d_programChanged(index);
}
#endif

#if DISTRHO_PLUGIN_WANT_STATE
void stateChanged(const char* const key, const char* const value)
{
if (fUi != nullptr)
fUi->d_stateChanged(key, value);
DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr,);
DISTRHO_SAFE_ASSERT_RETURN(key != nullptr && key[0] != '\0',);
DISTRHO_SAFE_ASSERT_RETURN(value != nullptr,);

fUi->d_stateChanged(key, value);
}
#endif

@@ -212,9 +225,9 @@ public:

bool idle()
{
if (fUi != nullptr)
fUi->d_uiIdle();
DISTRHO_SAFE_ASSERT_RETURN(fUi != nullptr, false);

fUi->d_uiIdle();
glApp.idle();

return ! glApp.isQuiting();
@@ -254,10 +267,13 @@ private:
DGL::Window glWindow;

// -------------------------------------------------------------------
// private members accessed by DistrhoPlugin class
// private members accessed by DistrhoUI classes

UI* const fUi;
UI::PrivateData* const fData;

DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(UIExporter)
DISTRHO_PREVENT_HEAP_ALLOCATION
};

// -----------------------------------------------------------------------


Loading…
Cancel
Save