Browse Source

Make previous changes c++98 compat

tags/v2.1-rc1
falkTX 5 years ago
parent
commit
0c536ccc43
3 changed files with 39 additions and 28 deletions
  1. +17
    -0
      source/includes/CarlaNative.hpp
  2. +11
    -14
      source/native-plugins/audio-file.cpp
  3. +11
    -14
      source/native-plugins/bigmeter.cpp

+ 17
- 0
source/includes/CarlaNative.hpp View File

@@ -542,6 +542,23 @@ public:

/**@}*/

// ---------------------------------------------------------------------------------------------------------------------
// -Weffc++ compat ext widget

extern "C" {

typedef struct _NativeInlineDisplayImageSurfaceCompat {
unsigned char* data;
int width, height, stride;
size_t dataSize;

_NativeInlineDisplayImageSurfaceCompat() noexcept
: data(nullptr), width(0), height(0), stride(0), dataSize(0) {}

} NativeInlineDisplayImageSurfaceCompat;

}

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

#define PluginClassEND(ClassName) \


+ 11
- 14
source/native-plugins/audio-file.cpp View File

@@ -237,14 +237,14 @@ protected:
const size_t dataSize = stride * height;
const uint pxToMove = fInlineDisplay.writtenValues;

uchar* data = fInlineDisplay.idisp.data;
uchar* data = fInlineDisplay.data;

if (fInlineDisplay.dataSize != dataSize || data == nullptr)
{
delete[] data;
data = new uchar[dataSize];
std::memset(data, 0, dataSize);
fInlineDisplay.idisp.data = data;
fInlineDisplay.data = data;
fInlineDisplay.dataSize = dataSize;
}
else if (pxToMove != 0)
@@ -255,9 +255,9 @@ protected:
std::memmove(&data[h * stride + w * 4], &data[h * stride + (w+pxToMove) * 4], 4);
}

fInlineDisplay.idisp.width = static_cast<int>(width);
fInlineDisplay.idisp.height = static_cast<int>(height);
fInlineDisplay.idisp.stride = static_cast<int>(stride);
fInlineDisplay.width = static_cast<int>(width);
fInlineDisplay.height = static_cast<int>(height);
fInlineDisplay.stride = static_cast<int>(stride);

const uint h2 = height / 2;

@@ -329,7 +329,7 @@ protected:

fInlineDisplay.writtenValues = 0;
fInlineDisplay.pending = false;
return &fInlineDisplay.idisp;
return (NativeInlineDisplayImageSurface*)(NativeInlineDisplayImageSurfaceCompat*)&fInlineDisplay;
}

// -------------------------------------------------------------------
@@ -344,17 +344,14 @@ private:
AudioFilePool fPool;
AudioFileThread fThread;

struct InlineDisplay {
NativeInlineDisplayImageSurface idisp;
size_t dataSize;
struct InlineDisplay : NativeInlineDisplayImageSurfaceCompat {
float lastValuesL[32];
float lastValuesR[32];
volatile uint8_t writtenValues;
volatile bool pending;

InlineDisplay()
: idisp{},
dataSize(0),
: NativeInlineDisplayImageSurfaceCompat(),
lastValuesL{0.0f},
lastValuesR{0.0f},
writtenValues(0),
@@ -362,10 +359,10 @@ private:

~InlineDisplay()
{
if (idisp.data != nullptr)
if (data != nullptr)
{
delete[] idisp.data;
idisp.data = nullptr;
delete[] data;
data = nullptr;
}
}



+ 11
- 14
source/native-plugins/bigmeter.cpp View File

@@ -193,22 +193,22 @@ protected:
const size_t stride = width * 4;
const size_t dataSize = stride * height;

uchar* data = fInlineDisplay.idisp.data;
uchar* data = fInlineDisplay.data;

if (fInlineDisplay.dataSize < dataSize || data == nullptr)
{
delete[] data;
data = new uchar[dataSize];
std::memset(data, 0, dataSize);
fInlineDisplay.idisp.data = data;
fInlineDisplay.data = data;
fInlineDisplay.dataSize = dataSize;
}

std::memset(data, 0, dataSize);

fInlineDisplay.idisp.width = static_cast<int>(width);
fInlineDisplay.idisp.height = static_cast<int>(height);
fInlineDisplay.idisp.stride = static_cast<int>(stride);
fInlineDisplay.width = static_cast<int>(width);
fInlineDisplay.height = static_cast<int>(height);
fInlineDisplay.stride = static_cast<int>(stride);

const uint heightValueLeft = static_cast<uint>(fInlineDisplay.lastLeft * static_cast<float>(height));
const uint heightValueRight = static_cast<uint>(fInlineDisplay.lastRight * static_cast<float>(height));
@@ -283,33 +283,30 @@ protected:
}

fInlineDisplay.pending = false;
return &fInlineDisplay.idisp;
return (NativeInlineDisplayImageSurface*)(NativeInlineDisplayImageSurfaceCompat*)&fInlineDisplay;
}

private:
int fColor, fStyle;
float fOutLeft, fOutRight;

struct InlineDisplay {
NativeInlineDisplayImageSurface idisp;
size_t dataSize;
struct InlineDisplay : NativeInlineDisplayImageSurfaceCompat {
float lastLeft;
float lastRight;
volatile bool pending;

InlineDisplay()
: idisp{},
dataSize(0),
: NativeInlineDisplayImageSurfaceCompat(),
lastLeft(0.0f),
lastRight(0.0f),
pending(false) {}

~InlineDisplay()
{
if (idisp.data != nullptr)
if (data != nullptr)
{
delete[] idisp.data;
idisp.data = nullptr;
delete[] data;
data = nullptr;
}
}



Loading…
Cancel
Save