Skip to content

Commit

Permalink
Fix for memory handling in supercollider.cpp architecture.
Browse files Browse the repository at this point in the history
  • Loading branch information
sletz committed May 2, 2017
1 parent 9fd92b1 commit c80f442
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions architecture/supercollider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ std::string fileNameToUnitName(const std::string& fileName)

// Globals

static InterfaceTable *ft;
static InterfaceTable* ft;

// The SuperCollider UGen class name generated here must match
// that generated by faust2sc:
Expand Down Expand Up @@ -419,7 +419,7 @@ void Faust_Ctor(Faust* unit) // module constructor
Print("Faust[%s]: RT memory allocation failed, try increasing the real-time memory size in the server options\n", g_unitName);

This comment has been minimized.

Copy link
@LFSaw

LFSaw May 2, 2017

This line seems to be never reached within scsynth

This comment has been minimized.

Copy link
@LFSaw

LFSaw May 2, 2017

a good test is the use-case described in #12 with e.g.

s.options.memSize_(8192);
s.reboot;
{FaustJPverbRaw.ar(SinOsc.ar, SinOsc.ar)}.scope

scsynth prints (note absence of Faust[%s]: )

exception in real time: alloc failed, increase server's memory allocation (e.g. via ServerOptions)
goto end;
}
for (int i=0; i < unit->getNumAudioInputs(); ++i) {
for (int i = 0; i < unit->getNumAudioInputs(); ++i) {
// Initialize interpolator.
unit->mInBufValue[i] = IN0(i);
// Aquire buffer memory.
Expand Down Expand Up @@ -479,15 +479,16 @@ FAUST_EXPORT void load(InterfaceTable* inTable)
ft = inTable;

MetaData meta;
mydsp tmp_dsp;
tmp_dsp.metadata(&meta);

mydsp* tmp_dsp = new FAUSTCLASS;
tmp_dsp->metadata(&meta);
delete tmp_dsp;

std::string name = meta["name"];

if (name.empty()) {
name = fileNameToUnitName(__FILE__);
}

name = normalizeClassName(name);

#if !defined(NDEBUG) & defined(SC_API_EXPORT)
Expand All @@ -502,10 +503,10 @@ FAUST_EXPORT void load(InterfaceTable* inTable)
return;
}

if (strncmp(name.c_str(),SC_FAUST_PREFIX,strlen(SC_FAUST_PREFIX))!=0) {
if (strncmp(name.c_str(), SC_FAUST_PREFIX, strlen(SC_FAUST_PREFIX)) != 0) {
name = SC_FAUST_PREFIX + name;
}

// Initialize global data
// TODO: Use correct sample rate
initState(name, 48000);
Expand Down

4 comments on commit c80f442

@sletz
Copy link
Member Author

@sletz sletz commented on c80f442 May 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is mydsp* tmp_dsp = new FAUSTCLASS; (instead of previous problematic stack allocation).

@LFSaw
Copy link

@LFSaw LFSaw commented on c80f442 May 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might need an explicit free in Dtor? (forgive my dumb comments, c(++) is really not my expertise...)

@sletz
Copy link
Member Author

@sletz sletz commented on c80f442 May 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete tmp_dsp; at line 484

@LFSaw
Copy link

@LFSaw LFSaw commented on c80f442 May 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see, that's what I meant with dumb ;)

Please sign in to comment.