Refactor getSamples to return a unique_ptr

This commit is contained in:
Mike Walters
2015-12-29 20:42:32 +00:00
parent c96f542823
commit ceac834103
7 changed files with 20 additions and 22 deletions

View File

@@ -48,14 +48,15 @@ InputSource::~InputSource() {
fclose(m_file);
}
bool InputSource::getSamples(std::complex<float> *dest, off_t start, off_t length)
std::unique_ptr<std::complex<float>[]> InputSource::getSamples(off_t start, off_t length)
{
if(start < 0 || length < 0)
return false;
return nullptr;
if (start + length >= sampleCount)
return false;
return nullptr;
memcpy(dest, &m_data[start], length * sizeof(std::complex<float>));
return true;
std::unique_ptr<std::complex<float>[]> dest(new std::complex<float>[length]);
memcpy(dest.get(), &m_data[start], length * sizeof(std::complex<float>));
return dest;
}