Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
Removed memory allocation when reading MIDI data.
Browse files Browse the repository at this point in the history
  • Loading branch information
falkTX committed Aug 27, 2012
1 parent abf0557 commit 358867e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
4 changes: 1 addition & 3 deletions dssi-vst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#include "remotevstclient.h"
#include "rdwrops.h"

#include "dssi/ladspa.h"
#include "dssi/dssi.h"
Expand All @@ -21,9 +22,6 @@
#include <string.h>
#include <stdlib.h>

// Should be divisible by three
#define MIDI_BUFFER_SIZE 1023

class DSSIVSTPluginInstance
{
public:
Expand Down
13 changes: 2 additions & 11 deletions rdwrops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,11 @@ rdwr_readFloat(int fd, const char *file, int line)
extern unsigned char *
rdwr_readMIDIData(int fd, int **frameoffsets, int &events, const char *file, int line)
{
static unsigned char *buf = 0;
static int *frameoffbuf = 0;
static int bufEvts = 0;
static unsigned char buf[MIDI_BUFFER_SIZE * 3];
static int frameoffbuf[MIDI_BUFFER_SIZE];

rdwr_tryRead(fd, &events, sizeof(int), file, line);

if (events > bufEvts) {
delete buf;
delete frameoffbuf;
buf = new unsigned char[events * 3];
frameoffbuf = new int[events];
bufEvts = events;
}

rdwr_tryRead(fd, buf, events * 3, file, line);
rdwr_tryRead(fd, frameoffbuf, events * sizeof(int), file, line);

Expand Down
3 changes: 3 additions & 0 deletions rdwrops.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include <vector>
#include "remoteplugin.h"

// Should be divisible by three
#define MIDI_BUFFER_SIZE 1023

extern void rdwr_tryRead(int fd, void *buf, size_t count, const char *file, int line);
extern void rdwr_tryWrite(int fd, const void *buf, size_t count, const char *file, int line);
extern void rdwr_writeOpcode(int fd, RemotePluginOpcode opcode, const char *file, int line);
Expand Down

0 comments on commit 358867e

Please sign in to comment.