-Fixed crash when saving *during* recording. Buffer size mismatch was the cause. Need to properly handle Stately::error(), this is just a quick-fix stop-crash.

This commit is contained in:
Harry van Haaren 2013-11-13 12:03:24 +00:00
parent 460db6e81d
commit 3fdd71b7dd
3 changed files with 32 additions and 13 deletions

View file

@ -135,18 +135,27 @@ void LooperClip::setRequestedBuffer( AudioBuffer* ab )
void LooperClip::recieveSaveBuffer( AudioBuffer* saveBuffer )
{
// copy current contents into save buffer,
size_t framesBySize = _buffer->getAudioFrames();
memcpy( &saveBuffer->getData().at(0), &_buffer->getData().at(0), sizeof(float)*framesBySize);
// CRITICAL FIXME: crash on buffer size difference
if ( saveBuffer->getData().size() >= _buffer->getData().at(0) )
{
// copy current contents into save buffer,
size_t framesBySize = _buffer->getAudioFrames();
memcpy( &saveBuffer->getData().at(0), &_buffer->getData().at(0), sizeof(float)*framesBySize);
saveBuffer->setID ( _buffer->getID() );
saveBuffer->setBeats( _buffer->getBeats() );
saveBuffer->setAudioFrames( _buffer->getAudioFrames() );
saveBuffer->setID ( _buffer->getID() );
saveBuffer->setBeats( _buffer->getBeats() );
saveBuffer->setAudioFrames( _buffer->getAudioFrames() );
EventStateSaveBuffer e ( track, scene, saveBuffer );
writeToGuiRingbuffer( &e );
EventStateSaveBuffer e ( track, scene, saveBuffer );
writeToGuiRingbuffer( &e );
Stately::done();
Stately::done();
}
else
{
LUPPP_ERROR("LooperClip @ %i, %i could not save, save buffer too small!", track, scene);
Stately::error();
}
}

View file

@ -32,3 +32,9 @@ void Stately::done()
savesDone = 0; // reset in case of another save before quit
}
}
void Stately::error()
{
// CRITICAL FIXME: add error handling code, noting an error occured, perhaps prompt user?
savesDone++;
}

View file

@ -24,9 +24,13 @@ class Stately
virtual void save();
/// this function *must* be called by each sub-class when it is *finished*
/// its save action. Once each Stately is done, the final save is OK-ed.
/// a successful save action. Once each Stately is done, the final save is OK-ed.
static void done();
/// this function notes that a stately could *not* successfully save: buffer
/// size mismatch in LooperClip for example.
static void error();
private:
static int savesDone;
};