-Implemented worker requestNewBuffer function

This commit is contained in:
Harry van Haaren 2013-07-31 10:56:08 +01:00
parent 30ef6c4330
commit e472b4fcd4

View file

@ -13,11 +13,11 @@ using namespace std;
namespace Worker
{
/// loads a sample into a new AudioBuffer, returning the buffer
static AudioBuffer* loadSample( string path )
{
SndfileHandle infile( path, SFM_READ );
cout << "Worker: loadSample() TODO: fix memory leak using Shared()" << endl;
AudioBuffer* ab = new AudioBuffer();
std::vector<float> buf( infile.frames(), 0.f );
@ -35,6 +35,18 @@ namespace Worker
return 0;
}
/// allocates a new audiobuffer of the desired size and returns it
static AudioBuffer* allocateNewBuffer(int size)
{
AudioBuffer* ab = new AudioBuffer();
std::vector<float> buf( size, 0.f );
ab->nonRtSetSample( buf );
return ab;
}
}
#endif // LUPPP_WORKER_H