Skip to content

Commit

Permalink
Fixed compilation for clang.
Browse files Browse the repository at this point in the history
  • Loading branch information
sadko4u committed Apr 20, 2022
1 parent 59e46e6 commit b2d31f7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 41 deletions.
6 changes: 3 additions & 3 deletions include/lsp-plug.in/plug-fw/wrap/jack/ports.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ namespace lsp
class MeshPort: public Port
{
private:
jack::mesh_t *pMesh;
plug::mesh_t *pMesh;

public:
explicit MeshPort(const meta::port_t *meta, Wrapper *w) : Port(meta, w)
Expand All @@ -485,7 +485,7 @@ namespace lsp

virtual int init()
{
pMesh = jack::mesh_t::create(pMetadata);
pMesh = jack::create_mesh(pMetadata);
return (pMesh == NULL) ? STATUS_NO_MEM : STATUS_OK;
}

Expand All @@ -494,7 +494,7 @@ namespace lsp
if (pMesh == NULL)
return;

jack::mesh_t::destroy(pMesh);
jack::destroy_mesh(pMesh);
pMesh = NULL;
}

Expand Down
64 changes: 30 additions & 34 deletions include/lsp-plug.in/plug-fw/wrap/jack/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,45 +147,41 @@ namespace lsp

} path_t;

typedef struct mesh_t: public plug::mesh_t
inline plug::mesh_t *create_mesh(const meta::port_t *meta)
{
static mesh_t *create(const meta::port_t *meta)
size_t buffers = meta->step;
size_t buf_size = meta->start * sizeof(float);
size_t mesh_size = sizeof(plug::mesh_t) + sizeof(float *) * buffers;

// Align values to 64-byte boundaries
buf_size = align_size(buf_size, OPTIMAL_ALIGN);
mesh_size = align_size(mesh_size, OPTIMAL_ALIGN);

// Allocate pointer
uint8_t *ptr = static_cast<uint8_t *>(malloc(mesh_size + buf_size * buffers));
if (ptr == NULL)
return NULL;

// Initialize references
plug::mesh_t *mesh = reinterpret_cast<plug::mesh_t *>(ptr);
mesh->nState = plug::M_EMPTY;
mesh->nBuffers = 0;
mesh->nItems = 0;
ptr += mesh_size;
for (size_t i=0; i<buffers; ++i)
{
size_t buffers = meta->step;
size_t buf_size = meta->start * sizeof(float);
size_t mesh_size = sizeof(mesh_t) + sizeof(float *) * buffers;

// Align values to 64-byte boundaries
buf_size = align_size(buf_size, OPTIMAL_ALIGN);
mesh_size = align_size(mesh_size, OPTIMAL_ALIGN);

// Allocate pointer
uint8_t *ptr = static_cast<uint8_t *>(malloc(mesh_size + buf_size * buffers));
if (ptr == NULL)
return NULL;

// Initialize references
mesh_t *mesh = reinterpret_cast<mesh_t *>(ptr);
mesh->nState = plug::M_EMPTY;
mesh->nBuffers = 0;
mesh->nItems = 0;
ptr += mesh_size;
for (size_t i=0; i<buffers; ++i)
{
mesh->pvData[i] = reinterpret_cast<float *>(ptr);
ptr += buf_size;
}

return mesh;
mesh->pvData[i] = reinterpret_cast<float *>(ptr);
ptr += buf_size;
}

static void destroy(mesh_t *mesh)
{
if (mesh != NULL)
free(mesh);
}
} mesh_t;
return mesh;
}

inline void destroy_mesh(plug::mesh_t *mesh)
{
if (mesh != NULL)
free(mesh);
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions include/lsp-plug.in/plug-fw/wrap/jack/ui_ports.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,24 +167,24 @@ namespace lsp
class UIMeshPort: public UIPort
{
private:
jack::mesh_t *pMesh;
plug::mesh_t *pMesh;

public:
explicit UIMeshPort(jack::Port *port): UIPort(port)
{
pMesh = jack::mesh_t::create(port->metadata());
pMesh = jack::create_mesh(port->metadata());
}

virtual ~UIMeshPort()
{
jack::mesh_t::destroy(pMesh);
jack::destroy_mesh(pMesh);
pMesh = NULL;
}

public:
virtual bool sync()
{
mesh_t *mesh = pPort->buffer<mesh_t>();
plug::mesh_t *mesh = pPort->buffer<plug::mesh_t>();
if ((mesh == NULL) || (!mesh->containsData()))
return false;

Expand Down

0 comments on commit b2d31f7

Please sign in to comment.